cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [07/10] cxf git commit: More refactoring
Date Fri, 13 Mar 2015 11:07:48 GMT
More refactoring


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/24e330c8
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/24e330c8
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/24e330c8

Branch: refs/heads/master
Commit: 24e330c8b6be65c98cd3914f6fe7498e980f4568
Parents: d68f140
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Tue Mar 10 13:24:13 2015 +0000
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Tue Mar 10 13:24:13 2015 +0000

----------------------------------------------------------------------
 .../wss4j/policyhandlers/AbstractBindingBuilder.java | 15 +++++++++++----
 .../policyhandlers/AsymmetricBindingHandler.java     |  4 ++--
 .../policyhandlers/SymmetricBindingHandler.java      |  5 +++--
 .../policyhandlers/TransportBindingHandler.java      |  6 ------
 .../ws/security/wss4j/SignatureConfirmationTest.java |  6 +++---
 5 files changed, 19 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/24e330c8/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
----------------------------------------------------------------------
diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
index 69a6e88..7dd95af 100644
--- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
+++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
@@ -22,6 +22,7 @@ package org.apache.cxf.ws.security.wss4j.policyhandlers;
 import java.net.URL;
 import java.security.cert.X509Certificate;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Date;
 import java.util.HashSet;
@@ -164,7 +165,7 @@ public abstract class AbstractBindingBuilder extends AbstractCommonBindingHandle
     
     protected Set<WSEncryptionPart> encryptedTokensList = new HashSet<WSEncryptionPart>();
 
-    protected List<byte[]> signatures = new ArrayList<byte[]>();
+    protected Set<Integer> signatures = new HashSet<>();
 
     protected Element bottomUpElement;
     protected Element topDownElement;
@@ -1829,7 +1830,7 @@ public abstract class AbstractBindingBuilder extends AbstractCommonBindingHandle
                     List<Reference> referenceList = sig.addReferencesToSign(sigParts,
secHeader);
                     sig.computeSignature(referenceList, false, null);
                     
-                    signatures.add(sig.getSignatureValue());
+                    addSig(sig.getSignatureValue());
                     if (isSigProtect) {
                         WSEncryptionPart part = new WSEncryptionPart(sig.getId(), "Element");
                         encryptedTokensList.add(part);
@@ -1966,7 +1967,7 @@ public abstract class AbstractBindingBuilder extends AbstractCommonBindingHandle
         //Do signature
         dkSign.computeSignature(referenceList, false, null);
         
-        signatures.add(dkSign.getSignatureValue());
+        addSig(dkSign.getSignatureValue());
     }
     
     private void doSymmSignature(AbstractToken policyToken, SecurityToken tok,
@@ -2032,7 +2033,7 @@ public abstract class AbstractBindingBuilder extends AbstractCommonBindingHandle
 
         //Do signature
         sig.computeSignature(referenceList, false, null);
-        signatures.add(sig.getSignatureValue());
+        addSig(sig.getSignatureValue());
     }
     
     protected void addSupportingTokens(List<WSEncryptionPart> sigs) throws WSSecurityException
{
@@ -2241,4 +2242,10 @@ public abstract class AbstractBindingBuilder extends AbstractCommonBindingHandle
         }
 
     }
