cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1170827 - in /cxf/trunk/rt/ws/security/src: main/java/org/apache/cxf/ws/security/policy/model/ test/java/org/apache/cxf/ws/security/wss4j/
Date Wed, 14 Sep 2011 19:59:31 GMT
Author: dkulp
Date: Wed Sep 14 19:59:31 2011
New Revision: 1170827

URL: http://svn.apache.org/viewvc?rev=1170827&view=rev
Log:
Remove some "cxf specific" stuff from the security policy model that
isn't needed anymore.

Modified:
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/AbstractSecurityAssertion.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TokenWrapper.java
    cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractPolicySecurityTest.java

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/AbstractSecurityAssertion.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/AbstractSecurityAssertion.java?rev=1170827&r1=1170826&r2=1170827&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/AbstractSecurityAssertion.java
(original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/AbstractSecurityAssertion.java
Wed Sep 14 19:59:31 2011
@@ -18,15 +18,11 @@
  */
 package org.apache.cxf.ws.security.policy.model;
 
-import java.util.Collection;
-
-import org.apache.cxf.ws.policy.AssertionInfo;
-import org.apache.cxf.ws.policy.AssertionInfoMap;
-import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.security.policy.SPConstants;
+import org.apache.neethi.Assertion;
 import org.apache.neethi.PolicyComponent;
 
-public abstract class AbstractSecurityAssertion implements PolicyAssertion {
+public abstract class AbstractSecurityAssertion implements Assertion {
     protected final SPConstants constants;
 
     private boolean isOptional;
@@ -74,14 +70,5 @@ public abstract class AbstractSecurityAs
     public PolicyComponent normalize() {
         return this;
     }
-    
-    public boolean isAsserted(AssertionInfoMap aim) {
-        Collection<AssertionInfo> ail = aim.getAssertionInfo(getName());
-        for (AssertionInfo ai : ail) {
-            if (ai.isAsserted() && ai.getAssertion() == this) {
-                return true;
-            }
-        }
-        return false;
-    }
+
 }

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TokenWrapper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TokenWrapper.java?rev=1170827&r1=1170826&r2=1170827&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TokenWrapper.java
(original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TokenWrapper.java
Wed Sep 14 19:59:31 2011
@@ -19,17 +19,17 @@
 package org.apache.cxf.ws.security.policy.model;
 
 
-import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.policy.PolicyBuilder;
 import org.apache.cxf.ws.security.policy.SPConstants;
 import org.apache.neethi.All;
+import org.apache.neethi.Assertion;
 import org.apache.neethi.ExactlyOne;
 import org.apache.neethi.Policy;
 import org.apache.neethi.PolicyComponent;
 import org.apache.neethi.PolicyContainingAssertion;
 
 public abstract class TokenWrapper extends AbstractSecurityAssertion 
-    implements PolicyAssertion, PolicyContainingAssertion {
+    implements Assertion, PolicyContainingAssertion {
     protected PolicyBuilder builder;
     protected Token token;
 

Modified: cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractPolicySecurityTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractPolicySecurityTest.java?rev=1170827&r1=1170826&r2=1170827&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractPolicySecurityTest.java
(original)
+++ cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractPolicySecurityTest.java
Wed Sep 14 19:59:31 2011
@@ -55,7 +55,6 @@ import org.apache.cxf.service.model.Endp
 import org.apache.cxf.transport.MessageObserver;
 import org.apache.cxf.ws.policy.AssertionInfo;
 import org.apache.cxf.ws.policy.AssertionInfoMap;
-import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.policy.PolicyBuilder;
 import org.apache.cxf.ws.policy.PolicyException;
 import org.apache.cxf.ws.security.SecurityConstants;
@@ -195,8 +194,7 @@ public abstract class AbstractPolicySecu
                     Collection<AssertionInfo> ais = aim.get(assertionType);
                     assertNotNull(ais);
                     for (AssertionInfo ai : ais) {
-                        assertTrue(assertionType + " policy erroneously failed.",
-                                ((PolicyAssertion)ai.getAssertion()).isAsserted(aim));
+                        checkAssertion(aim, assertionType, ai, true);
                     }
                 }
             }
@@ -206,14 +204,32 @@ public abstract class AbstractPolicySecu
                     Collection<AssertionInfo> ais = aim.get(assertionType);
                     assertNotNull(ais);
                     for (AssertionInfo ai : ais) {
-                        assertFalse(assertionType + " policy erroneously asserted.",
-                                    ((PolicyAssertion)ai.getAssertion()).isAsserted(aim));
+                        checkAssertion(aim, assertionType, ai, false);
                     }
                 }
             }
         }
     }
     
+    private void checkAssertion(AssertionInfoMap aim, 
+                                QName name,
+                                AssertionInfo inf,
+                                boolean asserted) {
+        boolean pass = true;
+        Collection<AssertionInfo> ail = aim.getAssertionInfo(name);
+        for (AssertionInfo ai : ail) {
+            if (ai.getAssertion().equal(inf.getAssertion())
+                && !ai.isAsserted() && !inf.getAssertion().isOptional())
{
+                pass = false;                    
+            }
+        }
+        if (asserted) {
+            assertTrue(name + " policy erroneously failed.", pass);
+        } else {
+            assertFalse(name + " policy erroneously asserted.", pass);            
+        }
+    }
+    
     protected void runInInterceptorAndValidateWss(Document document, AssertionInfoMap aim,
             List<CoverageType> types) throws Exception {
         
@@ -269,8 +285,7 @@ public abstract class AbstractPolicySecu
                     Collection<AssertionInfo> ais = aim.get(assertionType);
                     assertNotNull(ais);
                     for (AssertionInfo ai : ais) {
-                        assertTrue(assertionType + " policy erroneously failed.",
-                                   ((PolicyAssertion)ai.getAssertion()).isAsserted(aim));
+                        checkAssertion(aim, assertionType, ai, true);
                     }
                 }
             }
@@ -280,8 +295,7 @@ public abstract class AbstractPolicySecu
                     Collection<AssertionInfo> ais = aim.get(assertionType);
                     assertNotNull(ais);
                     for (AssertionInfo ai : ais) {
-                        assertFalse(assertionType + " policy erroneously asserted.",
-                                    ((PolicyAssertion)ai.getAssertion()).isAsserted(aim));
+                        checkAssertion(aim, assertionType, ai, false);
                     }
                 }
             }



Mime
View raw message