You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wss4j-dev@ws.apache.org by Massimiliano Masi <ma...@math.unifi.it> on 2008/04/17 12:47:03 UTC
Signing a SOAP Envelope using KeyStore
Hello,
I'm using Axis2 without rampart. I've the following question.
I've to sign a SOAP envelope. I tried the following code [1].
Do this code is correct? Do you have any example / pattern / documentation?
I already have both a KeyStore (as ByteArrayInputStream) and / or
a key pair. How can I instantiate Crypto without the use of
the crypto.properties (that I don't need, and I don't have a keystore
on the filesystem?) [2]
Thank you,
Massimiliano
[1]
public void signEnvelope()
{
WSSecurityEngine engine = WSSecurityEngine.getInstance();
try {
Document doc = XMLUtils.toDOM(envelope).getOwnerDocument();
WSSecSignature signer = new WSSecSignature();
signer.setSigCanonicalization(SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS);
signer.setSignatureAlgorithm(SignatureConstants.ALGO_ID_SIGNATURE_RSA);
WSSecHeader secHeader = new WSSecHeader();
secHeader.insertSecurityHeader(doc);
// NOTE: The security header of the SOAP Envelope is already present
Vector parts = new Vector();
WSEncryptionPart encparts = new
WSEncryptionPart(SOAPConstants.SOAP12_CONSTANTS.getEnvelopeURI());
parts.add(encparts);
signer.setParts(parts);
Crypto crypto = CryptoFactory.getInstance();
crypto.getKeyStore().load(new ByteArrayInputStream(idp.getKeyStore()),
idp.getPKCS12Password().toCharArray());
doc = signer.build(doc, crypto, secHeader);
} catch (Exception e) {
[2]
java.lang.RuntimeException: CryptoFactory: Cannot load properties:
crypto.properties
at
org.apache.ws.security.components.crypto.CryptoFactory.getProperties(CryptoFactory.java:254)
at
org.apache.ws.security.components.crypto.CryptoFactory.getProperties(CryptoFactory.java:237)
at
org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:157)
at
org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:55)
at
com.spirit.XUA.utils.SOAPEnvelopeSignatureTest.signEnvelope(SOAPEnvelopeSignatureTest.java:89)
at
com.spirit.XUA.utils.SOAPEnvelopeSignatureTest.main(SOAPEnvelopeSignatureTest.java:208)
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org