Search in sources :

Example 1 with IcPasswordAttributeImpl

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;
}
Also used : IcPasswordAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcPasswordAttributeImpl) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcPasswordAttribute(eu.bcvsolutions.idm.ic.api.IcPasswordAttribute) 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) UUID(java.util.UUID) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 2 with IcPasswordAttributeImpl

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;
}
Also used : ArrayList(java.util.ArrayList) SysProvisioningOperation(eu.bcvsolutions.idm.acc.entity.SysProvisioningOperation) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) IcPasswordAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcPasswordAttributeImpl) IcAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcAttributeImpl) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) List(java.util.List) ArrayList(java.util.ArrayList) IcPasswordAttribute(eu.bcvsolutions.idm.ic.api.IcPasswordAttribute) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl)

Aggregations

GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)2 IcAttribute (eu.bcvsolutions.idm.ic.api.IcAttribute)2 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)2 IcPasswordAttribute (eu.bcvsolutions.idm.ic.api.IcPasswordAttribute)2 IcPasswordAttributeImpl (eu.bcvsolutions.idm.ic.impl.IcPasswordAttributeImpl)2 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)1 SysProvisioningOperation (eu.bcvsolutions.idm.acc.entity.SysProvisioningOperation)1 ConfidentialString (eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString)1 IcUidAttribute (eu.bcvsolutions.idm.ic.api.IcUidAttribute)1 IcAttributeImpl (eu.bcvsolutions.idm.ic.impl.IcAttributeImpl)1 IcConnectorObjectImpl (eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 UUID (java.util.UUID)1