use of eu.bcvsolutions.idm.core.model.entity.IdmAuthorityChange in project CzechIdMng by bcvsolutions.
the class PermissionsAuthorityChangeProcessorTest method testCreateAuthorityChangeEntity.
/**
* In case the identity in role does not have IdmAuthorityChange entity
* relation, changing role's authorities must create one.
* @throws Exception
*/
@Test
public void testCreateAuthorityChangeEntity() throws Exception {
IdmRoleDto role = getTestRole();
IdmIdentityDto i = getTestUser();
IdmIdentityContractDto c = getTestContract(i);
getTestIdentityRole(role, c);
deleteAuthorityChangedEntity(i);
IdmAuthorityChange ac = acRepository.findOneByIdentity_Id(i.getId());
Assert.assertNull(ac);
sleep();
clearAuthPolicies(role);
ac = acRepository.findOneByIdentity_Id(i.getId());
Assert.assertNotNull(ac);
Assert.assertNotNull(ac.getAuthChangeTimestamp());
}
use of eu.bcvsolutions.idm.core.model.entity.IdmAuthorityChange in project CzechIdMng by bcvsolutions.
the class OAuthAuthenticationManager method authenticate.
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
if (!(authentication instanceof IdmJwtAuthentication)) {
throw new IdmAuthenticationException("Unsupported granted authority " + authentication.getClass().getName());
}
IdmJwtAuthentication idmJwtAuthentication = (IdmJwtAuthentication) authentication;
IdmIdentityDto identity = getIdentityForToken(idmJwtAuthentication);
IdmAuthorityChange authChange = getIdentityAuthorityChange(identity);
checkIssuedTime(idmJwtAuthentication.getIssuedAt(), authChange);
checkExpirationTime(idmJwtAuthentication);
checkDisabled(identity);
// Set logged user to workflow engine
workflowIdentityService.setAuthenticatedUserId(identity.getUsername());
// set authentication
securityService.setAuthentication(idmJwtAuthentication);
//
return idmJwtAuthentication;
}
use of eu.bcvsolutions.idm.core.model.entity.IdmAuthorityChange in project CzechIdMng by bcvsolutions.
the class IdentityRoleAddAuthoritiesProcessorTest method testAddRoleDoNotModifyAuthorities.
@Test
public void testAddRoleDoNotModifyAuthorities() throws Exception {
IdmRoleDto role = getTestRole();
IdmRoleDto role2 = getTestRole();
IdmIdentityDto i = getTestUser();
IdmIdentityContractDto c = getTestContract(i);
IdmAuthorityChange ac = getAuthorityChange(i);
// user has no authorities - change flag is null
Assert.assertNull(ac);
// authority added
getTestIdentityRole(role, c);
i = identityService.get(i.getId());
ac = getAuthorityChange(i);
DateTime firstChangeTs = ac.getAuthChangeTimestamp();
Assert.assertNotNull(firstChangeTs);
Thread.sleep(10);
getTestIdentityRole(role2, c);
i = identityService.get(i.getId());
ac = getAuthorityChange(i);
Assert.assertEquals(firstChangeTs, ac.getAuthChangeTimestamp());
}
use of eu.bcvsolutions.idm.core.model.entity.IdmAuthorityChange in project CzechIdMng by bcvsolutions.
the class IdentityRoleAddAuthoritiesProcessorTest method testAddRoleModifyAuthorities.
@Test
public void testAddRoleModifyAuthorities() {
IdmRoleDto role = getTestRole();
IdmIdentityDto i = getTestUser();
IdmIdentityContractDto c = getTestContract(i);
IdmAuthorityChange ac = getAuthorityChange(i);
// user has no authorities - change flag is null
Assert.assertNull(ac);
// authority added
getTestIdentityRole(role, c);
i = identityService.get(i.getId());
ac = getAuthorityChange(i);
Assert.assertNotNull(ac);
Assert.assertNotNull(ac.getAuthChangeTimestamp());
}
use of eu.bcvsolutions.idm.core.model.entity.IdmAuthorityChange in project CzechIdMng by bcvsolutions.
the class PermissionsAuthorityChangeProcessorTest method testChangePersmissions.
/**
* Change permissions type for given policy.
* @throws Exception
*/
@Test
public void testChangePersmissions() throws Exception {
securityService.setSystemAuthentication();
IdmRoleDto role = getTestRole();
IdmIdentityDto i = getTestUser();
IdmIdentityContractDto c = getTestContract(i);
getTestIdentityRole(role, c);
IdmAuthorityChange ac = acRepository.findOneByIdentity_Id(i.getId());
Assert.assertNotNull(ac);
Assert.assertNotNull(ac.getAuthChangeTimestamp());
DateTime origChangeTime = ac.getAuthChangeTimestamp();
sleep();
changeAuthorizationPolicyPermissions(role);
ac = acRepository.findOneByIdentity_Id(i.getId());
Assert.assertNotNull(ac);
Assert.assertNotNull(ac.getAuthChangeTimestamp());
Assert.assertTrue(origChangeTime.getMillis() < ac.getAuthChangeTimestamp().getMillis());
}
Aggregations