Search in sources :

Example 16 with ProvisioningAttributeDto

use of eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto in project CzechIdMng by bcvsolutions.

the class DefaultProvisioningExecutorIntegrationTest method testGreenLineAccountProvisioning.

@Test
public void testGreenLineAccountProvisioning() {
    SysSystemDto system = helper.createTestResourceSystem(true);
    ProvisioningAttributeDto usernameAttribute = getProvisioningAttribute(TestHelper.ATTRIBUTE_MAPPING_NAME);
    ProvisioningAttributeDto firstNameAttribute = getProvisioningAttribute(TestHelper.ATTRIBUTE_MAPPING_FIRSTNAME);
    ProvisioningAttributeDto lastNameAttribute = getProvisioningAttribute(TestHelper.ATTRIBUTE_MAPPING_LASTNAME);
    ProvisioningAttributeDto passwordAttribute = getProvisioningAttribute(TestHelper.ATTRIBUTE_MAPPING_PASSWORD);
    // 
    // create test provisioning context
    SysProvisioningOperationDto provisioningOperation = createProvisioningOperation(system, "firstname");
    IcObjectClass objectClass = provisioningOperation.getProvisioningContext().getConnectorObject().getObjectClass();
    Map<ProvisioningAttributeDto, Object> accoutObject = provisioningOperation.getProvisioningContext().getAccountObject();
    String uid = (String) accoutObject.get(usernameAttribute);
    GuardedString password = (GuardedString) accoutObject.get(passwordAttribute);
    // 
    // publish event
    provisioningExecutor.execute(provisioningOperation);
    // 
    // check target account
    IcUidAttribute uidAttribute = new IcUidAttributeImpl(null, uid, null);
    IcConnectorObject existsConnectorObject = connectorFacade.readObject(system.getConnectorInstance(), systemService.getConnectorConfiguration(system), objectClass, uidAttribute);
    // 
    assertNotNull(existsConnectorObject);
    assertEquals(uid, existsConnectorObject.getUidValue());
    assertEquals(accoutObject.get(firstNameAttribute), existsConnectorObject.getAttributeByName(TestHelper.ATTRIBUTE_MAPPING_FIRSTNAME).getValue());
    assertEquals(accoutObject.get(lastNameAttribute), existsConnectorObject.getAttributeByName(TestHelper.ATTRIBUTE_MAPPING_LASTNAME).getValue());
    // authenticate for password check
    IcUidAttribute attribute = connectorFacade.authenticateObject(system.getConnectorInstance(), systemService.getConnectorConfiguration(system), objectClass, uid, password);
    assertNotNull(attribute);
    assertEquals(uid, attribute.getUidValue());
    // 
    // check system entity
    SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
    assertFalse(systemEntity.isWish());
}
Also used : IcUidAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcUidAttributeImpl) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 17 with ProvisioningAttributeDto

use of eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto in project CzechIdMng by bcvsolutions.

the class DefaultProvisioningExecutorIntegrationTest method testReadonlySystem.

