Search in sources :

Example 1 with ECFRuntimeException

use of org.eclipse.ecf.core.util.ECFRuntimeException in project ecf by eclipse.

the class HttpClientRetrieveFileTransfer method registerSchemes.

private synchronized void registerSchemes(ISocketEventSource source, ISocketListener socketListener) {
    SchemeRegistry schemeRegistry = this.httpClient.getConnectionManager().getSchemeRegistry();
    Scheme http = new Scheme(HttpClientRetrieveFileTransfer.HTTP, HTTP_PORT, new ECFHttpClientProtocolSocketFactory(SocketFactory.getDefault(), source, socketListener));
    // $NON-NLS-1$
    Trace.trace(Activator.PLUGIN_ID, "registering http scheme");
    schemeRegistry.register(http);
    ISSLSocketFactoryModifier sslSocketFactoryModifier = Activator.getDefault().getSSLSocketFactoryModifier();
    if (sslSocketFactoryModifier == null) {
        sslSocketFactoryModifier = new HttpClientDefaultSSLSocketFactoryModifier();
    }
    SSLSocketFactory sslSocketFactory = null;
    try {
        sslSocketFactory = sslSocketFactoryModifier.getSSLSocketFactory();
    } catch (IOException e) {
        // $NON-NLS-1$
        Trace.catching(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_CATCHING, ISSLSocketFactoryModifier.class, "getSSLSocketFactory()", e);
        // $NON-NLS-1$
        Trace.throwing(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_THROWING, HttpClientRetrieveFileTransfer.class, "registerSchemes()", e);
        // $NON-NLS-1$
        throw new ECFRuntimeException("Unable to instantiate schemes for HttpClient.", e);
    }
    Scheme https = new Scheme(HttpClientRetrieveFileTransfer.HTTPS, HTTPS_PORT, new ECFHttpClientSecureProtocolSocketFactory(sslSocketFactory, source, socketListener));
    // $NON-NLS-1$
    Trace.trace(Activator.PLUGIN_ID, "registering https scheme; modifier=" + sslSocketFactoryModifier);
    schemeRegistry.register(https);
    // SPNEGO is not supported, so remove it from the list
    List authpref = new ArrayList(3);
    authpref.add(AuthPolicy.NTLM);
    authpref.add(AuthPolicy.DIGEST);
    authpref.add(AuthPolicy.BASIC);
    httpClient.getParams().setParameter(AuthPNames.PROXY_AUTH_PREF, authpref);
    httpClient.getParams().setParameter(AuthPNames.TARGET_AUTH_PREF, authpref);
}
Also used : Scheme(org.apache.http.conn.scheme.Scheme) SchemeRegistry(org.apache.http.conn.scheme.SchemeRegistry) ArrayList(java.util.ArrayList) ECFHttpClientProtocolSocketFactory(org.eclipse.ecf.internal.provider.filetransfer.httpclient4.ECFHttpClientProtocolSocketFactory) ISSLSocketFactoryModifier(org.eclipse.ecf.internal.provider.filetransfer.httpclient4.ISSLSocketFactoryModifier) ECFHttpClientSecureProtocolSocketFactory(org.eclipse.ecf.internal.provider.filetransfer.httpclient4.ECFHttpClientSecureProtocolSocketFactory) List(java.util.List) ArrayList(java.util.ArrayList) IOException(java.io.IOException) SSLSocketFactory(javax.net.ssl.SSLSocketFactory) ECFRuntimeException(org.eclipse.ecf.core.util.ECFRuntimeException)

Example 2 with ECFRuntimeException

use of org.eclipse.ecf.core.util.ECFRuntimeException in project ecf by eclipse.

the class CompositeDiscoveryContainer method addContainer.

/**
 * @param object
 * @return true on success
 * @see java.util.List#add(java.lang.Object)
 */
