Search in sources :

Example 1 with IConnectContext

use of org.eclipse.ecf.core.security.IConnectContext in project ecf by eclipse.

the class IMBot method connect.

public synchronized void connect() throws ECFException {
    fireInitBot();
    try {
        Namespace namespace = null;
        if (container == null) {
            container = ContainerFactory.getDefault().createContainer(bot.getContainerFactoryName());
            namespace = container.getConnectNamespace();
        } else
            throw new ContainerConnectException("Already connected");
        targetID = IDFactory.getDefault().createID(namespace, bot.getConnectID());
        firePreConnect();
        IPresenceContainerAdapter presenceAdapter = (IPresenceContainerAdapter) container.getAdapter(IPresenceContainerAdapter.class);
        presenceAdapter.getChatManager().addMessageListener(this);
        String password = bot.getPassword();
        IConnectContext context = (password == null) ? null : ConnectContextFactory.createPasswordConnectContext(password);
        container.connect(targetID, context);
    } catch (ECFException e) {
        if (container != null) {
            if (container.getConnectedID() != null) {
                container.disconnect();
            }
            container.dispose();
        }
        container = null;
        throw e;
    }
}
Also used : IPresenceContainerAdapter(org.eclipse.ecf.presence.IPresenceContainerAdapter) IConnectContext(org.eclipse.ecf.core.security.IConnectContext) ContainerConnectException(org.eclipse.ecf.core.ContainerConnectException) ECFException(org.eclipse.ecf.core.util.ECFException) Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 2 with IConnectContext

use of org.eclipse.ecf.core.security.IConnectContext in project ecf by eclipse.

the class GenericAuthConsumerContainerSelector method createContainer.

@Override
protected IRemoteServiceContainer createContainer(ContainerTypeDescription containerTypeDescription, String containerTypeDescriptionName, @SuppressWarnings("rawtypes") Map properties) throws SelectContainerException {
    IRemoteServiceContainer result = super.createContainer(containerTypeDescription, containerTypeDescriptionName, properties);
    ISharedObjectContainerClient client = (ISharedObjectContainerClient) result.getContainer().getAdapter(ISharedObjectContainerClient.class);
    if (client != null) {
        client.setConnectInitiatorPolicy(new IConnectInitiatorPolicy() {

            public void refresh() {
            }

            public Object createConnectData(IContainer container, ID targetID, IConnectContext context) {
                // to the server.
                return getConnectData();
            }

            public int getConnectTimeout() {
                return 30000;
            }
        });
    }
    return result;
}
Also used : IRemoteServiceContainer(org.eclipse.ecf.remoteservice.IRemoteServiceContainer) IConnectContext(org.eclipse.ecf.core.security.IConnectContext) ISharedObjectContainerClient(org.eclipse.ecf.core.sharedobject.ISharedObjectContainerClient) IConnectInitiatorPolicy(org.eclipse.ecf.core.security.IConnectInitiatorPolicy) ID(org.eclipse.ecf.core.identity.ID) IContainer(org.eclipse.ecf.core.IContainer)

Example 3 with IConnectContext

use of org.eclipse.ecf.core.security.IConnectContext in project ecf by eclipse.

the class HttpClientBrowseFileTransferFactory method newInstance.

public IRemoteFileSystemBrowser newInstance() {
    return new IRemoteFileSystemBrowser() {

        private Proxy proxy;

        private IConnectContext connectContext;

        public Namespace getBrowseNamespace() {
            return IDFactory.getDefault().getNamespaceByName(FileTransferNamespace.PROTOCOL);
        }

        public IRemoteFileSystemRequest sendBrowseRequest(IFileID directoryOrFileId, IRemoteFileSystemListener listener) throws RemoteFileSystemException {
            Assert.isNotNull(directoryOrFileId);
            Assert.isNotNull(listener);
            URL url;
            try {
                url = directoryOrFileId.getURL();
            } catch (final MalformedURLException e) {
                // $NON-NLS-1$
                throw new RemoteFileSystemException(NLS.bind("Exception creating URL for {0}", directoryOrFileId));
            }
            HttpClientFileSystemBrowser browser = new HttpClientFileSystemBrowser(new SNIAwareHttpClient(), directoryOrFileId, listener, url, connectContext, proxy);
            return browser.sendBrowseRequest();
        }

        public void setConnectContextForAuthentication(IConnectContext connectContext) {
            this.connectContext = connectContext;
        }

        public void setProxy(Proxy proxy) {
            this.proxy = proxy;
        }

        public Object getAdapter(Class adapter) {
            return null;
        }
    };
}
Also used : IConnectContext(org.eclipse.ecf.core.security.IConnectContext) RemoteFileSystemException(org.eclipse.ecf.filetransfer.RemoteFileSystemException) IRemoteFileSystemBrowser(org.eclipse.ecf.filetransfer.service.IRemoteFileSystemBrowser) Proxy(org.eclipse.ecf.core.util.Proxy) MalformedURLException(java.net.MalformedURLException) IFileID(org.eclipse.ecf.filetransfer.identity.IFileID) IRemoteFileSystemListener(org.eclipse.ecf.filetransfer.IRemoteFileSystemListener) URL(java.net.URL)

