if(gssCredntial instanceof GlobusGSSCredentialImpl){
GlobusCredential globusCred = ((GlobusGSSCredentialImpl)gssCredntial).getGlobusCredential();
TrustedCertificates tc = TrustedCertificates.getDefaultTrustedCertificates();
if (tc == null)
{
throw new XregistryException("Trusted certificates is null");
}
X509Certificate[] certs = tc.getCertificates();
ctx.setTrustedCertificates(certs);
ctx.setCredential(globusCred);
}else{
throw new XregistryException("Can not find the credantial to start a secure server");
}
} catch (RuntimeException e) {
throw new XregistryException("Secuirty is enabled, but no credentials found");
}
}
}
//This is to provide rest support
// HttpBasedServices httpServices;
// XregistryXmlBeansWrapper xregistryXmlBeansWrapper = new XregistryXmlBeansWrapper(globalContext);
// if(ctx != null){
// ServerSocketFactory secureSocketFactory = new PuretlsServerSocketFactory(port, ctx);
// httpServices = new XregistryHttpbasedServices(secureSocketFactory,xregistryXmlBeansWrapper.getRegistryImpl());
// }else{
// httpServices = new XregistryHttpbasedServices(port,xregistryXmlBeansWrapper.getRegistryImpl());
// }
// String cwsdlLoc = Thread.currentThread().getContextClassLoader().getResource("xregistry.wsdl").toString();
//
//
// ExtendedXbeanBasedService service = new ExtendedXbeanBasedService("xregistry", cwsdlLoc,
// xregistryXmlBeansWrapper);
// cmsvc = httpServices.addService(service);
// service.addHandler(new xsul.xhandler_context.ServerContextAccessHandler("service-context"));
// //service.startService();
// service.initManagmentAgent();
XregistryXmlBeansWrapper xregistryXmlBeansWrapper = new XregistryXmlBeansWrapper(globalContext);
HttpBasedServices httpServices;
if(ctx != null){
ServerSocketFactory secureSocketFactory = new PuretlsServerSocketFactory(port, ctx);
httpServices = new XregistryHttpbasedServices(secureSocketFactory,xregistryXmlBeansWrapper.getRegistryImpl());
}else{
httpServices = new XregistryHttpbasedServices(port,xregistryXmlBeansWrapper.getRegistryImpl());
}
String cwsdlLoc = Thread.currentThread().getContextClassLoader().getResource("xregistry.wsdl").toString();
XmlBeansBasedService xbeanBasedService = new XmlBeansBasedService("xregistry", cwsdlLoc,
xregistryXmlBeansWrapper);
cmsvc = httpServices.addService(xbeanBasedService)
.addHandler(new xsul.xhandler_context.ServerContextAccessHandler("service-context"));
System.out.println("Server started on "+httpServices.getServer().getLocation());
} catch (HttpServerException e) {
throw new XregistryException(e);
} catch (DynamicInfosetProcessorException e) {
throw new XregistryException(e);
} catch (FileNotFoundException e) {
throw new XregistryException(e);
} catch (IOException e) {
throw new XregistryException(e);
} catch (GeneralSecurityException e) {
throw new XregistryException(e);
}
}