Search in sources :

Example 6 with IConnectContext

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

the class GenericClientApplication method createContainer.

protected ISharedObjectContainer createContainer() throws ContainerCreateException {
    IContainerFactory f = Activator.getDefault().getContainerManager().getContainerFactory();
    ClientSOContainer client = (ClientSOContainer) ((clientId == null) ? f.createContainer(GENERIC_CLIENT_CONTAINER_TYPE) : f.createContainer(GENERIC_CLIENT_CONTAINER_TYPE, clientId));
    if (password != null) {
        client.setConnectInitiatorPolicy(new IConnectInitiatorPolicy() {

            public void refresh() {
            // nothing
            }

            public Object createConnectData(IContainer container, ID targetID, IConnectContext context) {
                return password;
            }

            public int getConnectTimeout() {
                return 30000;
            }
        });
    }
    return client;
}
Also used : IConnectContext(org.eclipse.ecf.core.security.IConnectContext) ClientSOContainer(org.eclipse.ecf.provider.generic.ClientSOContainer) IConnectInitiatorPolicy(org.eclipse.ecf.core.security.IConnectInitiatorPolicy) ID(org.eclipse.ecf.core.identity.ID)

Example 7 with IConnectContext

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

the class SSLGenericClientApplication method createContainer.

protected ISharedObjectContainer createContainer() throws ContainerCreateException {
    IContainerFactory f = Activator.getDefault().getContainerManager().getContainerFactory();
    ClientSOContainer client = (ClientSOContainer) ((clientId == null) ? f.createContainer(GENERIC_SSL_CLIENT) : f.createContainer(GENERIC_SSL_CLIENT, clientId));
    if (password != null) {
        client.setConnectInitiatorPolicy(new IConnectInitiatorPolicy() {

            public void refresh() {
            // nothing
            }

            public Object createConnectData(IContainer container, ID targetID, IConnectContext context) {
                return password;
            }

            public int getConnectTimeout() {
                return 30000;
            }
        });
    }
    return client;
}
Also used : IConnectContext(org.eclipse.ecf.core.security.IConnectContext) ClientSOContainer(org.eclipse.ecf.provider.generic.ClientSOContainer) IConnectInitiatorPolicy(org.eclipse.ecf.core.security.IConnectInitiatorPolicy) ID(org.eclipse.ecf.core.identity.ID)

Example 8 with IConnectContext

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

the class ChatRoomBot 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
            // $NON-NLS-1$
            throw new ContainerConnectException("Already connected");
        targetID = IDFactory.getDefault().createID(namespace, bot.getConnectID());
        IChatRoomManager manager = (IChatRoomManager) container.getAdapter(IChatRoomManager.class);
        if (manager == null)
            // $NON-NLS-1$
            throw new ECFException("No chat room manager available");
        firePreConnect();
        String password = bot.getPassword();
        IConnectContext context = (password == null) ? null : ConnectContextFactory.createPasswordConnectContext(password);
        container.connect(targetID, context);
        String[] roomNames = bot.getChatRooms();
        String[] roomPasswords = bot.getChatRoomPasswords();
        for (int i = 0; i < roomNames.length; i++) {
            IChatRoomInfo room = manager.getChatRoomInfo(roomNames[i]);
            roomContainer = room.createChatRoomContainer();
            roomID = room.getRoomID();
            firePreRoomConnect();
            roomContainer.addMessageListener(this);
            IConnectContext roomContext = (roomPasswords[i] == null) ? null : ConnectContextFactory.createPasswordConnectContext(roomPasswords[i]);
            roomContainer.connect(roomID, roomContext);
        }
    } catch (ECFException e) {
        if (container != null) {
            if (container.getConnectedID() != null) {
                container.disconnect();
            }
            container.dispose();
        }
        container = null;
        throw e;
    }
}
Also used : IChatRoomInfo(org.eclipse.ecf.presence.chatroom.IChatRoomInfo) IConnectContext(org.eclipse.ecf.core.security.IConnectContext) ContainerConnectException(org.eclipse.ecf.core.ContainerConnectException) ECFException(org.eclipse.ecf.core.util.ECFException) IChatRoomManager(org.eclipse.ecf.presence.chatroom.IChatRoomManager) Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 9 with IConnectContext

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

the class XMPPSContainer method createConnection.

protected ISynchAsynchConnection createConnection(ID remoteSpace, Object data) throws ConnectionCreateException {
    boolean google = isGoogle(remoteSpace);
    CallbackHandler ch = data instanceof IConnectContext ? ((IConnectContext) data).getCallbackHandler() : null;
    return new ECFConnection(google, getConnectNamespace(), receiver, ch);
}
Also used : IConnectContext(org.eclipse.ecf.core.security.IConnectContext) CallbackHandler(org.eclipse.ecf.core.security.CallbackHandler) ECFConnection(org.eclipse.ecf.internal.provider.xmpp.smack.ECFConnection)

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