Q:

Java soap client for EJBCA webservices

I am trying to build a Java Soap Client to call Ejbca webservices.
I'm facing to an issue at certificat level.
Exception in thread "main" org.ejbca.core.protocol.ws.AuthorizationDeniedException_Exception: Error no client certificate received used for authentication.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

From my installation I can retrieve the *.p12 file, how can I tell to my Java program to use this file to call correctly the web service.
Thanks for your help.

A:

In EJBCA there is a tool called clientToolBox, which is a command line utility that makes webservice calls. This is a good tool to test WS functionality. 
ClientToolBox also functions as sample code for various WS commands.
For the client certificate issue, you can check in org.ejbca.core.protocol.ws.client.EJBCAWSRABaseCommand. There is code in the constructor that loads the p12 file and sets the java property javax.net.ssl.keyStore and other properties. 
final String keyStorePath = props.getProperty("ejbcawsracli.keystore.path", "keystore.jks");
checkIfFileExists(keyStorePath);
System.setProperty("javax.net.ssl.keyStore", keyStorePath);
if (keyStorePath.endsWith(".p12")) {
    System.setProperty("javax.net.ssl.keyStoreType", "pkcs12");
}
if ( trustStorePath==null  ) {
    if (keyStorePath.endsWith(".p12")) {
        final Provider tlsProvider = new TLSProvider();
        Security.addProvider(tlsProvider);
        Security.setProperty("ssl.TrustManagerFactory.algorithm", "AcceptAll");
    } else {
        System.setProperty("javax.net.ssl.trustStore", keyStorePath);
    }
}
System.setProperty("javax.net.ssl.keyStorePassword", password);

The keystore properties are described in the web services documentation for EJBCA:
https://www.ejbca.org/docs/Web_Service_Interface.html#src-16224398_id-.WebServiceInterfacev6.12.0-UsingtheWebServiceAPIforIntegrationUsing_the_Web_Service_API_for_Integratio
Documentation for clientToolBox can be found in the documentation:
https://www.ejbca.org/docs/EJBCA_Client_Toolbox.html

