Search in sources :

Example 36 with IcAttribute

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

the class BasicVirtualConnector method read.

@Override
public IcConnectorObject read(IcUidAttribute uid, IcObjectClass objectClass) {
    Assert.notNull(objectClass, "Object class cannot be null!");
    Assert.notNull(uid, "UID cannot be null!");
    if (!IcObjectClassInfo.ACCOUNT.equals(objectClass.getType())) {
        throw new IcException("Only ACCOUNT object class is supported now!");
    }
    String uidValue = uid.getUidValue();
    if (uidValue == null) {
        throw new IcException("UID value cannot be null!");
    }
    // Find account by UID and System ID
    VsAccountDto account = accountService.findByUidSystem(uidValue, systemId);
    // All attributes from VS account
    List<IcAttribute> vsAttributes = new ArrayList<>();
    // Create uid attribute
    IcAttributeImpl uidAttribute = new IcAttributeImpl(IcAttributeInfo.NAME, uidValue);
    vsAttributes.add(uidAttribute);
    if (account != null) {
        // Create enable attribute
        if (this.virtualConfiguration.isDisableSupported()) {
            IcAttributeImpl enableAttribute = new IcAttributeImpl(IcAttributeInfo.ENABLE, account.isEnable());
            vsAttributes.add(enableAttribute);
        }
        // Attributes from definition and configuration
        UUID accountId = account.getId();
        Arrays.asList(virtualConfiguration.getAttributes()).forEach(virtualAttirbute -> {
            IcAttribute attribute = accountService.getIcAttribute(accountId, virtualAttirbute, formDefinition);
            if (attribute == null) {
                return;
            }
            vsAttributes.add(attribute);
        });
    }
    // Overwrite attributes form VS account with attributes from unresloved
    // requests
    List<IcAttribute> attributes = this.overwriteAttributesByUnresolvedRequests(account, uidValue, vsAttributes);
    if (attributes == null) {
        return null;
    }
    IcConnectorObjectImpl connectorObject = new IcConnectorObjectImpl();
    connectorObject.setUidValue(uidValue);
    connectorObject.setObjectClass(new IcObjectClassImpl(IcObjectClassInfo.ACCOUNT));
    connectorObject.setAttributes(attributes);
    return connectorObject;
}
Also used : IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) IcAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcAttributeImpl) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) VsAccountDto(eu.bcvsolutions.idm.vs.dto.VsAccountDto) ArrayList(java.util.ArrayList) IcException(eu.bcvsolutions.idm.ic.exception.IcException) UUID(java.util.UUID) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl)

Aggregations

IcAttribute (eu.bcvsolutions.idm.ic.api.IcAttribute)36 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)19 ArrayList (java.util.ArrayList)15 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)13 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)13 UUID (java.util.UUID)12 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)11 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)11 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)10 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)10 IcObjectClass (eu.bcvsolutions.idm.ic.api.IcObjectClass)10 IcConnectorFacade (eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade)10 List (java.util.List)10 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)9 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)9 SysSyncActionLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto)9 SysSyncItemLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto)9 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)9 ImmutableMap (com.google.common.collect.ImmutableMap)8 AccResultCode (eu.bcvsolutions.idm.acc.domain.AccResultCode)8