Search in sources :

Example 16 with ObjectClass

use of org.identityconnectors.framework.common.objects.ObjectClass in project CzechIdMng by bcvsolutions.

the class ConnIdIcConnectorService method updateObject.

@Override
public IcUidAttribute updateObject(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration, IcObjectClass objectClass, IcUidAttribute uid, List<IcAttribute> replaceAttributes) {
    Assert.notNull(connectorInstance);
    Assert.notNull(connectorInstance.getConnectorKey());
    Assert.notNull(connectorConfiguration);
    Assert.notNull(replaceAttributes);
    Assert.notNull(uid);
    LOG.debug("Update object - ConnId (Uid= {} {} {})", uid, connectorInstance.getConnectorKey().toString(), replaceAttributes.toString());
    ConnectorFacade conn = getConnectorFacade(connectorInstance, connectorConfiguration);
    Set<Attribute> connIdAttributes = new HashSet<>();
    for (IcAttribute icAttribute : replaceAttributes) {
        connIdAttributes.add(ConnIdIcConvertUtil.convertIcAttribute(icAttribute));
    }
    ObjectClass objectClassConnId = ConnIdIcConvertUtil.convertIcObjectClass(objectClass);
    if (objectClassConnId == null) {
        objectClassConnId = ObjectClass.ACCOUNT;
    }
    Uid updatedUid = conn.update(objectClassConnId, ConnIdIcConvertUtil.convertIcUid(uid), connIdAttributes, null);
    LOG.debug("Updated object - ConnId ({} {}) Uid= {})", connectorInstance.getConnectorKey().toString(), replaceAttributes.toString(), updatedUid);
    return ConnIdIcConvertUtil.convertConnIdUid(updatedUid);
}
Also used : Uid(org.identityconnectors.framework.common.objects.Uid) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) ObjectClass(org.identityconnectors.framework.common.objects.ObjectClass) Attribute(org.identityconnectors.framework.common.objects.Attribute) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) ConnectorFacade(org.identityconnectors.framework.api.ConnectorFacade) HashSet(java.util.HashSet)

Example 17 with ObjectClass

use of org.identityconnectors.framework.common.objects.ObjectClass in project CzechIdMng by bcvsolutions.

the class ConnIdIcConnectorService method authenticateObject.

@Override
public IcUidAttribute authenticateObject(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration, IcObjectClass objectClass, String username, GuardedString password) {
    Assert.notNull(connectorInstance);
    Assert.notNull(connectorInstance.getConnectorKey());
    Assert.notNull(connectorConfiguration);
    Assert.notNull(username);
    LOG.debug("Authenticate object - ConnId (username= {} {})", username, connectorInstance.getConnectorKey().toString());
    ConnectorFacade conn = getConnectorFacade(connectorInstance, connectorConfiguration);
    ObjectClass objectClassConnId = ConnIdIcConvertUtil.convertIcObjectClass(objectClass);
    if (objectClassConnId == null) {
        objectClassConnId = ObjectClass.ACCOUNT;
    }
    try {
        IcUidAttribute uid = ConnIdIcConvertUtil.convertConnIdUid(conn.authenticate(objectClassConnId, username, new org.identityconnectors.common.security.GuardedString(password.asString().toCharArray()), null));
        LOG.debug("Authenticated object - ConnId (Uid= {})", uid);
        return uid;
    } catch (InvalidCredentialException ex) {
        throw new ResultCodeException(IcResultCode.AUTH_FAILED, ex);
    }
}
Also used : IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) ObjectClass(org.identityconnectors.framework.common.objects.ObjectClass) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) ConnectorFacade(org.identityconnectors.framework.api.ConnectorFacade) InvalidCredentialException(org.identityconnectors.framework.common.exceptions.InvalidCredentialException) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString)

Example 18 with ObjectClass

use of org.identityconnectors.framework.common.objects.ObjectClass in project CzechIdMng by bcvsolutions.

