From 59f3ae0b6789628365c605e2d2188f89ae0992de Mon Sep 17 00:00:00 2001 From: elfogre Date: Tue, 2 Jan 2018 17:38:37 +0100 Subject: [PATCH 1/2] Allow to sign SOAP attachments See gh-107 --- .../security/wss4j2/Wss4jSecurityInterceptor.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java index b0f1648d..45c6ea60 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java @@ -199,6 +199,8 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl private CallbackHandler samlCallbackHandler; + private CallbackHandler attachmentCallbackHandler; + // Allow RSA 15 to maintain default behavior private boolean allowRSA15KeyTransportAlgorithm = true; @@ -458,6 +460,14 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl this.samlCallbackHandler = samlCallbackHandler; } + /** + * Sets the attachment callback handler used for SwA signature/encryption + * @param attachmentCallbackHandler + */ + public void setAttachmentCallbackHandler (CallbackHandler attachmentCallbackHandler) { + this.attachmentCallbackHandler = attachmentCallbackHandler; + } + /** * Sets the server-side time to live. */ @@ -705,6 +715,8 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl requestData.setWssConfig(this.wssConfig); + requestData.setAttachmentCallbackHandler(attachmentCallbackHandler); + messageContext.setProperty(WSHandlerConstants.TTL_TIMESTAMP, Integer.toString(this.securementTimeToLive)); if (this.samlCallbackHandler != null) { From 90ff94a7770b7ac127badeb4a78045ce4a5f31c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Mon, 10 Mar 2025 06:16:18 +0100 Subject: [PATCH 2/2] Polish "Allow to sign SOAP attachments" See gh-107 --- .../wss4j2/Wss4jSecurityInterceptor.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java index 45c6ea60..fec85315 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java @@ -461,12 +461,13 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl } /** - * Sets the attachment callback handler used for SwA signature/encryption - * @param attachmentCallbackHandler - */ - public void setAttachmentCallbackHandler (CallbackHandler attachmentCallbackHandler) { - this.attachmentCallbackHandler = attachmentCallbackHandler; - } + * Set the {@link CallbackHandler} to use to sign/encrypt attachments. + * @param attachmentCallbackHandler the attachment callback handler + * @since 4.1.0 + */ + public void setAttachmentCallbackHandler(CallbackHandler attachmentCallbackHandler) { + this.attachmentCallbackHandler = attachmentCallbackHandler; + } /** * Sets the server-side time to live. @@ -715,13 +716,14 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl requestData.setWssConfig(this.wssConfig); - requestData.setAttachmentCallbackHandler(attachmentCallbackHandler); - messageContext.setProperty(WSHandlerConstants.TTL_TIMESTAMP, Integer.toString(this.securementTimeToLive)); if (this.samlCallbackHandler != null) { messageContext.setProperty(WSHandlerConstants.SAML_CALLBACK_REF, this.samlCallbackHandler); } + if (this.attachmentCallbackHandler != null) { + requestData.setAttachmentCallbackHandler(this.attachmentCallbackHandler); + } // allow for qualified password types for .Net interoperability requestData.setAllowNamespaceQualifiedPasswordTypes(true);