List of usage examples for org.springframework.security.acls.model MutableAcl isGranted
boolean isGranted(List<Permission> permission, List<Sid> sids, boolean administrativeMode) throws NotFoundException, UnloadedSidException;
From source file:org.createnet.raptor.auth.service.services.AclManagerService.java
@Retryable(maxAttempts = 3, value = AclManagerException.class, backoff = @Backoff(delay = 200, multiplier = 3)) private void isPermissionGranted(Permission permission, Sid sid, MutableAcl acl) { try {/* ww w. ja v a 2 s . c o m*/ try { acl.isGranted(Arrays.asList(permission), Arrays.asList(sid), false); } catch (NotFoundException e) { acl.insertAce(acl.getEntries().size(), permission, sid, true); } } catch (Exception e) { log.warn("Failed to add ACE: {}", e.getMessage()); throw new AclManagerException(e); } }
From source file:org.jtalks.common.service.security.AclManagerImplTest.java
private void assertNotGranted(MutableAcl acl, Sid sid, Permission permission, String message) { List<Permission> expectedPermission = new ArrayList<Permission>(); expectedPermission.add(permission);/* w w w.j a v a2 s . c o m*/ List<Sid> expectedSid = new ArrayList<Sid>(); expectedSid.add(sid); try { if (!acl.isGranted(expectedPermission, expectedSid, false)) return; fail(message); } catch (NotFoundException e) { } }
From source file:org.jtalks.common.service.security.AclManagerImplTest.java
private void assertGranted(MutableAcl acl, Sid sid, Permission permission, String message) { List<Permission> expectedPermission = new ArrayList<Permission>(); expectedPermission.add(permission);//from w w w . ja v a 2 s . c o m List<Sid> expectedSid = new ArrayList<Sid>(); expectedSid.add(sid); try { assertTrue(acl.isGranted(expectedPermission, expectedSid, true), message); } catch (NotFoundException e) { fail(message); } }
From source file:org.createnet.raptor.auth.service.services.AclManagerService.java
@Override public <T> boolean isPermissionGranted(Class<T> clazz, Serializable identifier, Sid sid, Permission permission) {/* ww w . j ava 2 s. c o m*/ ObjectIdentity identity = new ObjectIdentityImpl(clazz.getCanonicalName(), identifier); MutableAcl acl = (MutableAcl) aclService.readAclById(identity); boolean isGranted = false; try { log.debug("Check if {} can {} on {}:{}", sid, RaptorPermission.toLabel(permission), clazz, identifier); isGranted = acl.isGranted(Arrays.asList(permission), Arrays.asList(sid), false); log.debug("{} {}ALLOWED {} on {}:{}", sid, (isGranted ? "" : "NOT "), RaptorPermission.toLabel(permission), clazz, identifier); } catch (NotFoundException e) { log.info("Unable to find an ACE for {} on {}:{} - {}", RaptorPermission.toLabel(permission), clazz, identifier, e.getMessage()); } catch (UnloadedSidException e) { log.error("Unloaded Sid for {} on {}:{} - {}", RaptorPermission.toLabel(permission), clazz, identifier, e.getMessage(), e); } return isGranted; }