Search in sources :

Example 6 with IcConnector

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

the class CzechIdMIcConfigurationService method getAvailableLocalConnectors.

/**
 * Return available local connectors for this IC implementation
 *
 * @return
 */
@SuppressWarnings("unchecked")
@Override
public Set<IcConnectorInfo> getAvailableLocalConnectors() {
    if (connectorInfos == null) {
        connectorInfos = new HashSet<>();
        connectorsConfigurations = new HashMap<>();
        connectorsClass = new HashMap<>();
        List<Class<?>> annotated = new ArrayList<>();
        // Find all class with annotation IcConnectorClass under specific
        // packages
        localConnectorsPackages.forEach(packageWithConnectors -> {
            Reflections reflections = new Reflections(packageWithConnectors);
            annotated.addAll(reflections.getTypesAnnotatedWith(IcConnectorClass.class));
        });
        LOG.info(MessageFormat.format("Found annotated classes with IcConnectorClass [{0}]", annotated));
        for (Class<?> clazz : annotated) {
            IcConnectorClass connectorAnnotation = clazz.getAnnotation(IcConnectorClass.class);
            if (!this.getFramework().equals(connectorAnnotation.framework())) {
                continue;
            }
            if (!IcConnector.class.isAssignableFrom(clazz)) {
                throw new IcException(MessageFormat.format("Cannot create instance of CzechIdM connector [{0}]! Connector class must be child of [{0}]!", IcConnector.class.getSimpleName()));
            }
            IcConnectorInfo info = CzechIdMIcConvertUtil.convertConnectorClass(connectorAnnotation, (Class<? extends IcConnector>) clazz);
            Class<? extends ConfigurationClass> configurationClass = connectorAnnotation.configurationClass();
            connectorInfos.add(info);
            IcConnectorConfiguration configuration = initDefaultConfiguration(configurationClass);
            // Put default configuration to cache
            connectorsConfigurations.put(info.getConnectorKey().getFullName(), configuration);
            // Put connector class to cache
            connectorsClass.put(info.getConnectorKey().getFullName(), ((Class<? extends IcConnector>) clazz));
        }
        LOG.info(MessageFormat.format("Found all local connector connectorInfos [{0}]", connectorInfos.toString()));
    }
    return connectorInfos;
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) ArrayList(java.util.ArrayList) IcException(eu.bcvsolutions.idm.ic.exception.IcException) IcConnectorInfo(eu.bcvsolutions.idm.ic.api.IcConnectorInfo) IcConnectorClass(eu.bcvsolutions.idm.ic.api.annotation.IcConnectorClass) ConfigurationClass(eu.bcvsolutions.idm.core.api.domain.ConfigurationClass) IcConnectorClass(eu.bcvsolutions.idm.ic.api.annotation.IcConnectorClass) IcConnector(eu.bcvsolutions.idm.ic.api.IcConnector) Reflections(org.reflections.Reflections)

Example 7 with IcConnector

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

the class CzechIdMIcConfigurationService method getSchema.

@Override
public IcSchema getSchema(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration) {
    Assert.notNull(connectorInstance);
    Assert.notNull(connectorInstance.getConnectorKey());
    Assert.notNull(connectorConfiguration);
    String key = connectorInstance.getConnectorKey().toString();
    LOG.debug("Generate schema - CzechIdM {}", key);
    IcConnector connector = createConnectorInstance(connectorInstance);
    if (!(connector instanceof IcCanGenSchema)) {
        throw new IcException(MessageFormat.format("Connector [{0}] not supports generate schema operation!", key));
    }
    connector.init(connectorConfiguration);
    IcSchema schema = ((IcCanGenSchema) connector).schema();
    LOG.debug("Generated schema - CzechIdM ({}) schema = {}", key, schema);
    return schema;
}
Also used : IcCanGenSchema(eu.bcvsolutions.idm.ic.api.operation.IcCanGenSchema) IcConnector(eu.bcvsolutions.idm.ic.api.IcConnector) IcException(eu.bcvsolutions.idm.ic.exception.IcException) IcSchema(eu.bcvsolutions.idm.ic.api.IcSchema)

Example 8 with IcConnector

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

the class CzechIdMIcConnectorService method search.

