use of eu.bcvsolutions.idm.ic.impl.IcPasswordAttributeImpl 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.impl.IcPasswordAttributeImpl in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningOperationService method getFullConnectorObject.
/**
* Returns fully loaded ConnectorObject with guarded strings.
*
* TODO: don't update connectorObject in provisioningOperation (needs attribute defensive clone)
*
* @param provisioningOperation
* @return
*/
@Override
public IcConnectorObject getFullConnectorObject(SysProvisioningOperationDto provisioningOperation) {
if (provisioningOperation == null || provisioningOperation.getProvisioningContext() == null || provisioningOperation.getProvisioningContext().getConnectorObject() == null) {
return null;
}
List<IcAttribute> attributes = new ArrayList<>();
//
IcConnectorObject connectorObject = provisioningOperation.getProvisioningContext().getConnectorObject();
connectorObject.getAttributes().forEach(attribute -> {
IcAttribute attributeCopy = null;
if (attribute.isMultiValue()) {
List<Object> values = (List<Object>) attribute.getValues();
attributeCopy = new IcAttributeImpl(attribute.getName(), values, true);
} else if (attribute instanceof IcPasswordAttribute && attribute.getValue() != null) {
attributeCopy = new IcPasswordAttributeImpl(attribute.getName(), confidentialStorage.getGuardedString(provisioningOperation.getId(), SysProvisioningOperation.class, ((ConfidentialString) attribute.getValue()).getKey()));
} else if (attribute instanceof IcPasswordAttribute && attribute.getValue() == null) {
attributeCopy = new IcPasswordAttributeImpl(attribute.getName(), (GuardedString) null);
} else {
attributeCopy = new IcAttributeImpl(attribute.getName(), attribute.getValue());
}
attributes.add(attributeCopy);
});
IcConnectorObject newConnectorObject = new IcConnectorObjectImpl(connectorObject.getUidValue(), connectorObject.getObjectClass(), attributes);
return newConnectorObject;
}
Aggregations