the class ConnIdIcConnectorService 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);
    LOG.debug("Start search for connector {} and objectClass {} and filter {} - ConnId", connectorInstance.getConnectorKey().toString(), objectClass.getDisplayName(), filter);
    ConnectorFacade conn = getConnectorFacade(connectorInstance, connectorConfiguration);
    ObjectClass objectClassConnId = ConnIdIcConvertUtil.convertIcObjectClass(objectClass);
    if (objectClassConnId == null) {
        objectClassConnId = ObjectClass.ACCOUNT;
    }
    final SearchResultsHandler handlerConnId = new SearchResultsHandler() {

        @Override
        public boolean handle(ConnectorObject connectorObject) {
            return handler.handle(ConnIdIcConvertUtil.convertConnIdConnectorObject(connectorObject));
        }

        @Override
        public void handleResult(SearchResult result) {
            // VS TODO: For all my tests was search result Null and this method (handle result) was not called!
            LOG.debug("SearchResul was returned (pagination): cookie: {}  --- remaining paged results: {}", result.getPagedResultsCookie(), result.getRemainingPagedResults());
        }
    };
    Filter filterConnId = ConnIdIcConvertUtil.convertIcFilter(filter);
    // For pagination - TODO
    Map<String, Object> searchOpt = new HashMap<String, Object>();
    searchOpt.put(OperationOptions.OP_PAGE_SIZE, 100);
    searchOpt.put(OperationOptions.OP_PAGED_RESULTS_OFFSET, 1);
    OperationOptions searchOptions = new OperationOptions(searchOpt);
    this.pageSearch(conn, objectClassConnId, filterConnId, handlerConnId, searchOptions);
}
Also used : OperationOptions(org.identityconnectors.framework.common.objects.OperationOptions) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) ObjectClass(org.identityconnectors.framework.common.objects.ObjectClass) Filter(org.identityconnectors.framework.common.objects.filter.Filter) IcFilter(eu.bcvsolutions.idm.ic.filter.api.IcFilter) HashMap(java.util.HashMap) ConnectorObject(org.identityconnectors.framework.common.objects.ConnectorObject) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) ConnectorFacade(org.identityconnectors.framework.api.ConnectorFacade) SearchResult(org.identityconnectors.framework.common.objects.SearchResult) ConnectorObject(org.identityconnectors.framework.common.objects.ConnectorObject) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SearchResultsHandler(org.identityconnectors.framework.spi.SearchResultsHandler)

Example 19 with ObjectClass

use of org.identityconnectors.framework.common.objects.ObjectClass in project CzechIdMng by bcvsolutions.

the class ConnIdIcConnectorService method deleteObject.

@Override
public void deleteObject(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration, IcObjectClass objectClass, IcUidAttribute uid) {
    Assert.notNull(connectorInstance);
    Assert.notNull(connectorInstance.getConnectorKey());
    Assert.notNull(connectorConfiguration);
    Assert.notNull(uid);
    LOG.debug("Delete object - ConnId (Uid= {} {})", uid, connectorInstance.getConnectorKey().toString());
    ConnectorFacade conn = getConnectorFacade(connectorInstance, connectorConfiguration);
    ObjectClass objectClassConnId = ConnIdIcConvertUtil.convertIcObjectClass(objectClass);
    if (objectClassConnId == null) {
        objectClassConnId = ObjectClass.ACCOUNT;
    }
    conn.delete(objectClassConnId, ConnIdIcConvertUtil.convertIcUid(uid), null);
    LOG.debug("Deleted object - ConnId ({}) Uid= {}", connectorInstance.getConnectorKey().toString(), uid);
}
Also used : IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) ObjectClass(org.identityconnectors.framework.common.objects.ObjectClass) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) ConnectorFacade(org.identityconnectors.framework.api.ConnectorFacade)

Aggregations

ObjectClass (org.identityconnectors.framework.common.objects.ObjectClass)19 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)10 GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)9 AsynchronousOperationResult (com.evolveum.midpoint.schema.result.AsynchronousOperationResult)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)8 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)8 ConnectorFacade (org.identityconnectors.framework.api.ConnectorFacade)8 Uid (org.identityconnectors.framework.common.objects.Uid)8 SystemException (com.evolveum.midpoint.util.exception.SystemException)7 IcObjectClass (eu.bcvsolutions.idm.ic.api.IcObjectClass)7 IcConnectorFacade (eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade)7 QName (javax.xml.namespace.QName)7 GuardedString (org.identityconnectors.common.security.GuardedString)7 ConnectorObject (org.identityconnectors.framework.common.objects.ConnectorObject)7 OperationOptions (org.identityconnectors.framework.common.objects.OperationOptions)7 OperationOptionsBuilder (org.identityconnectors.framework.common.objects.OperationOptionsBuilder)7 Attribute (org.identityconnectors.framework.common.objects.Attribute)5 QualifiedUid (org.identityconnectors.framework.common.objects.QualifiedUid)5 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)4 SyncResultsHandler (org.identityconnectors.framework.common.objects.SyncResultsHandler)4