Search in sources :

Example 1 with RemoteFrameworkConnectionInfo

use of org.identityconnectors.framework.api.RemoteFrameworkConnectionInfo in project CzechIdMng by bcvsolutions.

the class ConnIdIcConfigurationService method findRemoteConnectorManager.

private ConnectorInfoManager findRemoteConnectorManager(IcConnectorServer server) {
    // get all saved remote connector servers
    ConnectorInfoManager manager = null;
    try {
        GuardedString pass = server.getPassword();
        if (pass == null) {
            throw new InvalidCredentialException();
        }
        RemoteFrameworkConnectionInfo info = new RemoteFrameworkConnectionInfo(server.getHost(), server.getPort(), new org.identityconnectors.common.security.GuardedString(pass.asString().toCharArray()), server.isUseSsl(), null, server.getTimeout());
        // flush remote cache
        ConnectorInfoManagerFactory instance = ConnectorInfoManagerFactory.getInstance();
        instance.clearRemoteCache();
        manager = instance.getRemoteManager(info);
    } catch (InvalidCredentialException e) {
        throw new IcInvalidCredentialException(server.getHost(), server.getPort(), e);
    } catch (ConnectorIOException e) {
        throw new IcServerNotFoundException(server.getHost(), server.getPort(), e);
    } catch (ConnectorException e) {
        throw new IcCantConnectException(server.getHost(), server.getPort(), e);
    } catch (Exception e) {
        throw new IcRemoteServerException(server.getHost(), server.getPort(), e);
    }
    return manager;
}
Also used : ConnectorIOException(org.identityconnectors.framework.common.exceptions.ConnectorIOException) IcServerNotFoundException(eu.bcvsolutions.idm.ic.exception.IcServerNotFoundException) IcInvalidCredentialException(eu.bcvsolutions.idm.ic.exception.IcInvalidCredentialException) IcInvalidCredentialException(eu.bcvsolutions.idm.ic.exception.IcInvalidCredentialException) InvalidCredentialException(org.identityconnectors.framework.common.exceptions.InvalidCredentialException) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IcRemoteServerException(eu.bcvsolutions.idm.ic.exception.IcRemoteServerException) ConnectorException(org.identityconnectors.framework.common.exceptions.ConnectorException) IcInvalidCredentialException(eu.bcvsolutions.idm.ic.exception.IcInvalidCredentialException) InvalidCredentialException(org.identityconnectors.framework.common.exceptions.InvalidCredentialException) IcCantConnectException(eu.bcvsolutions.idm.ic.exception.IcCantConnectException) IcServerNotFoundException(eu.bcvsolutions.idm.ic.exception.IcServerNotFoundException) CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) ConnectorIOException(org.identityconnectors.framework.common.exceptions.ConnectorIOException) ConnectorInfoManagerFactory(org.identityconnectors.framework.api.ConnectorInfoManagerFactory) ConnectorInfoManager(org.identityconnectors.framework.api.ConnectorInfoManager) IcCantConnectException(eu.bcvsolutions.idm.ic.exception.IcCantConnectException) ConnectorException(org.identityconnectors.framework.common.exceptions.ConnectorException) IcRemoteServerException(eu.bcvsolutions.idm.ic.exception.IcRemoteServerException) RemoteFrameworkConnectionInfo(org.identityconnectors.framework.api.RemoteFrameworkConnectionInfo)

Example 2 with RemoteFrameworkConnectionInfo

use of org.identityconnectors.framework.api.RemoteFrameworkConnectionInfo in project syncope by apache.

the class ConnIdBundleManagerImpl method initRemote.

