use of eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method doIdentityProvisioningChangeAccountTransformFromResource.
@Test
public void doIdentityProvisioningChangeAccountTransformFromResource() {
IdmIdentityDto identity = idmIdentityService.getByUsername(IDENTITY_USERNAME);
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
TestResource createdAccount = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
identity.setFirstName(IDENTITY_CHANGED_FIRST_NAME.substring(1));
identity = idmIdentityService.save(identity);
Assert.assertNotEquals(identity.getFirstName(), createdAccount.getFirstname());
provisioningService.doProvisioning(identity);
TestResource changedAccount = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
Assert.assertNotNull(changedAccount);
// Must be with "c" on target system, because we have set transformation
// from system!
Assert.assertEquals(identity.getFirstName(), changedAccount.getFirstname().substring(1));
}
use of eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method doIdentityProvisioningStrategyMerge.
@Test()
public void doIdentityProvisioningStrategyMerge() {
IdmIdentityDto identity = idmIdentityService.getByUsername(IDENTITY_USERNAME);
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
SysSystemAttributeMappingFilter filterSchemaAttr = new SysSystemAttributeMappingFilter();
filterSchemaAttr.setIdmPropertyName("email");
filterSchemaAttr.setSystemId(accountService.get(accountIdentityOne.getAccount()).getSystem());
SysSystemAttributeMappingDto attributeHandling = systemAttributeMappingService.find(filterSchemaAttr, null).getContent().get(0);
attributeHandling.setEntityAttribute(true);
attributeHandling.setStrategyType(AttributeMappingStrategyType.MERGE);
SysSchemaAttributeDto schemaAttributeDto = schemaAttributeService.get(attributeHandling.getSchemaAttribute());
schemaAttributeDto.setMultivalued(true);
schemaAttributeService.save(schemaAttributeDto);
systemAttributeMappingService.save(attributeHandling);
// Do provisioning
provisioningService.doProvisioning(identity);
}
use of eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method doIdentityProvisioningAndPasswordCheck.
@Test
public void doIdentityProvisioningAndPasswordCheck() {
IdmIdentityDto existIdentity = idmIdentityService.getByUsername(IDENTITY_USERNAME);
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(existIdentity.getId());
AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
TestResource createdAccount = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
Assert.assertNotNull(createdAccount);
// password must be exactly two 'a' characters, see setting for password
// policy
Assert.assertEquals("aa", createdAccount.getPassword());
}
use of eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method doIdentityProvisioningChangePassword.
@Test
public void doIdentityProvisioningChangePassword() {
IdmIdentityDto identity = idmIdentityService.getByUsername(IDENTITY_USERNAME);
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
SysSystemDto system = systemService.get(accountService.get(accountIdentityOne.getAccount()).getSystem());
// Create new password one
PasswordChangeDto passwordChange = new PasswordChangeDto();
passwordChange.setAccounts(ImmutableList.of(accountIdentityOne.getAccount().toString()));
passwordChange.setNewPassword(new GuardedString(IDENTITY_PASSWORD_ONE));
passwordChange.setIdm(true);
// Do change of password for selected accounts
idmIdentityService.passwordChange(identity, passwordChange);
accountIdentityOne = identityAccoutnService.get(accountIdentityOne.getId());
// Check correct password One
provisioningService.authenticate(accountService.get(accountIdentityOne.getAccount()).getUid(), new GuardedString(IDENTITY_PASSWORD_ONE), system, SystemEntityType.IDENTITY);
// Check incorrect password
try {
provisioningService.authenticate(accountService.get(accountIdentityOne.getAccount()).getUid(), new GuardedString(IDENTITY_PASSWORD_TWO), system, SystemEntityType.IDENTITY);
fail("Bad credentials exception is expected here!");
} catch (ResultCodeException ex) {
//
}
// Do change of password for selected accounts
passwordChange.setNewPassword(new GuardedString(IDENTITY_PASSWORD_TWO));
idmIdentityService.passwordChange(idmIdentityService.get(accountIdentityOne.getIdentity()), passwordChange);
// Check correct password Two
accountIdentityOne = identityAccoutnService.get(accountIdentityOne.getId());
provisioningService.authenticate(accountService.get(accountIdentityOne.getAccount()).getUid(), new GuardedString(IDENTITY_PASSWORD_TWO), system, SystemEntityType.IDENTITY);
}
use of eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method getSystem.
private SysSystemDto getSystem() {
IdmIdentityDto identity = idmIdentityService.getByUsername(IDENTITY_USERNAME);
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
return systemService.get(accountService.get(accountIdentityOne.getAccount()).getSystem());
}
Aggregations