Search in sources :

Example 1 with IcPasswordAttribute

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

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

Example 3 with IcPasswordAttribute

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

the class ProvisioningSendNotificationProcessor method process.

@Override
public EventResult<SysProvisioningOperationDto> process(EntityEvent<SysProvisioningOperationDto> event) {
    SysProvisioningOperationDto provisioningOperation = event.getContent();
    String uid = provisioningOperationService.getByProvisioningOperation(provisioningOperation).getUid();
    IdmIdentityDto identity = null;
    if (provisioningOperation.getEntityIdentifier() != null && SystemEntityType.IDENTITY == provisioningOperation.getEntityType()) {
        identity = identityService.get(provisioningOperation.getEntityIdentifier());
    }
    // TODO: identity or email null, send message to actual log user?
    if (identity != null && identity.getState() != IdentityState.CREATED) {
        for (IcAttribute attribute : provisioningOperationService.getFullConnectorObject(provisioningOperation).getAttributes()) {
            // TODO: send password always, when create?
            if (attribute instanceof IcPasswordAttribute && attribute.getValue() != null) {
                GuardedString password = ((IcPasswordAttribute) attribute).getPasswordValue();
                // 
                // send message with new password to identity, topic has connection to templates
                SysSystemDto system = systemService.get(provisioningOperation.getSystem());
                notificationManager.send(AccModuleDescriptor.TOPIC_NEW_PASSWORD, new IdmMessageDto.Builder().setLevel(NotificationLevel.SUCCESS).addParameter("systemName", system.getName()).addParameter("uid", uid).addParameter("password", password).build(), identity);
                break;
            }
        }
    }
    return new DefaultEventResult<>(event, this);
}
Also used : IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) 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) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Aggregations

GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)3 IcAttribute (eu.bcvsolutions.idm.ic.api.IcAttribute)3 IcPasswordAttribute (eu.bcvsolutions.idm.ic.api.IcPasswordAttribute)3 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)2 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)2 IcPasswordAttributeImpl (eu.bcvsolutions.idm.ic.impl.IcPasswordAttributeImpl)2 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)1 SysProvisioningOperation (eu.bcvsolutions.idm.acc.entity.SysProvisioningOperation)1 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)1 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)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