if(globalContext.getTrustedCertificates() != null){
ctx.setTrustedCertificates(globalContext.getTrustedCertificates());
}else if(trustedCertsFile != null && new File(trustedCertsFile).isFile()){
ctx.loadRootCertificates(trustedCertsFile);
}else if(trustedCertsFile != null && new File(trustedCertsFile).isDirectory()){
TrustedCertificates certificates = TrustedCertificates.load(trustedCertsFile);
TrustedCertificates.setDefaultTrustedCertificates(certificates);
ctx.setTrustedCertificates(certificates.getCertificates());
}
else{
TrustedCertificates tc = TrustedCertificates.getDefaultTrustedCertificates();
ctx.setTrustedCertificates(tc.getCertificates());
}
ctx.loadEAYKeyFile(certKeyFile, "");
SSLPolicyInt policy = new SSLPolicyInt();
policy.requireClientAuth(true);
policy.setAcceptNoClientCert(true);
ctx.setPolicy(policy);
}else{
//Use Globous crednatials if it is there
try {
ctx = new PureTLSContext();
GSSCredential gssCredntial = globalContext.getCredential();
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");
}