private void initRemote(final URI location) {
    // 1. Extract conf params for remote connection from given URI
    String host = location.getHost();
    int port = location.getPort();
    GuardedString key = new GuardedString(location.getUserInfo().toCharArray());
    boolean useSSL = location.getScheme().equals("connids");
    List<TrustManager> trustManagers = new ArrayList<>();
    String[] params = StringUtils.isBlank(location.getQuery()) ? null : location.getQuery().split("&");
    if (params != null && params.length > 0) {
        final String[] trustAllCerts = params[0].split("=");
        if (trustAllCerts != null && trustAllCerts.length > 1 && "trustAllCerts".equalsIgnoreCase(trustAllCerts[0]) && "true".equalsIgnoreCase(trustAllCerts[1])) {
            trustManagers.add(new X509TrustManager() {

                @Override
                public void checkClientTrusted(final X509Certificate[] chain, final String authType) throws CertificateException {
                // no checks, trust all
                }

                @Override
                public void checkServerTrusted(final X509Certificate[] chain, final String authType) throws CertificateException {
                // no checks, trust all
                }

                @Override
                public X509Certificate[] getAcceptedIssuers() {
                    return null;
                }
            });
        }
    }
    LOG.debug("Configuring remote connector server:" + "\n\tHost: {}" + "\n\tPort: {}" + "\n\tKey: {}" + "\n\tUseSSL: {}" + "\n\tTrustAllCerts: {}", host, port, key, useSSL, !trustManagers.isEmpty());
    RemoteFrameworkConnectionInfo info = new RemoteFrameworkConnectionInfo(host, port, key, useSSL, trustManagers, 60 * 1000);
    LOG.debug("Remote connection info: {}", info);
    // 2. Get connector info manager
    ConnectorInfoManager manager = ConnectorInfoManagerFactory.getInstance().getRemoteManager(info);
    if (manager == null) {
        throw new NotFoundException("Remote ConnectorInfoManager");
    }
    connInfoManagers.put(location, manager);
}
Also used : ArrayList(java.util.ArrayList) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) CertificateException(java.security.cert.CertificateException) GuardedString(org.identityconnectors.common.security.GuardedString) GuardedString(org.identityconnectors.common.security.GuardedString) X509Certificate(java.security.cert.X509Certificate) TrustManager(javax.net.ssl.TrustManager) X509TrustManager(javax.net.ssl.X509TrustManager) ConnectorInfoManager(org.identityconnectors.framework.api.ConnectorInfoManager) X509TrustManager(javax.net.ssl.X509TrustManager) RemoteFrameworkConnectionInfo(org.identityconnectors.framework.api.RemoteFrameworkConnectionInfo)

Aggregations

ConnectorInfoManager (org.identityconnectors.framework.api.ConnectorInfoManager)2 RemoteFrameworkConnectionInfo (org.identityconnectors.framework.api.RemoteFrameworkConnectionInfo)2 CoreException (eu.bcvsolutions.idm.core.api.exception.CoreException)1 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)1 IcCantConnectException (eu.bcvsolutions.idm.ic.exception.IcCantConnectException)1 IcInvalidCredentialException (eu.bcvsolutions.idm.ic.exception.IcInvalidCredentialException)1 IcRemoteServerException (eu.bcvsolutions.idm.ic.exception.IcRemoteServerException)1 IcServerNotFoundException (eu.bcvsolutions.idm.ic.exception.IcServerNotFoundException)1 CertificateException (java.security.cert.CertificateException)1 X509Certificate (java.security.cert.X509Certificate)1 ArrayList (java.util.ArrayList)1 TrustManager (javax.net.ssl.TrustManager)1 X509TrustManager (javax.net.ssl.X509TrustManager)1 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)1 GuardedString (org.identityconnectors.common.security.GuardedString)1 ConnectorInfoManagerFactory (org.identityconnectors.framework.api.ConnectorInfoManagerFactory)1 ConnectorException (org.identityconnectors.framework.common.exceptions.ConnectorException)1 ConnectorIOException (org.identityconnectors.framework.common.exceptions.ConnectorIOException)1 InvalidCredentialException (org.identityconnectors.framework.common.exceptions.InvalidCredentialException)1