This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch coheigea/saml-refactor-new
in repository https://gitbox.apache.org/repos/asf/ws-wss4j.git


The following commit(s) were added to refs/heads/coheigea/saml-refactor-new by 
this push:
     new 4957565e6 Moving WSSecSignatureBase to common
4957565e6 is described below

commit 4957565e6e73cc0bb1c3c614cb5eac169e139edb
Author: Colm O hEigeartaigh <[email protected]>
AuthorDate: Fri Jun 20 12:11:48 2025 +0100

    Moving WSSecSignatureBase to common
---
 .../common}/dom/message/WSSecSignatureBase.java    | 27 +++++++++++++++++-----
 .../wss4j/dom/message/WSSecDerivedKeyBase.java     |  1 +
 .../apache/wss4j/dom/message/WSSecSignature.java   |  1 +
 3 files changed, 23 insertions(+), 6 deletions(-)

diff --git 
a/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureBase.java
 
b/ws-security-common/src/main/java/org/apache/wss4j/common/dom/message/WSSecSignatureBase.java
similarity index 92%
rename from 
ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureBase.java
rename to 
ws-security-common/src/main/java/org/apache/wss4j/common/dom/message/WSSecSignatureBase.java
index 893406a10..b08c6cefb 100644
--- 
a/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureBase.java
+++ 
b/ws-security-common/src/main/java/org/apache/wss4j/common/dom/message/WSSecSignatureBase.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.wss4j.dom.message;
+package org.apache.wss4j.common.dom.message;
 
 import java.security.InvalidAlgorithmParameterException;
 import java.security.NoSuchAlgorithmException;
@@ -26,6 +26,7 @@ import java.util.Collections;
 import java.util.List;
 
 import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
 import javax.xml.crypto.XMLStructure;
 import javax.xml.crypto.dom.DOMStructure;
 import javax.xml.crypto.dsig.DigestMethod;
@@ -34,8 +35,6 @@ import javax.xml.crypto.dsig.XMLSignatureFactory;
 import javax.xml.crypto.dsig.spec.ExcC14NParameterSpec;
 import javax.xml.crypto.dsig.spec.TransformParameterSpec;
 
-import org.apache.wss4j.common.dom.message.WSSecBase;
-import org.apache.wss4j.common.dom.message.WSSecHeader;
 import org.apache.wss4j.common.WSEncryptionPart;
 import org.apache.wss4j.common.dom.callback.DOMCallbackLookup;
 import org.apache.wss4j.common.ext.Attachment;
@@ -47,10 +46,9 @@ import org.apache.wss4j.common.dom.WSConstants;
 import org.apache.wss4j.common.dom.WSDocInfo;
 import org.apache.wss4j.common.dom.transform.AttachmentTransformParameterSpec;
 import org.apache.wss4j.common.dom.transform.STRTransform;
-import org.apache.wss4j.common.dom.message.SignatureUtils;
-import org.apache.wss4j.dom.util.WSSecurityUtil;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
+import org.w3c.dom.Node;
 
 /**
  * This is the base class for WS Security messages that are used for signature 
generation or
@@ -244,7 +242,7 @@ public class WSSecSignatureBase extends WSSecBase {
                 clonedElements.add(element);
                 Document doc = this.getSecurityHeader().getSecurityHeaderDoc();
                 element.getParentNode().appendChild(XMLUtils.cloneElement(doc, 
element));
-                WSSecurityUtil.inlineAttachments(includeElements, 
attachmentCallbackHandler, false);
+                inlineAttachments(includeElements, attachmentCallbackHandler, 
false);
             }
         }
     }
@@ -354,4 +352,21 @@ public class WSSecSignatureBase extends WSSecBase {
         }
     }
 
+    private static void inlineAttachments(List<Element> includeElements,
+                                         CallbackHandler 
attachmentCallbackHandler,
+                                         boolean removeAttachments) throws 
WSSecurityException {
+        for (Element includeElement : includeElements) {
+            String xopURI = includeElement.getAttributeNS(null, "href");
+            if (xopURI != null) {
+                // Retrieve the attachment bytes
+                byte[] attachmentBytes =
+                    AttachmentUtils.getBytesFromAttachment(xopURI, 
attachmentCallbackHandler, removeAttachments);
+                String encodedBytes = 
org.apache.xml.security.utils.XMLUtils.encodeToString(attachmentBytes);
+
+                Node encodedChild =
+                    
includeElement.getOwnerDocument().createTextNode(encodedBytes);
+                includeElement.getParentNode().replaceChild(encodedChild, 
includeElement);
+            }
+        }
+    }
 }
diff --git 
a/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDerivedKeyBase.java
 
b/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDerivedKeyBase.java
index 8e764f06c..9d98f3634 100644
--- 
a/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDerivedKeyBase.java
+++ 
b/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDerivedKeyBase.java
@@ -31,6 +31,7 @@ import org.apache.wss4j.common.derivedKey.AlgoFactory;
 import org.apache.wss4j.common.derivedKey.ConversationConstants;
 import org.apache.wss4j.common.derivedKey.DerivationAlgorithm;
 import org.apache.wss4j.common.dom.message.WSSecHeader;
+import org.apache.wss4j.common.dom.message.WSSecSignatureBase;
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.common.token.Reference;
 import org.apache.wss4j.common.token.SecurityTokenReference;
diff --git 
a/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignature.java
 
b/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignature.java
index c8039c588..9483be3f2 100644
--- 
a/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignature.java
+++ 
b/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignature.java
@@ -49,6 +49,7 @@ import org.apache.wss4j.common.crypto.Crypto;
 import org.apache.wss4j.common.crypto.CryptoType;
 import org.apache.wss4j.common.crypto.DERDecoder;
 import org.apache.wss4j.common.dom.message.WSSecHeader;
+import org.apache.wss4j.common.dom.message.WSSecSignatureBase;
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.common.token.BinarySecurity;
 import org.apache.wss4j.common.token.DOMX509Data;

Reply via email to