@Override
public void search(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration, IcObjectClass objectClass, IcFilter filter, IcResultsHandler handler) {
    Assert.notNull(connectorInstance);
    Assert.notNull(connectorInstance.getConnectorKey());
    Assert.notNull(connectorConfiguration);
    Assert.notNull(objectClass);
    Assert.notNull(handler);
    String key = connectorInstance.getConnectorKey().toString();
    LOG.debug("Start search for connector {} and objectClass {} and filter {} - CzechIdM", key, objectClass.getDisplayName(), filter);
    IcConnector connector = this.getConnectorInstance(connectorInstance, connectorConfiguration);
    if (!(connector instanceof IcCanSearch)) {
        throw new IcException(MessageFormat.format("Connector [{0}] not supports search operation!", key));
    }
    ((IcCanSearch) connector).search(objectClass, filter, handler);
}
Also used : IcConnector(eu.bcvsolutions.idm.ic.api.IcConnector) IcException(eu.bcvsolutions.idm.ic.exception.IcException) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IcCanSearch(eu.bcvsolutions.idm.ic.api.operation.IcCanSearch)

Example 9 with IcConnector

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

the class CzechIdMIcConnectorService method readObject.

@Override
public IcConnectorObject readObject(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration, IcObjectClass objectClass, IcUidAttribute uid) {
    Assert.notNull(connectorInstance);
    Assert.notNull(connectorInstance.getConnectorKey());
    Assert.notNull(connectorConfiguration);
    Assert.notNull(uid);
    String key = connectorInstance.getConnectorKey().toString();
    LOG.debug("Read object - CzechIdM (Uid= {} {})", uid, key);
    if (objectClass == null) {
        objectClass = new IcObjectClassImpl(IcObjectClassInfo.ACCOUNT);
    }
    IcConnector connector = this.getConnectorInstance(connectorInstance, connectorConfiguration);
    if (!(connector instanceof IcCanRead)) {
        throw new IcException(MessageFormat.format("Connector [{0}] not supports read operation!", key));
    }
    IcConnectorObject object = ((IcCanRead) connector).read(uid, objectClass);
    LOG.debug("Readed object - CzechIdM ({}) Uid= {}", object, uid);
    return object;
}
Also used : IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcCanRead(eu.bcvsolutions.idm.ic.api.operation.IcCanRead) IcConnector(eu.bcvsolutions.idm.ic.api.IcConnector) IcException(eu.bcvsolutions.idm.ic.exception.IcException) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString)

Example 10 with IcConnector

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

the class CzechIdMIcConnectorService 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);
    String key = connectorInstance.getConnectorKey().toString();
    LOG.debug("Create object - CzechIdM ({} {})", key, attributes.toString());
    if (objectClass == null) {
        objectClass = new IcObjectClassImpl(IcObjectClassInfo.ACCOUNT);
    }
    IcConnector connector = this.getConnectorInstance(connectorInstance, connectorConfiguration);
    if (!(connector instanceof IcCanCreate)) {
        throw new IcException(MessageFormat.format("Connector [{0}] not supports create operation!", key));
    }
    IcUidAttribute uid = ((IcCanCreate) connector).create(objectClass, attributes);
    LOG.debug("Created object - CzechIdM ({} {}) Uid= {}", key, attributes.toString(), uid);
    return null;
}
Also used : IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) IcCanCreate(eu.bcvsolutions.idm.ic.api.operation.IcCanCreate) IcConnector(eu.bcvsolutions.idm.ic.api.IcConnector) IcException(eu.bcvsolutions.idm.ic.exception.IcException) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute)

Aggregations

IcConnector (eu.bcvsolutions.idm.ic.api.IcConnector)11 IcException (eu.bcvsolutions.idm.ic.exception.IcException)9 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)5 IcObjectClassImpl (eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl)4 IcConnectorInfo (eu.bcvsolutions.idm.ic.api.IcConnectorInfo)2 IcUidAttribute (eu.bcvsolutions.idm.ic.api.IcUidAttribute)2 ConfigurationClass (eu.bcvsolutions.idm.core.api.domain.ConfigurationClass)1 CoreException (eu.bcvsolutions.idm.core.api.exception.CoreException)1 IcConnectorConfiguration (eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration)1 IcConnectorInstance (eu.bcvsolutions.idm.ic.api.IcConnectorInstance)1 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)1 IcSchema (eu.bcvsolutions.idm.ic.api.IcSchema)1 IcConnectorClass (eu.bcvsolutions.idm.ic.api.annotation.IcConnectorClass)1 IcCanCreate (eu.bcvsolutions.idm.ic.api.operation.IcCanCreate)1 IcCanDelete (eu.bcvsolutions.idm.ic.api.operation.IcCanDelete)1 IcCanGenSchema (eu.bcvsolutions.idm.ic.api.operation.IcCanGenSchema)1 IcCanRead (eu.bcvsolutions.idm.ic.api.operation.IcCanRead)1 IcCanSearch (eu.bcvsolutions.idm.ic.api.operation.IcCanSearch)1 IcCanUpdate (eu.bcvsolutions.idm.ic.api.operation.IcCanUpdate)1 IcConnectorInstanceImpl (eu.bcvsolutions.idm.ic.impl.IcConnectorInstanceImpl)1