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