cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject cxf git commit: Make Signature protection policy validation more robust
Date Mon, 24 Nov 2014 15:06:08 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes a79141e64 -> a3647e52b


Make Signature protection policy validation more robust


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

Branch: refs/heads/2.7.x-fixes
Commit: a3647e52bca18ddae734897b29b0ceab2da1ce6f
Parents: a79141e
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Mon Nov 24 14:36:41 2014 +0000
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Mon Nov 24 14:52:11 2014 +0000

----------------------------------------------------------------------
 .../AbstractBindingPolicyValidator.java         | 22 +++++++++-----------
 1 file changed, 10 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/a3647e52/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyvalidators/AbstractBindingPolicyValidator.java
----------------------------------------------------------------------
diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyvalidators/AbstractBindingPolicyValidator.java
b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyvalidators/AbstractBindingPolicyValidator.java
index 75810bf..e8cd6c4 100644
--- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyvalidators/AbstractBindingPolicyValidator.java
+++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyvalidators/AbstractBindingPolicyValidator.java
@@ -400,13 +400,15 @@ public abstract class AbstractBindingPolicyValidator implements BindingPolicyVal
             Integer actInt = (Integer)result.get(WSSecurityEngineResult.TAG_ACTION);
             if (actInt.intValue() == WSConstants.SIGN && !foundPrimarySignature)
{
                 foundPrimarySignature = true;
-                String sigId = (String)result.get(WSSecurityEngineResult.TAG_ID);
-                if (sigId == null || !isIdEncrypted(sigId, results)) {
+                Element sigElement = 
+                    (Element)result.get(WSSecurityEngineResult.TAG_TOKEN_ELEMENT);
+                if (sigElement == null || !isElementEncrypted(sigElement, results)) {
                     return false;
                 }
             } else if (actInt.intValue() == WSConstants.SC) {
-                String sigId = (String)result.get(WSSecurityEngineResult.TAG_ID);
-                if (sigId == null || !isIdEncrypted(sigId, results)) {
+                Element sigElement = 
+                    (Element)result.get(WSSecurityEngineResult.TAG_TOKEN_ELEMENT);
+                if (sigElement == null || !isElementEncrypted(sigElement, results)) {
                     return false;
                 }
             }
@@ -415,9 +417,9 @@ public abstract class AbstractBindingPolicyValidator implements BindingPolicyVal
     }
     
     /**
-     * Return true if the given id was encrypted
+     * Return true if the given Element was encrypted
      */
-    private boolean isIdEncrypted(String sigId, List<WSSecurityEngineResult> results)
{
+    private boolean isElementEncrypted(Element element, List<WSSecurityEngineResult>
results) {
         for (WSSecurityEngineResult wser : results) {
             Integer actInt = (Integer)wser.get(WSSecurityEngineResult.TAG_ACTION);
             if (actInt.intValue() == WSConstants.ENCR) {
@@ -426,12 +428,8 @@ public abstract class AbstractBindingPolicyValidator implements BindingPolicyVal
                 if (el != null) {
                     for (WSDataRef r : el) {
                         Element protectedElement = r.getProtectedElement();
-                        if (protectedElement != null) {
-                            String id = protectedElement.getAttributeNS(null, "Id");
-                            String wsuId = protectedElement.getAttributeNS(WSConstants.WSU_NS,
"Id");
-                            if (sigId.equals(id) || sigId.equals(wsuId)) {
-                                return true;
-                            }
+                        if (element.equals(protectedElement)) {
+                            return true;
                         }
                     }
                 }


Mime
View raw message