Search in sources :

Example 16 with IcObjectClass

use of eu.bcvsolutions.idm.ic.api.IcObjectClass 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 IcObjectClass

use of eu.bcvsolutions.idm.ic.api.IcObjectClass 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 IcObjectClass

use of eu.bcvsolutions.idm.ic.api.IcObjectClass in project CzechIdMng by bcvsolutions.

the class ConnIdIcConvertUtil method convertConnIdSyncDelta.

public static IcSyncDelta convertConnIdSyncDelta(SyncDelta delta) {
    if (delta == null) {
        return null;
    }
    IcSyncToken token = ConnIdIcConvertUtil.convertConnIdSyncToken(delta.getToken());
    IcSyncDeltaTypeEnum deltaType = IcSyncDeltaTypeEnum.valueOf(delta.getDeltaType().name());
    IcUidAttribute previousUid = ConnIdIcConvertUtil.convertConnIdUid(delta.getPreviousUid());
    IcObjectClass objectClass = ConnIdIcConvertUtil.convertConnIdObjectClass(delta.getObjectClass());
    IcUidAttribute uid = ConnIdIcConvertUtil.convertConnIdUid(delta.getUid());
    IcConnectorObject object = ConnIdIcConvertUtil.convertConnIdConnectorObject(delta.getObject());
    return new IcSyncDeltaImpl(token, deltaType, previousUid, objectClass, uid, object);
}
Also used : IcSyncDeltaTypeEnum(eu.bcvsolutions.idm.ic.impl.IcSyncDeltaTypeEnum) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcSyncDeltaImpl(eu.bcvsolutions.idm.ic.impl.IcSyncDeltaImpl) IcSyncToken(eu.bcvsolutions.idm.ic.api.IcSyncToken) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute)

Example 19 with IcObjectClass

use of eu.bcvsolutions.idm.ic.api.IcObjectClass in project CzechIdMng by bcvsolutions.

the class ConnIdIcConnectorService method updateObject.

@Override
public IcUidAttribute updateObject(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration, IcObjectClass objectClass, IcUidAttribute uid, List<IcAttribute> replaceAttributes) {
    Assert.notNull(connectorInstance);
    Assert.notNull(connectorInstance.getConnectorKey());
    Assert.notNull(connectorConfiguration);
    Assert.notNull(replaceAttributes);
    Assert.notNull(uid);
    LOG.debug("Update object - ConnId (Uid= {} {} {})", uid, connectorInstance.getConnectorKey().toString(), replaceAttributes.toString());
    ConnectorFacade conn = getConnectorFacade(connectorInstance, connectorConfiguration);
    Set<Attribute> connIdAttributes = new HashSet<>();
    for (IcAttribute icAttribute : replaceAttributes) {
        connIdAttributes.add(ConnIdIcConvertUtil.convertIcAttribute(icAttribute));
    }
    ObjectClass objectClassConnId = ConnIdIcConvertUtil.convertIcObjectClass(objectClass);
    if (objectClassConnId == null) {
        objectClassConnId = ObjectClass.ACCOUNT;
    }
    Uid updatedUid = conn.update(objectClassConnId, ConnIdIcConvertUtil.convertIcUid(uid), connIdAttributes, null);
    LOG.debug("Updated object - ConnId ({} {}) Uid= {})", connectorInstance.getConnectorKey().toString(), replaceAttributes.toString(), updatedUid);
    return ConnIdIcConvertUtil.convertConnIdUid(updatedUid);
}
Also used : Uid(org.identityconnectors.framework.common.objects.Uid) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) ObjectClass(org.identityconnectors.framework.common.objects.ObjectClass) Attribute(org.identityconnectors.framework.common.objects.Attribute) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) ConnectorFacade(org.identityconnectors.framework.api.ConnectorFacade) HashSet(java.util.HashSet)

Example 20 with IcObjectClass

use of eu.bcvsolutions.idm.ic.api.IcObjectClass in project CzechIdMng by bcvsolutions.

the class ConnIdIcConnectorService method authenticateObject.

@Override
public IcUidAttribute authenticateObject(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration, IcObjectClass objectClass, String username, GuardedString password) {
    Assert.notNull(connectorInstance);
    Assert.notNull(connectorInstance.getConnectorKey());
    Assert.notNull(connectorConfiguration);
    Assert.notNull(username);
    LOG.debug("Authenticate object - ConnId (username= {} {})", username, connectorInstance.getConnectorKey().toString());
    ConnectorFacade conn = getConnectorFacade(connectorInstance, connectorConfiguration);
    ObjectClass objectClassConnId = ConnIdIcConvertUtil.convertIcObjectClass(objectClass);
    if (objectClassConnId == null) {
        objectClassConnId = ObjectClass.ACCOUNT;
    }
    try {
        IcUidAttribute uid = ConnIdIcConvertUtil.convertConnIdUid(conn.authenticate(objectClassConnId, username, new org.identityconnectors.common.security.GuardedString(password.asString().toCharArray()), null));
        LOG.debug("Authenticated object - ConnId (Uid= {})", uid);
        return uid;
    } catch (InvalidCredentialException ex) {
        throw new ResultCodeException(IcResultCode.AUTH_FAILED, ex);
    }
}
Also used : IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) ObjectClass(org.identityconnectors.framework.common.objects.ObjectClass) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) ConnectorFacade(org.identityconnectors.framework.api.ConnectorFacade) InvalidCredentialException(org.identityconnectors.framework.common.exceptions.InvalidCredentialException) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString)

Aggregations

IcObjectClass (eu.bcvsolutions.idm.ic.api.IcObjectClass)22 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)16 IcUidAttribute (eu.bcvsolutions.idm.ic.api.IcUidAttribute)13 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)11 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)8 IcConnectorFacade (eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade)8 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)7 ConnectorFacade (org.identityconnectors.framework.api.ConnectorFacade)7 ObjectClass (org.identityconnectors.framework.common.objects.ObjectClass)7 ProvisioningAttributeDto (eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto)6 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)6 IcConnectorConfiguration (eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration)6 IcObjectClassImpl (eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl)6 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)5 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)5 IcAttribute (eu.bcvsolutions.idm.ic.api.IcAttribute)5 IcUidAttributeImpl (eu.bcvsolutions.idm.ic.impl.IcUidAttributeImpl)5 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)4 IcConnectorObjectImpl (eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl)4 ArrayList (java.util.ArrayList)4