public boolean addContainer(final Object object) {
    // connect the new container if necessary and register ourself as listeners
    IContainer iContainer = (IContainer) object;
    if (iContainer.getConnectedID() == null) {
        try {
            iContainer.connect(targetID, null);
        } catch (ContainerConnectException e) {
            // we eat the exception here
            // $NON-NLS-1$
            Trace.catching(Activator.PLUGIN_ID, METHODS_CATCHING, this.getClass(), "addContainer(Object)", e);
            return false;
        }
    }
    final IDiscoveryLocator idca = (IDiscoveryLocator) object;
    idca.addServiceListener(ccsl);
    idca.addServiceTypeListener(ccstl);
    // register previously registered with the new IDS
    synchronized (registeredServices) {
        final IDiscoveryAdvertiser ida = (IDiscoveryAdvertiser) object;
        for (final Iterator itr = registeredServices.iterator(); itr.hasNext(); ) {
            final IServiceInfo serviceInfo = (IServiceInfo) itr.next();
            try {
                ida.registerService(serviceInfo);
            } catch (final ECFRuntimeException e) {
                // we eat the exception here since the original registerService call is long done
                // $NON-NLS-1$
                Trace.catching(Activator.PLUGIN_ID, METHODS_CATCHING, this.getClass(), "addContainer(Object)", e);
            }
        }
    }
    synchronized (containers) {
        Trace.trace(Activator.PLUGIN_ID, METHODS_TRACING, this.getClass(), "addContainer(Object)", // $NON-NLS-1$ //$NON-NLS-2$
        "addContainer " + object.toString());
        return containers.add(object);
    }
}
Also used : ContainerConnectException(org.eclipse.ecf.core.ContainerConnectException) IContainer(org.eclipse.ecf.core.IContainer) ECFRuntimeException(org.eclipse.ecf.core.util.ECFRuntimeException)

Example 3 with ECFRuntimeException

use of org.eclipse.ecf.core.util.ECFRuntimeException in project ecf by eclipse.

the class JSLPDiscoveryContainer method registerService.

/* (non-Javadoc)
	 * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#registerService(org.eclipse.ecf.discovery.IServiceInfo)
	 */
public void registerService(IServiceInfo aServiceInfo) {
    Assert.isNotNull(aServiceInfo);
    try {
        JSLPServiceInfo si = new JSLPServiceInfo(aServiceInfo);
        IServiceTypeID stid = si.getServiceID().getServiceTypeID();
        Activator.getDefault().getAdvertiser().register(si.getServiceURL(), Arrays.asList(stid.getScopes()), new ServicePropertiesAdapter(si).toProperties());
    } catch (ServiceLocationException e) {
        // $NON-NLS-1$
        Trace.catching(Activator.PLUGIN_ID, JSLPDebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "registerService(IServiceInfo)", e);
        throw new ECFRuntimeException(e.getMessage(), e);
    }
}
Also used : ECFRuntimeException(org.eclipse.ecf.core.util.ECFRuntimeException) ServiceLocationException(ch.ethz.iks.slp.ServiceLocationException)

Example 4 with ECFRuntimeException

use of org.eclipse.ecf.core.util.ECFRuntimeException in project ecf by eclipse.

the class DnsSdAdvertiserServiceTest method testRegisterServiceWithoutHostKey.

/**
 * Tests that a register is handled correctly when no key is present
 * for that domain and the underlying ddns call fails
 * @throws ContainerConnectException
 */
public void testRegisterServiceWithoutHostKey() throws ContainerConnectException {
    final DnsSdDiscoveryAdvertiser advertiser = new DnsSdDiscoveryAdvertiser();
    advertiser.connect(null, null);
    try {
        advertiser.registerService(serviceInfo);
    } catch (ECFRuntimeException e) {
        advertiser.disconnect();
        return;
    }
    fail("Register should have failed without a host key given.");
}
Also used : DnsSdDiscoveryAdvertiser(org.eclipse.ecf.provider.dnssd.DnsSdDiscoveryAdvertiser) ECFRuntimeException(org.eclipse.ecf.core.util.ECFRuntimeException)

Aggregations

ECFRuntimeException (org.eclipse.ecf.core.util.ECFRuntimeException)4 ServiceLocationException (ch.ethz.iks.slp.ServiceLocationException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)1 Scheme (org.apache.http.conn.scheme.Scheme)1 SchemeRegistry (org.apache.http.conn.scheme.SchemeRegistry)1 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)1 IContainer (org.eclipse.ecf.core.IContainer)1 ECFHttpClientProtocolSocketFactory (org.eclipse.ecf.internal.provider.filetransfer.httpclient4.ECFHttpClientProtocolSocketFactory)1 ECFHttpClientSecureProtocolSocketFactory (org.eclipse.ecf.internal.provider.filetransfer.httpclient4.ECFHttpClientSecureProtocolSocketFactory)1 ISSLSocketFactoryModifier (org.eclipse.ecf.internal.provider.filetransfer.httpclient4.ISSLSocketFactoryModifier)1 DnsSdDiscoveryAdvertiser (org.eclipse.ecf.provider.dnssd.DnsSdDiscoveryAdvertiser)1