@Test
public void testReadonlySystem() {
    SysSystemDto system = helper.createTestResourceSystem(true);
    system.setReadonly(true);
    system = systemService.save(system);
    ProvisioningAttributeDto usernameAttribute = getProvisioningAttribute(TestHelper.ATTRIBUTE_MAPPING_NAME);
    ProvisioningAttributeDto firstNameAttribute = getProvisioningAttribute(TestHelper.ATTRIBUTE_MAPPING_FIRSTNAME);
    ProvisioningAttributeDto lastNameAttribute = getProvisioningAttribute(TestHelper.ATTRIBUTE_MAPPING_LASTNAME);
    ProvisioningAttributeDto passwordAttribute = getProvisioningAttribute(TestHelper.ATTRIBUTE_MAPPING_PASSWORD);
    // 
    // create test provisioning context
    SysProvisioningOperationDto provisioningOperation = createProvisioningOperation(system, "firstname");
    IcObjectClass objectClass = provisioningOperation.getProvisioningContext().getConnectorObject().getObjectClass();
    Map<ProvisioningAttributeDto, Object> accoutObject = provisioningOperation.getProvisioningContext().getAccountObject();
    String uid = (String) accoutObject.get(usernameAttribute);
    GuardedString password = (GuardedString) accoutObject.get(passwordAttribute);
    // 
    // publish event
    provisioningExecutor.execute(provisioningOperation);
    // is necessary to get again operation from service
    SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
    filter.setSystemEntity(provisioningOperation.getSystemEntity());
    filter.setSystemId(system.getId());
    SysProvisioningOperationDto readOnlyoperation = provisioningOperationService.find(filter, null).getContent().get(0);
    // 
    assertEquals(OperationState.NOT_EXECUTED, readOnlyoperation.getResultState());
    assertEquals(AccResultCode.PROVISIONING_SYSTEM_READONLY.name(), readOnlyoperation.getResult().getModel().getStatusEnum());
    // 
    IcUidAttribute uidAttribute = new IcUidAttributeImpl(null, uid, null);
    IcConnectorObject existsConnectorObject = connectorFacade.readObject(system.getConnectorInstance(), systemService.getConnectorConfiguration(system), objectClass, uidAttribute);
    // 
    assertNull(existsConnectorObject);
    // passwords are stored in confidential storage
    assertNotNull(confidentialStorage.get(readOnlyoperation.getId(), SysProvisioningOperation.class, provisioningOperationService.createAccountObjectPropertyKey(passwordAttribute.getKey(), 0)));
    assertNotNull(confidentialStorage.get(readOnlyoperation.getId(), SysProvisioningOperation.class, provisioningOperationService.createConnectorObjectPropertyKey(readOnlyoperation.getProvisioningContext().getConnectorObject().getAttributeByName(passwordAttribute.getSchemaAttributeName()), 0)));
    // 
    system.setReadonly(false);
    system = systemService.save(system);
    // 
    provisioningExecutor.execute(readOnlyoperation);
    // is necessary to get again operation from service
    Assert.assertNull(provisioningOperationService.get(readOnlyoperation.getId()));
    // 
    // check target account
    existsConnectorObject = connectorFacade.readObject(system.getConnectorInstance(), systemService.getConnectorConfiguration(system), objectClass, uidAttribute);
    // 
    assertNotNull(existsConnectorObject);
    assertEquals(uid, existsConnectorObject.getUidValue());
    assertEquals(accoutObject.get(firstNameAttribute), existsConnectorObject.getAttributeByName(TestHelper.ATTRIBUTE_MAPPING_FIRSTNAME).getValue());
    assertEquals(accoutObject.get(lastNameAttribute), existsConnectorObject.getAttributeByName(TestHelper.ATTRIBUTE_MAPPING_LASTNAME).getValue());
    // authenticate for password check
    IcUidAttribute attribute = connectorFacade.authenticateObject(system.getConnectorInstance(), systemService.getConnectorConfiguration(system), objectClass, uid, password);
    assertNotNull(attribute);
    assertEquals(uid, attribute.getUidValue());
    // passwords are removed in confidential storage
    assertNull(confidentialStorage.get(readOnlyoperation.getId(), SysProvisioningOperation.class, provisioningOperationService.createAccountObjectPropertyKey(TestHelper.ATTRIBUTE_MAPPING_PASSWORD, 0)));
    // 
    String connectorObjectPropertyKey = provisioningOperationService.createConnectorObjectPropertyKey(readOnlyoperation.getProvisioningContext().getConnectorObject().getAttributeByName(TestHelper.ATTRIBUTE_MAPPING_PASSWORD), 0);
    // 
    assertNull(confidentialStorage.get(readOnlyoperation.getId(), SysProvisioningOperation.class, connectorObjectPropertyKey));
}
Also used : SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysProvisioningOperation(eu.bcvsolutions.idm.acc.entity.SysProvisioningOperation) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) IcUidAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcUidAttributeImpl) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 18 with ProvisioningAttributeDto

use of eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningOperationServiceUnitTest method testReplaceArrayGuardedStringsInAccountObject.