Example 4 with IConnectContext

use of org.eclipse.ecf.core.security.IConnectContext in project ecf by eclipse.

the class ScpBrowseFileTransferFactory method newInstance.

public IRemoteFileSystemBrowser newInstance() {
    return new IRemoteFileSystemBrowser() {

        private Proxy proxy;

        private IConnectContext connectContext;

        public Namespace getBrowseNamespace() {
            return IDFactory.getDefault().getNamespaceByName(FileTransferNamespace.PROTOCOL);
        }

        public IRemoteFileSystemRequest sendBrowseRequest(IFileID directoryOrFileId, IRemoteFileSystemListener listener) throws RemoteFileSystemException {
            Assert.isNotNull(directoryOrFileId);
            Assert.isNotNull(listener);
            URL url;
            try {
                url = directoryOrFileId.getURL();
            } catch (final MalformedURLException e) {
                throw new RemoteFileSystemException(NLS.bind("Exception creating URL for {0}", // $NON-NLS-1$
                directoryOrFileId));
            }
            ScpFileSystemBrowser browser = new ScpFileSystemBrowser(directoryOrFileId, listener, url, connectContext, proxy);
            return browser.sendBrowseRequest();
        }

        public void setConnectContextForAuthentication(IConnectContext connectContext) {
            this.connectContext = connectContext;
        }

        public void setProxy(Proxy proxy) {
            this.proxy = proxy;
        }

        public Object getAdapter(Class adapter) {
            return null;
        }
    };
}
Also used : IConnectContext(org.eclipse.ecf.core.security.IConnectContext) IRemoteFileSystemBrowser(org.eclipse.ecf.filetransfer.service.IRemoteFileSystemBrowser) Proxy(org.eclipse.ecf.core.util.Proxy) MalformedURLException(java.net.MalformedURLException) IFileID(org.eclipse.ecf.filetransfer.identity.IFileID) URL(java.net.URL)

Example 5 with IConnectContext

use of org.eclipse.ecf.core.security.IConnectContext in project ecf by eclipse.

the class AbstractHostContainerSelector method connectHostContainer.

/**
 * @param serviceReference service reference
 * @param properties properties
 * @param container container
 * @param target target
 * @throws ContainerConnectException if container cannot be connected
 * @throws IDCreateException thrown if ID cannot be created
 * @since 2.0
 */
protected void connectHostContainer(ServiceReference serviceReference, Map<String, Object> properties, IContainer container, Object target) throws ContainerConnectException, IDCreateException {
    ID targetID = (target instanceof String) ? IDUtil.createID(container.getConnectNamespace(), (String) target) : IDUtil.createID(container.getConnectNamespace(), new Object[] { target });
    Object context = properties.get(RemoteConstants.SERVICE_EXPORTED_CONTAINER_CONNECT_CONTEXT);
    IConnectContext connectContext = null;
    if (context != null) {
        connectContext = createConnectContext(serviceReference, properties, container, context);
    }
    // connect the container
    container.connect(targetID, connectContext);
}
Also used : IConnectContext(org.eclipse.ecf.core.security.IConnectContext) ID(org.eclipse.ecf.core.identity.ID)

Aggregations

IConnectContext (org.eclipse.ecf.core.security.IConnectContext)9 ID (org.eclipse.ecf.core.identity.ID)4 IConnectInitiatorPolicy (org.eclipse.ecf.core.security.IConnectInitiatorPolicy)3 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)2 Namespace (org.eclipse.ecf.core.identity.Namespace)2 ECFException (org.eclipse.ecf.core.util.ECFException)2 Proxy (org.eclipse.ecf.core.util.Proxy)2 IFileID (org.eclipse.ecf.filetransfer.identity.IFileID)2 IRemoteFileSystemBrowser (org.eclipse.ecf.filetransfer.service.IRemoteFileSystemBrowser)2 ClientSOContainer (org.eclipse.ecf.provider.generic.ClientSOContainer)2 IContainer (org.eclipse.ecf.core.IContainer)1 CallbackHandler (org.eclipse.ecf.core.security.CallbackHandler)1 ISharedObjectContainerClient (org.eclipse.ecf.core.sharedobject.ISharedObjectContainerClient)1 IRemoteFileSystemListener (org.eclipse.ecf.filetransfer.IRemoteFileSystemListener)1 RemoteFileSystemException (org.eclipse.ecf.filetransfer.RemoteFileSystemException)1 ECFConnection (org.eclipse.ecf.internal.provider.xmpp.smack.ECFConnection)1 IPresenceContainerAdapter (org.eclipse.ecf.presence.IPresenceContainerAdapter)1 IChatRoomInfo (org.eclipse.ecf.presence.chatroom.IChatRoomInfo)1