Hi!
I'm trying to access an EJBCA server via the provided web services from my java application. I am trying to run the following code snippet from the official documentation (http://ejbca.org/docs/adminguide.html#Using%20the%20Web%20Service%20API%20for%20Integration):
CryptoProviderTools.installBCProvider();
String urlstr = "https://localhost:8443/ejbca/ejbcaws/ejbcaws?wsdl";
System.setProperty("javax.net.ssl.trustStore","p12/wstest.jks");
System.setProperty("javax.net.ssl.trustStorePassword","foo123");
System.setProperty("javax.net.ssl.keyStore","p12/wstest.jks");
System.setProperty("javax.net.ssl.keyStorePassword","foo123");
QName qname = new QName("http://ws.protocol.core.ejbca.org/", "EjbcaWSService");
EjbcaWSService service = new EjbcaWSService(new URL(urlstr),qname);
ejbcaraws = service.getEjbcaWSPort();
However, the first line gives me a ClassCastException: org.bouncycastle.jce.provider.BouncyCastleProvider cannot be cast to org.bouncycastle.jce.interfaces.ConfigurableProvider
. I have checked that the BouncyCastleProvider does implement the ConfigurableProvider interface.
More curiously, when i call the function twice (CryptoProviderTools.installBCProvider()
), the second time around i get a NoSuchFieldError
, with the following cause: java.lang.NoSuchFieldError: SN
Thank you very much for your help :)
I was having the same problem, I found this document "The Cryptoworkshop Guide to Java Cryptography and the Bouncy Castle APIs" at http://www.cryptoworkshop.com/guide/cwguide-070313.pdf
which says: To install the provider at run time just add: Security.addProvider(new BouncyCastleProvider());
This also requires importing:
import java.security.Security; import org.bouncycastle.jce.provider.BouncyCastleProvider;
If I check the providers I do see BC
(requires importing import java.security.Provider)
but now I'm stuck when I try to get any info from ejbca I get the
Administrator is not authorized to resource /administrator. Msg: .
So hope that helps you.