protected static IXregistryPortType createSSLSecureServiceStub(String hostkeyPath, X509Certificate[] trustedCerts,
String xregistryServiceWsdlUrl) throws XRegistryClientException, GeneralSecurityException,
FileNotFoundException, IOException{
try {
if (hostkeyPath == null || hostkeyPath == "") {
throw new XRegistryClientException("The host key file path is null or empty");
}
PureTLSContext ctx = new PureTLSContext();
ctx.setTrustedCertificates(trustedCerts);
ctx.loadEAYKeyFile(hostkeyPath, "");
SSLPolicyInt policy = new SSLPolicyInt();
policy.requireClientAuth(true);
policy.setAcceptNoClientCert(true);
ctx.setPolicy(policy);
SoapHttpDynamicInfosetInvoker invoker = new PuretlsInvoker(ctx);
String wsdlAsStr = invoker.invokeHttpGet(xregistryServiceWsdlUrl);
XmlElement el = XmlConstants.BUILDER.parseFragmentFromReader(new StringReader(wsdlAsStr));
WsdlDefinitions def = new WsdlDefinitions(el);
WSIFServiceFactory wsf = WSIFServiceFactory.newInstance();
WSIFService serv = wsf.getService(def);
serv.addLocalProvider(new Provider(invoker));
WSIFClient client = XmlBeansWSIFRuntime.getDefault().newClientFor(serv.getPort());
((XsulSoapPort) client.getPort()).setInvoker(invoker);
return (IXregistryPortType)client.generateDynamicStub(IXregistryPortType.class);
} catch (WSIFException e) {
throw new XRegistryClientException(e);
} catch (XsulException e) {
throw new XRegistryClientException(e);
} catch (IOException e) {
throw new XRegistryClientException(e);
} catch (GeneralSecurityException e) {
throw new XRegistryClientException(e);
} catch (XmlBuilderException e) {
throw new XRegistryClientException(e);
}
}