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());
}
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));
}
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);
}
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);
}
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);
}
}
Aggregations