+    
+    protected void addSig(byte[] val) {
+        if (val != null && val.length > 0) {
+            signatures.add(Arrays.hashCode(val));
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/24e330c8/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java
----------------------------------------------------------------------
diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java
b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java
index fc3aa8b..67d7afe 100644
--- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java
+++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java
@@ -665,7 +665,7 @@ public class AsymmetricBindingHandler extends AbstractBindingBuilder {
                     dkSign.computeSignature(referenceList, true, bottomUpElement);
                 }
                 bottomUpElement = dkSign.getSignatureElement();
-                signatures.add(dkSign.getSignatureValue());
+                addSig(dkSign.getSignatureValue());
                 
                 mainSigId = dkSign.getSignatureId();
             } catch (Exception ex) {
@@ -704,7 +704,7 @@ public class AsymmetricBindingHandler extends AbstractBindingBuilder {
                 }
             }
             
-            signatures.add(sig.getSignatureValue());
+            addSig(sig.getSignatureValue());
                         
             mainSigId = sig.getId();
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/24e330c8/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java
----------------------------------------------------------------------
diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java
b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java
index c04597c..de508d7 100644
--- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java
+++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java
@@ -211,7 +211,7 @@ public class SymmetricBindingHandler extends AbstractBindingBuilder {
                 //Sign the message
                 //We should use the same key in the case of EncryptBeforeSig
                 if (sigParts.size() > 0) {
-                    signatures.add(this.doSignature(sigParts, encryptionWrapper, encryptionToken,

+                    addSig(this.doSignature(sigParts, encryptionWrapper, encryptionToken,

                                                     tok, attached));
                 }
                 
@@ -338,7 +338,8 @@ public class SymmetricBindingHandler extends AbstractBindingBuilder {
             sigs.addAll(getSignedParts(null));
             if (isRequestor()) {
                 if (!sigs.isEmpty()) {
-                    signatures.add(doSignature(sigs, sigAbstractTokenWrapper, sigToken, sigTok,
tokIncluded));
+                    addSig(
+                        doSignature(sigs, sigAbstractTokenWrapper, sigToken, sigTok, tokIncluded));
                 }
                 doEndorse();
             } else {

http://git-wip-us.apache.org/repos/asf/cxf/blob/24e330c8/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/TransportBindingHandler.java
----------------------------------------------------------------------
diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/TransportBindingHandler.java
b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/TransportBindingHandler.java
index 1f8a21c..9712f51 100644
--- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/TransportBindingHandler.java
+++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/TransportBindingHandler.java
@@ -126,12 +126,6 @@ public class TransportBindingHandler extends AbstractBindingBuilder {
         
     }
     
-    private void addSig(byte[] val) {
-        if (val != null && val.length > 0) {
-            signatures.add(val);
-        }
-    }
-    
     public void handleBinding() {
         WSSecTimestamp timestamp = createTimestamp();
         handleLayout(timestamp);

http://git-wip-us.apache.org/repos/asf/cxf/blob/24e330c8/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/SignatureConfirmationTest.java
----------------------------------------------------------------------
diff --git a/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/SignatureConfirmationTest.java
b/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/SignatureConfirmationTest.java
index 6ea49f1..2a0cc9c 100644
--- a/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/SignatureConfirmationTest.java
+++ b/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/SignatureConfirmationTest.java
@@ -21,6 +21,7 @@ package org.apache.cxf.ws.security.wss4j;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.util.List;
+import java.util.Set;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -32,7 +33,6 @@ import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.dom.DOMSource;
 
 import org.w3c.dom.Document;
-
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.DOMUtils.NullResolver;
@@ -98,7 +98,7 @@ public class SignatureConfirmationTest extends AbstractSecurityTest {
         //
         // Save the signature for future confirmation
         //
-        List<WSHandlerResult> sigv = CastUtils.cast((List<?>)msg.get(WSHandlerConstants.SEND_SIGV));
+        Set<Integer> sigv = CastUtils.cast((Set<?>)msg.get(WSHandlerConstants.SEND_SIGV));
         assertNotNull(sigv);
         assertTrue(sigv.size() != 0);
         
@@ -144,7 +144,7 @@ public class SignatureConfirmationTest extends AbstractSecurityTest {
     
    
     private void testSignatureConfirmationResponse(
-        List<WSHandlerResult> sigSaved,
+        Set<Integer> sigSaved,
         List<WSHandlerResult> sigReceived
     ) throws Exception {
         Document doc = readDocument("wsse-request-clean.xml");


Mime
View raw message