I'm using Axis2 and need to attach a client certificate when I make requests to a specific Web Service. So far I haven't modified anything from the Axis2 configuration (axis2.xml or anything else), and I'd really prefer to keep it that way.
The solution in C# is very straightforward:
X509Certificate2 cert = new X509Certificate2(pathToCertificate, certificatePassword);
X509SecurityToken token = new X509SecurityToken(cert);
SoapContext context = port.RequestSoapContext;
context.Security.Tokens.Add(token);
context.Security.Elements.Add(new MessageSignature(token));
context.Security.Timestamp.TtlInSeconds = 60;
However, I haven't found a way to do the same in Java. Right now I only have the certificate loaded from a key store as a java.security.cert.Certificate. How do I add it to my SOAP request?
EDIT: Apparently I should be able to do this using Rampart. However, it seems to me that in order to use it, I have to change some Axis2 config files, which is exactly what I'm trying to avoid. Also, there seems to be some configuration in Axis2 where the key store is specified. Is there really no way to do this by code?