use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.
the class IdentityGuaranteesForRoleFilterIntegrationTest method testFindGuaranteesByTypeInRole.
@Test
public void testFindGuaranteesByTypeInRole() {
// prepare data
String guaranteeType = getHelper().createName();
IdmIdentityDto identityOne = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto identityTwo = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto identityThree = getHelper().createIdentity((GuardedString) null);
IdmRoleDto role = getHelper().createRole();
IdmRoleDto roleGuarantee = getHelper().createRole();
getHelper().createRoleGuarantee(role, identityOne, guaranteeType);
getHelper().createRoleGuaranteeRole(role, roleGuarantee);
getHelper().createIdentityRole(identityThree, roleGuarantee);
getHelper().createIdentityRole(identityTwo, role);
//
IdmIdentityFilter dataFilter = new IdmIdentityFilter();
dataFilter.setGuaranteesForRole(role.getId());
dataFilter.setGuaranteeType(guaranteeType);
List<IdmIdentity> identities = filter.find(dataFilter, null).getContent();
//
Assert.assertEquals(1, identities.size());
Assert.assertTrue(identities.stream().anyMatch(i -> i.getId().equals(identityOne.getId())));
}
use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceItegrationTest method testOwnerWithoutId.
@Test(expected = IllegalArgumentException.class)
public void testOwnerWithoutId() {
// unpersisted identity
FormableEntity owner = new IdmIdentity();
formService.getValues(owner);
}
use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.
the class IdentityRoleAddAuthoritiesProcessor method checkAddedPermissions.
private void checkAddedPermissions(IdmIdentityRoleDto identityRole) {
IdmIdentityContract contract = contractRepository.findOne(identityRole.getIdentityContract());
IdmIdentity identity = contract.getIdentity();
List<IdmIdentityRoleDto> withoutAdded = identityRoleService.findAllByIdentity(identity.getId());
withoutAdded.remove(identityRole);
// represents the final authorities set after role removal
Collection<? extends GrantedAuthority> original = authorityHierarchy.getReachableGrantedAuthorities(authoritiesFactory.getGrantedAuthoritiesForValidRoles(identity.getId(), withoutAdded));
Collection<? extends GrantedAuthority> addedAuthorities = authorityHierarchy.getReachableGrantedAuthorities(authoritiesFactory.getGrantedAuthoritiesForValidRoles(identity.getId(), Collections.singletonList(identityRole)));
if (!authoritiesFactory.containsAllAuthorities(original, addedAuthorities)) {
// authorities were changed, update identity flag
IdmAuthorityChange ac = repository.findOneByIdentity_Id(identity.getId());
if (ac == null) {
ac = new IdmAuthorityChange();
ac.setIdentity(identity);
}
ac.authoritiesChanged();
repository.save(ac);
}
}
use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.
the class IdentityRoleDeleteAuthoritiesProcessor method checkRevokedPermissions.
private void checkRevokedPermissions(IdmIdentityRoleDto identityRole) {
IdmIdentityContract contract = contractRepository.findOne(identityRole.getIdentityContract());
IdmIdentity identity = contract.getIdentity();
List<IdmIdentityRoleDto> roles = identityRoleService.findAllByIdentity(identity.getId());
roles.remove(identityRole);
// represents the final authorities set after role removal
Collection<? extends GrantedAuthority> withoutDeleted = authorityHierarchy.getReachableGrantedAuthorities(authoritiesFactory.getGrantedAuthoritiesForValidRoles(identity.getId(), roles));
Collection<? extends GrantedAuthority> deletedAuthorities = authorityHierarchy.getReachableGrantedAuthorities(authoritiesFactory.getGrantedAuthoritiesForValidRoles(identity.getId(), Collections.singletonList(identityRole)));
if (!authoritiesFactory.containsAllAuthorities(withoutDeleted, deletedAuthorities)) {
// authorities were changed, update identity flag
IdmAuthorityChange ac = repository.findOneByIdentity_Id(identity.getId());
if (ac == null) {
ac = new IdmAuthorityChange();
ac.setIdentity(identity);
}
ac.authoritiesChanged();
repository.save(ac);
}
}
use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityService method createAuthorityChange.
private void createAuthorityChange(Collection<IdmIdentity> withoutAuthChange, DateTime changeTime) {
for (IdmIdentity identity : withoutAuthChange) {
IdmAuthorityChange ac = new IdmAuthorityChange();
ac.setAuthChangeTimestamp(changeTime);
ac.setIdentity(identity);
authChangeRepository.save(ac);
}
}
Aggregations