@Test
public void testReplaceArrayGuardedStringsInAccountObject() {
    ProvisioningContext context = new ProvisioningContext();
    Map<ProvisioningAttributeDto, Object> accoutObject = new HashMap<>();
    context.setAccountObject(accoutObject);
    // 
    // fill properties
    ProvisioningAttributeDto guarded = new ProvisioningAttributeDto("guarded", AttributeMappingStrategyType.SET);
    GuardedString guardedOne = new GuardedString("one");
    GuardedString guardedTwo = new GuardedString("two");
    accoutObject.put(guarded, new GuardedString[] { guardedOne, guardedTwo });
    // 
    // run
    Map<String, Serializable> confidentiaValues = service.replaceGuardedStrings(context);
    // 
    // check
    assertEquals(2, confidentiaValues.size());
    assertEquals(guardedOne.asString(), confidentiaValues.get(service.createAccountObjectPropertyKey(guarded.getKey(), 0)));
    assertEquals(guardedTwo.asString(), confidentiaValues.get(service.createAccountObjectPropertyKey(guarded.getKey(), 1)));
    assertEquals(2, ((Object[]) accoutObject.get(guarded)).length);
    assertEquals(service.createAccountObjectPropertyKey(guarded.getKey(), 0), ((ConfidentialString) ((Object[]) accoutObject.get(guarded))[0]).getKey());
    assertEquals(service.createAccountObjectPropertyKey(guarded.getKey(), 1), ((ConfidentialString) ((Object[]) accoutObject.get(guarded))[1]).getKey());
}
Also used : ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) Serializable(java.io.Serializable) HashMap(java.util.HashMap) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AbstractVerifiableUnitTest(eu.bcvsolutions.idm.test.api.AbstractVerifiableUnitTest) Test(org.junit.Test)

Example 19 with ProvisioningAttributeDto

use of eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningOperationServiceUnitTest method testReplaceSingleGuardedStringsInAccountObject.

@Test
public void testReplaceSingleGuardedStringsInAccountObject() {
    ProvisioningContext context = new ProvisioningContext();
    Map<ProvisioningAttributeDto, Object> accoutObject = new HashMap<>();
    context.setAccountObject(accoutObject);
    // 
    // fill properties
    ProvisioningAttributeDto normal = new ProvisioningAttributeDto("normal", AttributeMappingStrategyType.SET);
    String normalValue = "one";
    accoutObject.put(normal, normalValue);
    ProvisioningAttributeDto guarded = new ProvisioningAttributeDto("guarded", AttributeMappingStrategyType.SET);
    GuardedString guardedValue = new GuardedString("one");
    accoutObject.put(guarded, guardedValue);
    // 
    // run
    Map<String, Serializable> confidentiaValues = service.replaceGuardedStrings(context);
    // 
    // check
    assertEquals(1, confidentiaValues.size());
    assertEquals(guardedValue.asString(), confidentiaValues.get(service.createAccountObjectPropertyKey(guarded.getKey(), 0)));
    assertEquals(normalValue, accoutObject.get(normal));
    assertNotEquals(guardedValue, accoutObject.get(guardedValue));
}
Also used : ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) Serializable(java.io.Serializable) HashMap(java.util.HashMap) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AbstractVerifiableUnitTest(eu.bcvsolutions.idm.test.api.AbstractVerifiableUnitTest) Test(org.junit.Test)

Example 20 with ProvisioningAttributeDto

use of eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningOperationServiceUnitTest method testReplaceGuardedStringsInEmptyAccountObject.

@Test
public void testReplaceGuardedStringsInEmptyAccountObject() {
    ProvisioningContext context = new ProvisioningContext();
    Map<ProvisioningAttributeDto, Object> accoutObjet = new HashMap<>();
    context.setAccountObject(accoutObjet);
    Map<String, Serializable> confidentialValues = service.replaceGuardedStrings(context);
    assertEquals(0, confidentialValues.size());
}
Also used : ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) Serializable(java.io.Serializable) HashMap(java.util.HashMap) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AbstractVerifiableUnitTest(eu.bcvsolutions.idm.test.api.AbstractVerifiableUnitTest) Test(org.junit.Test)

Aggregations

ProvisioningAttributeDto (eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto)23 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)18 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)16 ProvisioningContext (eu.bcvsolutions.idm.acc.domain.ProvisioningContext)15 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)15 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)14 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)11 SysProvisioningOperationFilter (eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter)10 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)9 IcConnectorObjectImpl (eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl)9 ArrayList (java.util.ArrayList)8 Collection (java.util.Collection)8 List (java.util.List)8 Test (org.junit.Test)8 IcAttribute (eu.bcvsolutions.idm.ic.api.IcAttribute)7 ImmutableMap (com.google.common.collect.ImmutableMap)6 AccResultCode (eu.bcvsolutions.idm.acc.domain.AccResultCode)6 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)6 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)6 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)6