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;
}
}
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;
}
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;
}
};
}
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;
}
};
}
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);
}
Aggregations