public Ace getAce(Permission permission, Authority authority, ACEType type, AccessStatus accessStatus) { ParameterCheck.mandatory("permission", permission); ParameterCheck.mandatory("authority", authority); ParameterCheck.mandatory("type", type); ParameterCheck.mandatory("accessStatus", accessStatus); return getAceEntity(permission.getId(), authority.getId(), ((accessStatus == AccessStatus.ALLOWED) ? true : false), type); }
public Ace getAce(Permission permission, Authority authority, ACEType type, AccessStatus accessStatus) { ParameterCheck.mandatory("permission", permission); ParameterCheck.mandatory("authority", authority); ParameterCheck.mandatory("type", type); ParameterCheck.mandatory("accessStatus", accessStatus); return getAceEntity(permission.getId(), authority.getId(), ((accessStatus == AccessStatus.ALLOWED) ? true : false), type); }
@Override protected int updateAuthorityEntity(AuthorityEntity authorityEntity) { Authority existingAuthorityEntity = getAuthority(authorityEntity.getAuthority()); if(existingAuthorityEntity != null) { for(Ace ace : getAceEntitiesByAuthority(existingAuthorityEntity.getId())) { AceEntity aceEntity = getAceEntity(ace.getId()); aceEntity.setAuthorityId(authorityEntity.getId()); updateAceEntity(aceEntity); } deleteAuthority(existingAuthorityEntity.getId()); } authorityEntity.incrementVersion(); return template.update(UPDATE_AUTHORITY, authorityEntity); }
@Override protected int updateAuthorityEntity(AuthorityEntity authorityEntity) { Authority existingAuthorityEntity = getAuthority(authorityEntity.getAuthority()); if(existingAuthorityEntity != null) { for(Ace ace : getAceEntitiesByAuthority(existingAuthorityEntity.getId())) { AceEntity aceEntity = getAceEntity(ace.getId()); aceEntity.setAuthorityId(authorityEntity.getId()); updateAceEntity(aceEntity); } deleteAuthority(existingAuthorityEntity.getId()); } authorityEntity.incrementVersion(); return template.update(UPDATE_AUTHORITY, authorityEntity); }
public void testCreateUpdateAndDeleteAuth() throws Exception { final String authName = getName() + "-" + System.currentTimeMillis(); Authority authEntity= getAuth(authName); assertNull(authEntity); Authority createAuthEntity = createAuth(authName); assertNotNull(createAuthEntity); authEntity= getAuth(authName); assertEquals(createAuthEntity, authEntity); String newAuthName = authName+"-new"; updateAuth(authName, newAuthName); assertNull(getAuth(authName)); authEntity = getAuth(newAuthName); assertNotNull(authEntity); assertEquals(createAuthEntity.getId(), authEntity.getId()); assertEquals(newAuthName, authEntity.getAuthority()); deleteAuth(authEntity.getId()); assertNull(getAuth(newAuthName)); }
public Ace createAce(Permission permission, Authority authority, ACEType type, AccessStatus accessStatus) { ParameterCheck.mandatory("permission", permission); ParameterCheck.mandatory("authority", authority); ParameterCheck.mandatory("type", type); ParameterCheck.mandatory("accessStatus", accessStatus); AceEntity entity = new AceEntity(); entity.setApplies(type.getId()); // note: 'applies' stores the ACE type entity.setAllowed((accessStatus == AccessStatus.ALLOWED) ? true : false); entity.setAuthorityId(authority.getId()); entity.setPermissionId(permission.getId()); long aceId = createAceEntity(entity); entity.setVersion(0L); entity.setId(aceId); return entity; }
public Ace createAce(Permission permission, Authority authority, ACEType type, AccessStatus accessStatus) { ParameterCheck.mandatory("permission", permission); ParameterCheck.mandatory("authority", authority); ParameterCheck.mandatory("type", type); ParameterCheck.mandatory("accessStatus", accessStatus); AceEntity entity = new AceEntity(); entity.setApplies(type.getId()); // note: 'applies' stores the ACE type entity.setAllowed((accessStatus == AccessStatus.ALLOWED) ? true : false); entity.setAuthorityId(authority.getId()); entity.setPermissionId(permission.getId()); long aceId = createAceEntity(entity); entity.setVersion(0L); entity.setId(aceId); return entity; }