use of eu.bcvsolutions.idm.ic.api.IcUidAttribute in project CzechIdMng by bcvsolutions.
the class AbstractProvisioningProcessor method process.
/**
* Prepare provisioning operation execution
*/
@Override
public EventResult<SysProvisioningOperationDto> process(EntityEvent<SysProvisioningOperationDto> event) {
SysProvisioningOperationDto provisioningOperation = event.getContent();
SysSystemDto system = systemService.get(provisioningOperation.getSystem());
IcConnectorObject connectorObject = provisioningOperation.getProvisioningContext().getConnectorObject();
IcObjectClass objectClass = connectorObject.getObjectClass();
String uid = systemEntityService.getByProvisioningOperation(provisioningOperation).getUid();
LOG.debug("Start provisioning operation [{}] for object with uid [{}] and connector object [{}]", provisioningOperation.getOperationType(), uid, objectClass.getType());
// Find connector identification persisted in system
if (system.getConnectorKey() == null) {
throw new ProvisioningException(AccResultCode.CONNECTOR_KEY_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
}
// load connector configuration
IcConnectorConfiguration connectorConfig = systemService.getConnectorConfiguration(systemService.get(provisioningOperation.getSystem()));
if (connectorConfig == null) {
throw new ProvisioningException(AccResultCode.CONNECTOR_CONFIGURATION_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
}
//
try {
provisioningOperation = provisioningOperationService.save(provisioningOperation);
// convert confidential string to guarded strings before provisioning realization
connectorObject = provisioningOperationService.getFullConnectorObject(provisioningOperation);
provisioningOperation.getProvisioningContext().setConnectorObject(connectorObject);
//
IcUidAttribute resultUid = processInternal(provisioningOperation, connectorConfig);
// update system entity, when identifier on target system differs
if (resultUid != null && resultUid.getUidValue() != null) {
SysSystemEntityDto systemEntity = systemEntityService.getByProvisioningOperation(provisioningOperation);
// If system entity was not found, we try found system entity by returned UID
if (systemEntity == null) {
systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, provisioningOperation.getEntityType(), resultUid.getUidValue());
}
Asserts.notNull(systemEntity, "Systeme entity cannot be null!");
if (!systemEntity.getUid().equals(resultUid.getUidValue()) || systemEntity.isWish()) {
systemEntity.setUid(resultUid.getUidValue());
systemEntity.setWish(false);
systemEntity = systemEntityService.save(systemEntity);
LOG.info("UID was changed. System entity with uid [{}] was updated", systemEntity.getUid());
}
}
provisioningOperationService.handleSuccessful(provisioningOperation);
} catch (Exception ex) {
provisioningOperationService.handleFailed(provisioningOperation, ex);
}
// set operation back to content
event.setContent(provisioningOperation);
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.ic.api.IcUidAttribute in project CzechIdMng by bcvsolutions.
the class ProvisioningCreateProcessor method processInternal.
@Override
public IcUidAttribute processInternal(SysProvisioningOperationDto provisioningOperation, IcConnectorConfiguration connectorConfig) {
// get system for password policy
SysSystemDto system = systemService.get(provisioningOperation.getSystem());
// execute provisioning
IcConnectorObject connectorObject = provisioningOperation.getProvisioningContext().getConnectorObject();
for (IcAttribute attribute : connectorObject.getAttributes()) {
// if attribute is password and his value is empty, generate new password
if (attribute instanceof IcPasswordAttribute && ((IcPasswordAttribute) attribute).getPasswordValue() == null) {
UUID passwordPolicyId = system.getPasswordPolicyGenerate();
//
String password = null;
if (passwordPolicyId == null) {
LOG.debug("Generate password policy for system [{}], not found. Password will be generate by default password policy", system.getCode());
password = passwordPolicyService.generatePasswordByDefault();
} else {
LOG.debug("Generate password policy for system [{}] found", system.getCode());
password = passwordPolicyService.generatePassword(passwordPolicyService.get(passwordPolicyId));
}
//
connectorObject.getAttributes().remove(attribute);
connectorObject.getAttributes().add(new IcPasswordAttributeImpl(ProvisioningService.PASSWORD_SCHEMA_PROPERTY_NAME, new GuardedString(password)));
break;
}
}
//
IcUidAttribute icUid = connectorFacade.createObject(systemService.getConnectorInstance(system), connectorConfig, connectorObject.getObjectClass(), connectorObject.getAttributes());
//
// set connector object back to provisioning context
provisioningOperation.getProvisioningContext().setConnectorObject(connectorObject);
// has to be first - we need to replace guarded strings before systemEntityService.save(systemEntity)
provisioningOperation = provisioningOperationService.save(provisioningOperation);
return icUid;
}
use of eu.bcvsolutions.idm.ic.api.IcUidAttribute in project CzechIdMng by bcvsolutions.
the class ConnIdIcConnectorService method createObject.
@Override
public IcUidAttribute createObject(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration, IcObjectClass objectClass, List<IcAttribute> attributes) {
Assert.notNull(connectorInstance);
Assert.notNull(connectorInstance.getConnectorKey());
Assert.notNull(connectorConfiguration);
Assert.notNull(attributes);
LOG.debug("Create object - ConnId ({} {})", connectorInstance.getConnectorKey().toString(), attributes.toString());
ConnectorFacade conn = getConnectorFacade(connectorInstance, connectorConfiguration);
Set<Attribute> connIdAttributes = new HashSet<>();
for (IcAttribute icAttribute : attributes) {
connIdAttributes.add(ConnIdIcConvertUtil.convertIcAttribute(icAttribute));
}
ObjectClass objectClassConnId = ConnIdIcConvertUtil.convertIcObjectClass(objectClass);
if (objectClassConnId == null) {
objectClassConnId = ObjectClass.ACCOUNT;
}
Uid uid = conn.create(objectClassConnId, connIdAttributes, null);
LOG.debug("Created object - ConnId ({} {}) Uid= {}", connectorInstance.getConnectorKey().toString(), attributes.toString(), uid);
return ConnIdIcConvertUtil.convertConnIdUid(uid);
}
use of eu.bcvsolutions.idm.ic.api.IcUidAttribute in project CzechIdMng by bcvsolutions.
the class CzechIdMIcConnectorService 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);
String key = connectorInstance.getConnectorKey().toString();
LOG.debug("Update object - CzechIdM (Uid= {} {} {})", uid, key, replaceAttributes.toString());
if (objectClass == null) {
objectClass = new IcObjectClassImpl(IcObjectClassInfo.ACCOUNT);
}
IcConnector connector = this.getConnectorInstance(connectorInstance, connectorConfiguration);
if (!(connector instanceof IcCanUpdate)) {
throw new IcException(MessageFormat.format("Connector [{0}] not supports update operation!", key));
}
IcUidAttribute updatedUid = ((IcCanUpdate) connector).update(uid, objectClass, replaceAttributes);
LOG.debug("Updated object - CzechIdM ({} {}) Uid= {})", connectorInstance.getConnectorKey().toString(), replaceAttributes.toString(), updatedUid);
return updatedUid;
}
use of eu.bcvsolutions.idm.ic.api.IcUidAttribute in project CzechIdMng by bcvsolutions.
the class VsRequestRealizationProcessor method process.
@Override
public EventResult<VsRequestDto> process(EntityEvent<VsRequestDto> event) {
VsRequestDto dto = event.getContent();
//
dto = service.createRequest(dto);
IcUidAttribute uid = service.internalStart(dto);
event.getProperties().put(VsRequestRealizationProcessor.RESULT_UID, uid);
event.setContent(dto);
//
return new DefaultEventResult<>(event, this);
}
Aggregations