use of org.springframework.security.acls.model.Sid in project spring-security by spring-projects.
the class AdminPermissionController method deletePermission.
/**
* Deletes a permission
*/
@RequestMapping(value = "/secure/deletePermission.htm")
public ModelAndView deletePermission(@RequestParam("contactId") int contactId, @RequestParam("sid") String sid, @RequestParam("permission") int mask) {
Contact contact = contactManager.getById(new Long(contactId));
Sid sidObject = new PrincipalSid(sid);
Permission permission = permissionFactory.buildFromMask(mask);
contactManager.deletePermission(contact, sidObject, permission);
Map<String, Object> model = new HashMap<String, Object>();
model.put("contact", contact);
model.put("sid", sidObject);
model.put("permission", permission);
return new ModelAndView("deletePermission", "model", model);
}
use of org.springframework.security.acls.model.Sid in project spring-security by spring-projects.
the class BasicLookupStrategyTests method testCreateGrantedAuthority.
@Test
public void testCreateGrantedAuthority() {
Sid result = strategy.createSid(false, "sid");
assertThat(result.getClass()).isEqualTo(GrantedAuthoritySid.class);
assertThat(((GrantedAuthoritySid) result).getGrantedAuthority()).isEqualTo("sid");
}
use of org.springframework.security.acls.model.Sid in project spring-security by spring-projects.
the class BasicLookupStrategyTests method testReadAllObjectIdentitiesWhenLastElementIsAlreadyCached.
/**
* Test created from SEC-590.
*/
@Test
public void testReadAllObjectIdentitiesWhenLastElementIsAlreadyCached() throws Exception {
String query = "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (4,2,104,null,1,1);" + "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (5,2,105,4,1,1);" + "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (6,2,106,4,1,1);" + "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (7,2,107,5,1,1);" + "INSERT INTO acl_entry(ID,ACL_OBJECT_IDENTITY,ACE_ORDER,SID,MASK,GRANTING,AUDIT_SUCCESS,AUDIT_FAILURE) VALUES (5,4,0,1,1,1,0,0)";
jdbcTemplate.execute(query);
ObjectIdentity grandParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(104));
ObjectIdentity parent1Oid = new ObjectIdentityImpl(TARGET_CLASS, new Long(105));
ObjectIdentity parent2Oid = new ObjectIdentityImpl(TARGET_CLASS, Integer.valueOf(106));
ObjectIdentity childOid = new ObjectIdentityImpl(TARGET_CLASS, Integer.valueOf(107));
// First lookup only child, thus populating the cache with grandParent,
// parent1
// and child
List<Permission> checkPermission = Arrays.asList(BasePermission.READ);
List<Sid> sids = Arrays.asList(BEN_SID);
List<ObjectIdentity> childOids = Arrays.asList(childOid);
strategy.setBatchSize(6);
Map<ObjectIdentity, Acl> foundAcls = strategy.readAclsById(childOids, sids);
Acl foundChildAcl = foundAcls.get(childOid);
assertThat(foundChildAcl).isNotNull();
assertThat(foundChildAcl.isGranted(checkPermission, sids, false)).isTrue();
// Search for object identities has to be done in the following order:
// last
// element have to be one which
// is already in cache and the element before it must not be stored in
// cache
List<ObjectIdentity> allOids = Arrays.asList(grandParentOid, parent1Oid, parent2Oid, childOid);
try {
foundAcls = strategy.readAclsById(allOids, sids);
} catch (NotFoundException notExpected) {
fail("It shouldn't have thrown NotFoundException");
}
Acl foundParent2Acl = foundAcls.get(parent2Oid);
assertThat(foundParent2Acl).isNotNull();
assertThat(foundParent2Acl.isGranted(checkPermission, sids, false)).isTrue();
}
use of org.springframework.security.acls.model.Sid in project Gemma by PavlidisLab.
the class AclAdviceTest method testArrayDesignAclsUser.
@Test
public void testArrayDesignAclsUser() {
String userName = "testuser" + RandomStringUtils.randomAlphabetic(3);
this.makeUser(userName);
this.runAsUser(userName);
ArrayDesign ad = this.getTestPersistentArrayDesign(2, true, false, false);
aclTestUtils.checkHasAcl(ad);
aclTestUtils.checkHasAces(ad);
Sid owner = securityService.getOwner(ad);
assertEquals(userName, ((AclPrincipalSid) owner).getPrincipal());
arrayDesignService.update(ad);
assertEquals(userName, ((AclPrincipalSid) owner).getPrincipal());
arrayDesignService.remove(ad);
aclTestUtils.checkDeletedAcl(ad);
}
use of org.springframework.security.acls.model.Sid in project Gemma by PavlidisLab.
the class AclAdviceTest method testArrayDesignAcls.
/*
* Create Array design, check ACLs are put on correctly and removed when the design is removed. Array Designs are
* _simple_ compared to EEs!
*/
@Test
public void testArrayDesignAcls() {
// need to modify
ArrayDesign ad = this.getTestPersistentArrayDesign(2, true, false, false);
aclTestUtils.checkHasAcl(ad);
aclTestUtils.checkHasAces(ad);
Sid owner = securityService.getOwner(ad);
assertEquals("administrator", ((AclPrincipalSid) owner).getPrincipal());
arrayDesignService.remove(ad);
aclTestUtils.checkDeletedAcl(ad);
}
Aggregations