cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [1/2] git commit: Improved setting policies.
Date Tue, 15 Apr 2014 14:51:02 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 5204b1ec6 -> 1f5a2ffd4


Improved setting policies.


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

Branch: refs/heads/master
Commit: 7bbe6d06bcdaa8ba6b1e8c350dc3b414683df93d
Parents: 5204b1e
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Tue Apr 15 15:06:46 2014 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Tue Apr 15 15:06:46 2014 +0100

----------------------------------------------------------------------
 .../wss4j/PolicyStaxActionInInterceptor.java    | 45 ++++++++++----------
 1 file changed, 23 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/7bbe6d06/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyStaxActionInInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyStaxActionInInterceptor.java
b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyStaxActionInInterceptor.java
index 59a13b1..e896980 100644
--- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyStaxActionInInterceptor.java
+++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyStaxActionInInterceptor.java
@@ -20,6 +20,7 @@ package org.apache.cxf.ws.security.wss4j;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 import java.util.logging.Logger;
 
 import javax.xml.namespace.QName;
@@ -85,8 +86,6 @@ public class PolicyStaxActionInInterceptor extends AbstractPhaseInterceptor<Soap
         }
         
         assertAllSecurityAssertions(aim);
-        assertAllAlgorithmSuites(SP11Constants.SP_NS, aim);
-        assertAllAlgorithmSuites(SP12Constants.SP_NS, aim);
     }
     
     private SecurityEvent findEvent(Event event, List<SecurityEvent> incomingSecurityEventList)
{
@@ -99,33 +98,35 @@ public class PolicyStaxActionInInterceptor extends AbstractPhaseInterceptor<Soap
     }
     
     private void assertAllSecurityAssertions(AssertionInfoMap aim) {
-        for (QName key : aim.keySet()) {
-            if (SP11Constants.SP_NS.equals(key.getNamespaceURI())
-                || SP12Constants.SP_NS.equals(key.getNamespaceURI())
-                || SP13Constants.SP_NS.equals(key.getNamespaceURI())) {
-                Collection<AssertionInfo> ais = aim.get(key);
+        for (Map.Entry<QName, Collection<AssertionInfo>> entry : aim.entrySet())
{
+            String namespace = entry.getKey().getNamespaceURI();
+            if (SP11Constants.SP_NS.equals(namespace) || SP12Constants.SP_NS.equals(namespace)
+                || SP13Constants.SP_NS.equals(namespace)) {
+                Collection<AssertionInfo> ais = entry.getValue();
                 if (ais != null && !ais.isEmpty()) {
-                    for (AssertionInfo ai : ais) {
-                        ai.setAsserted(true);
+                    if (SPConstants.ALGORITHM_SUITE.equals(entry.getKey().getLocalPart()))
{
+                        assertAlgorithmSuites(ais, aim);
+                    } else {
+                        for (AssertionInfo ai : ais) {
+                            ai.setAsserted(true);
+                        }
                     }
                 }
             }
         }
-        
     }
     
-    private void assertAllAlgorithmSuites(String spNamespace, AssertionInfoMap aim) {
-        Collection<AssertionInfo> sp11Ais = 
-            aim.get(new QName(spNamespace, SPConstants.ALGORITHM_SUITE));
-        if (sp11Ais != null && !sp11Ais.isEmpty()) {
-            for (AssertionInfo ai : sp11Ais) {
-                ai.setAsserted(true);
-                AlgorithmSuite algorithmSuite = (AlgorithmSuite)ai.getAssertion();
-                AlgorithmSuiteType algorithmSuiteType = algorithmSuite.getAlgorithmSuiteType();
-                String namespace = algorithmSuiteType.getNamespace();
-                if (namespace == null) {
-                    namespace = spNamespace;
-                }
+    // Handle these separately for custom AlgorithmSuites
+    private void assertAlgorithmSuites(
+        Collection<AssertionInfo> ais, AssertionInfoMap aim
+    ) {
+        for (AssertionInfo ai : ais) {
+            ai.setAsserted(true);
+            AlgorithmSuite algorithmSuite = (AlgorithmSuite)ai.getAssertion();
+       
+            AlgorithmSuiteType algorithmSuiteType = algorithmSuite.getAlgorithmSuiteType();
+            String namespace = algorithmSuiteType.getNamespace();
+            if (namespace != null && !namespace.equals(algorithmSuite.getName().getNamespaceURI()))
{
                 Collection<AssertionInfo> algAis = 
                     aim.get(new QName(namespace, algorithmSuiteType.getName()));
                 if (algAis != null && !algAis.isEmpty()) {


Mime
View raw message