From 775629c1e6bfae6a663829dd436611160b4e394e Mon Sep 17 00:00:00 2001 From: Tareq Abedrabbo Date: Mon, 10 Aug 2009 09:58:56 +0000 Subject: [PATCH] SWS-547 - support for securement signature user setting via WSHandlerConstants.SIGNATURE_USER --- .../security/wss4j/Wss4jSecurityInterceptor.java | 14 ++++++++++++++ .../Wss4jMessageInterceptorSignTestCase.java | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/security/src/main/java/org/springframework/ws/soap/security/wss4j/Wss4jSecurityInterceptor.java b/security/src/main/java/org/springframework/ws/soap/security/wss4j/Wss4jSecurityInterceptor.java index c26dd94a..b46ea781 100755 --- a/security/src/main/java/org/springframework/ws/soap/security/wss4j/Wss4jSecurityInterceptor.java +++ b/security/src/main/java/org/springframework/ws/soap/security/wss4j/Wss4jSecurityInterceptor.java @@ -324,6 +324,20 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl handler.setOption(WSHandlerConstants.SIGNATURE_PARTS, securementSignatureParts); } + /** + * The user's name for signature. + *

+ * This name is used as the alias name in the keystore to get user's + * certificate and private key to perform signing. + *

+ * If this parameter is not set, then the signature + * function falls back to the alias specified by {@link #setSecurementUsername(String)}. + *

+ */ + 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; diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSignTestCase.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSignTestCase.java index 7354ae14..404ddde7 100755 --- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSignTestCase.java +++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSignTestCase.java @@ -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); + + + } }