SWS-547 - support for securement signature user setting via WSHandlerConstants.SIGNATURE_USER

This commit is contained in:
Tareq Abedrabbo
2009-08-10 09:58:56 +00:00
parent 1ff799bc22
commit 775629c1e6
2 changed files with 30 additions and 0 deletions

View File

@@ -324,6 +324,20 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl
handler.setOption(WSHandlerConstants.SIGNATURE_PARTS, securementSignatureParts);
}
/**
* The user's name for signature.
* <p/>
* This name is used as the alias name in the keystore to get user's
* certificate and private key to perform signing.
* <p/>
* If this parameter is not set, then the signature
* function falls back to the alias specified by {@link #setSecurementUsername(String)}.
* <p/>
*/
public void setSecurementSignatureUser(String securementSignatureUser) {
handler.setOption(WSHandlerConstants.SIGNATURE_USER, securementSignatureUser);
}
/** Sets the username for securement username token or/and the alias of the private key for securement signature */
public void setSecurementUsername(String securementUsername) {
this.securementUsername = securementUsername;

View File

@@ -97,4 +97,20 @@ public abstract class Wss4jMessageInterceptorSignTestCase extends Wss4jTestCase
}
public void testSignResponseWithSignatureUser() throws Exception {
interceptor.setSecurementActions("Signature");
interceptor.setEnableSignatureConfirmation(false);
interceptor.setSecurementPassword("123456");
interceptor.setSecurementSignatureUser("rsaKey");
SoapMessage message = loadMessage("empty-soap.xml");
MessageContext messageContext = getMessageContext(message);
interceptor.secureMessage(message, messageContext);
Document document = getDocument(message);
assertXpathExists("Absent SignatureConfirmation element",
"/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/ds:Signature", document);
}
}