List of usage examples for org.apache.shiro.authz AuthorizationException AuthorizationException
public AuthorizationException()
From source file:com.thesett.util.security.shiro.LocalSubject.java
License:Apache License
/** {@inheritDoc} */ public void checkPermission(String permission) throws AuthorizationException { if (!isPermitted(permission)) { throw new AuthorizationException(); }//from ww w . j av a 2 s .c o m }
From source file:com.thesett.util.security.shiro.LocalSubject.java
License:Apache License
/** {@inheritDoc} */ public void checkPermission(org.apache.shiro.authz.Permission permission) throws AuthorizationException { if (!isPermitted(permission)) { throw new AuthorizationException(); }//from w w w .j a v a 2 s. co m }
From source file:com.thesett.util.security.shiro.LocalSubject.java
License:Apache License
/** {@inheritDoc} */ public void checkPermissions(String... permissions) throws AuthorizationException { if (!isPermittedAll(permissions)) { throw new AuthorizationException(); }//from w w w. java 2 s. c om }
From source file:com.thesett.util.security.shiro.LocalSubject.java
License:Apache License
/** {@inheritDoc} */ public void checkPermissions(Collection<org.apache.shiro.authz.Permission> permissions) throws AuthorizationException { if (!isPermittedAll(permissions)) { throw new AuthorizationException(); }/*from w ww.j av a 2s .c om*/ }
From source file:de.cosmocode.palava.security.aspectj.SecurityTest.java
License:Apache License
/** * Runs before class und binds a dummy subject. *//*from ww w . j a v a2 s .c o m*/ @BeforeClass public static void beforeClass() { Guice.createInjector(new Module() { @Override public void configure(Binder binder) { final Subject subject = EasyMock.createMock("subject", Subject.class); EasyMock.expect(subject.isAuthenticated()).andStubReturn(false); EasyMock.expect(subject.isRemembered()).andStubReturn(false); subject.checkPermissions("access"); EasyMock.expectLastCall().andStubThrow(new AuthorizationException()); subject.checkRoles(Arrays.asList("admin")); EasyMock.expectLastCall().andStubThrow(new AuthorizationException()); EasyMock.replay(subject); binder.bind(Subject.class).toInstance(subject); } }); }
From source file:org.mobicents.servlet.restcomm.http.AbstractEndpoint.java
License:Open Source License
protected void secure(final Account account, final String permission) throws AuthorizationException { final Subject subject = SecurityUtils.getSubject(); final Sid accountSid = account.getSid(); if (account.getStatus().equals(Account.Status.ACTIVE) && (subject.hasRole("Administrator") || (subject.getPrincipal().equals(accountSid) && subject.isPermitted(permission)))) { return;//from w w w . j av a 2s .co m } else { throw new AuthorizationException(); } }
From source file:org.mobicents.servlet.restcomm.http.ApplicationsEndpoint.java
License:Open Source License
protected boolean secureLevelControlApplications(String accountSid, Application app) { String sidPrincipal = String.valueOf(SecurityUtils.getSubject().getPrincipal()); if (!sidPrincipal.equals(String.valueOf(accountSid))) { throw new AuthorizationException(); } else if (app != null && app.getAccountSid() != null && !sidPrincipal.equals(String.valueOf(app.getAccountSid()))) { throw new AuthorizationException(); }// ww w . ja v a 2 s . c o m return true; }
From source file:org.mobicents.servlet.sip.restcomm.http.AbstractEndpoint.java
License:Open Source License
protected void secure(final Sid accountSid, final String permission) throws AuthorizationException { final Subject subject = SecurityUtils.getSubject(); if (subject.hasRole("Administrator") || (subject.getPrincipal().equals(accountSid) && subject.isPermitted(permission))) { return;//from ww w .j av a2 s .c o m } else { throw new AuthorizationException(); } }
From source file:org.obiba.mica.access.rest.DataAccessRequestResource.java
License:Open Source License
@PUT @Path("/_log-actions") @Timed// www .j a v a 2s . c o m public Response updateActionLogs(@PathParam("id") String id, Mica.DataAccessRequestDto dto) { if (!SecurityUtils.getSubject().hasRole(Roles.MICA_DAO) && !SecurityUtils.getSubject().hasRole(Roles.MICA_ADMIN)) { throw new AuthorizationException(); } if (!id.equals(dto.getId())) throw new BadRequestException(); DataAccessRequest request = dtos.fromDto(dto); dataAccessRequestService.saveActionsLogs(request); return Response.noContent().build(); }
From source file:org.obiba.mica.variable.search.rest.PublishedDatasetVariablesSetResource.java
License:Open Source License
private DocumentSet getSecuredDocumentSet(String id) { DocumentSet documentSet = variableSetService.get(id); if (!subjectAclService.isCurrentUser(documentSet.getUsername())) throw new AuthorizationException(); MicaConfig config = micaConfigService.getConfig(); if (!config.isCartEnabled() && !documentSet.hasName()) throw new AuthorizationException(); // cart if (config.isCartEnabled() && !config.isAnonymousCanCreateCart() && !subjectAclService.hasMicaRole() && !documentSet.hasName()) throw new AuthorizationException(); // cart if (documentSet.hasName() && !subjectAclService.hasMicaRole()) throw new AuthorizationException(); return documentSet; }