Search in sources :

Example 6 with AccIdentityAccountDto

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));
}
Also used : AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 7 with AccIdentityAccountDto

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);
}
Also used : SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 8 with AccIdentityAccountDto

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());
}
Also used : AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 9 with AccIdentityAccountDto

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);
}
Also used : PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 10 with AccIdentityAccountDto

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());
}
Also used : AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)

Aggregations

AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)69 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)54 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)50 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)46 Test (org.junit.Test)46 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)32 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)26 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)25 TestResource (eu.bcvsolutions.idm.acc.entity.TestResource)24 PasswordChangeDto (eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto)16 ArrayList (java.util.ArrayList)16 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)13 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)11 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)10 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)10 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)10 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)10 UUID (java.util.UUID)9 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)8 IdmPasswordPolicyDto (eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto)8