ws-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r355490 - in /webservices/commons/trunk/policy: interop/ibm/src/org/apache/ws/policy/interop/ src/examples/ test/ test/org/ test/org/apache/ test/org/apache/ws/ test/org/apache/ws/policy/ test/org/apache/ws/policy/util/
Date Fri, 09 Dec 2005 13:55:36 GMT
Author: sanka
Date: Fri Dec  9 05:55:22 2005
New Revision: 355490

URL: http://svn.apache.org/viewcvs?rev=355490&view=rev
Log:
Adding PolicyComparatot which is a utility class for policy comparison

Added:
    webservices/commons/trunk/policy/test/
    webservices/commons/trunk/policy/test/org/
    webservices/commons/trunk/policy/test/org/apache/
    webservices/commons/trunk/policy/test/org/apache/ws/
    webservices/commons/trunk/policy/test/org/apache/ws/policy/
    webservices/commons/trunk/policy/test/org/apache/ws/policy/util/
    webservices/commons/trunk/policy/test/org/apache/ws/policy/util/PolicyComparator.java
Modified:
    webservices/commons/trunk/policy/interop/ibm/src/org/apache/ws/policy/interop/SimplePolicyService.java
    webservices/commons/trunk/policy/src/examples/SimplePolicyExample.java
    webservices/commons/trunk/policy/src/examples/WSSPolicyProcessor.java

Modified: webservices/commons/trunk/policy/interop/ibm/src/org/apache/ws/policy/interop/SimplePolicyService.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/policy/interop/ibm/src/org/apache/ws/policy/interop/SimplePolicyService.java?rev=355490&r1=355489&r2=355490&view=diff
==============================================================================
--- webservices/commons/trunk/policy/interop/ibm/src/org/apache/ws/policy/interop/SimplePolicyService.java
(original)
+++ webservices/commons/trunk/policy/interop/ibm/src/org/apache/ws/policy/interop/SimplePolicyService.java
Fri Dec  9 05:55:22 2005
@@ -38,7 +38,6 @@
 import org.apache.ws.policy.util.PolicyReader;
 import org.apache.ws.policy.util.PolicyWriter;
 
-
 /**
  * @author Sanka Samaranayake (sanka@apache.org)
  */
@@ -101,11 +100,11 @@
     }
 
     private PolicyReader getReader() {
-        return PolicyFactory.getInstance().getPolicyReader();
+        return PolicyFactory.getPolicyReader(PolicyFactory.OM_POLICY_READER);
     }
 
     private PolicyWriter getWriter() {
-        return PolicyFactory.getInstance().getPolicyWriter();
+        return PolicyFactory.getPolicyWriter();
     }
 
     private OMElement getWholeElement(OMElement element) {

Modified: webservices/commons/trunk/policy/src/examples/SimplePolicyExample.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/policy/src/examples/SimplePolicyExample.java?rev=355490&r1=355489&r2=355490&view=diff
==============================================================================
--- webservices/commons/trunk/policy/src/examples/SimplePolicyExample.java (original)
+++ webservices/commons/trunk/policy/src/examples/SimplePolicyExample.java Fri Dec  9 05:55:22
2005
@@ -16,15 +16,14 @@
 
 package examples;
 
-import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.FileInputStream;
 
 import org.apache.ws.policy.model.Policy;
+import org.apache.ws.policy.util.DOMPolicyReader;
+import org.apache.ws.policy.util.OMPolicyReader;
 import org.apache.ws.policy.util.PolicyFactory;
-import org.apache.ws.policy.util.PolicyReader;
-import org.apache.ws.policy.util.PolicyReaderDOM;
-import org.apache.ws.policy.util.PolicyWriter;
+import org.apache.ws.policy.util.StAXPolicyWriter;
 
 /**
  * @author Werner Dittmann (werner@apache.org)
@@ -32,49 +31,50 @@
 
 public class SimplePolicyExample {
 
-	public static void main(String[] args) throws Exception {
+    public static void main(String[] args) throws Exception {
+
+        FileInputStream fis = null;
+        if (args.length > 0) {
+            fis = new FileInputStream(args[0]);
+        } else {
+            fis = new FileInputStream("policy/src/examples/policy2.xml");
+        }
+
+        OMPolicyReader prdr = (OMPolicyReader) PolicyFactory
+                .getPolicyReader(PolicyFactory.DOM_POLICY_READER);
+        StAXPolicyWriter pwrt = (StAXPolicyWriter) PolicyFactory
+                .getPolicyWriter();
+
+        Policy argOne = prdr.readPolicy(fis);
+        Policy norm = (Policy) argOne.normalize();
 
-		FileInputStream fis = null;
-		if (args.length > 0) {
-			fis = new FileInputStream(args[0]);			
-		}
-		else {
-			fis = new FileInputStream("policy/src/examples/policy2.xml");
-		}
-
-		PolicyReader prdr = PolicyFactory.getInstance().getPolicyReader();
-	    PolicyWriter pwrt = PolicyFactory.getInstance().getPolicyWriter();
-	    
-	    Policy argOne = prdr.readPolicy(fis);
-	    Policy norm  = (Policy)argOne.normalize();
-	    
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         pwrt.writePolicy(norm, baos);
 
         System.out.println(baos.toString());
         System.out.println("-----\n");
 
-		fis.close();
+        fis.close();
         /*
          * Use standard Parser, w3c DOM
          */
-		if (args.length > 0) {
-			fis = new FileInputStream(args[0]);			
-		}
-		else {
-			fis = new FileInputStream("policy/src/examples/policy2.xml");
-		}
-        PolicyReaderDOM readerDom = PolicyFactory.getInstance().getPolicyReaderDOM();
+        if (args.length > 0) {
+            fis = new FileInputStream(args[0]);
+        } else {
+            fis = new FileInputStream("policy/src/examples/policy2.xml");
+        }
+        DOMPolicyReader readerDom = (DOMPolicyReader) PolicyFactory
+                .getPolicyReader(PolicyFactory.DOM_POLICY_READER);
+
         Policy pDom = readerDom.readPolicy(fis);
-	    Policy normDom  = (Policy)pDom.normalize();
-	    
+        Policy normDom = (Policy) pDom.normalize();
+
         baos = new ByteArrayOutputStream();
         pwrt.writePolicy(normDom, baos);
 
-		System.out.println(baos.toString());
+        System.out.println(baos.toString());
 
-		fis.close();
-	
-	}
-}
+        fis.close();
 
+    }
+}

Modified: webservices/commons/trunk/policy/src/examples/WSSPolicyProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/policy/src/examples/WSSPolicyProcessor.java?rev=355490&r1=355489&r2=355490&view=diff
==============================================================================
--- webservices/commons/trunk/policy/src/examples/WSSPolicyProcessor.java (original)
+++ webservices/commons/trunk/policy/src/examples/WSSPolicyProcessor.java Fri Dec  9 05:55:22
2005
@@ -25,9 +25,9 @@
 import org.apache.ws.policy.model.Policy;
 import org.apache.ws.policy.model.PrimitiveAssertion;
 import org.apache.ws.policy.model.XorCompositeAssertion;
+import org.apache.ws.policy.util.DOMPolicyReader;
+import org.apache.ws.policy.util.OMPolicyReader;
 import org.apache.ws.policy.util.PolicyFactory;
-import org.apache.ws.policy.util.PolicyReader;
-import org.apache.ws.policy.util.PolicyReaderDOM;
 
 /**
  * @author Sanka Samaranayake (sanka@apache.org)
@@ -60,15 +60,15 @@
         /*
          * Use the Stream based parser, Axis2 OM  
          */
-        PolicyReader reader = PolicyFactory.getInstance().getPolicyReader();
-        Policy p = reader
+        OMPolicyReader readerOm = (OMPolicyReader) PolicyFactory.getPolicyReader(PolicyFactory.OM_POLICY_READER);
+        Policy p = readerOm
                 .readPolicy(new ByteArrayInputStream(policy.getBytes()));
         process.processPolicy((Policy) p.normalize());
         
         /*
          * Use standard Parser, w3c DOM
          */
-        PolicyReaderDOM readerDom = PolicyFactory.getInstance().getPolicyReaderDOM();
+        DOMPolicyReader readerDom = (DOMPolicyReader) PolicyFactory.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
         Policy pDom = readerDom
                 .readPolicy(new ByteArrayInputStream(policy.getBytes()));
         process.processPolicy((Policy) pDom.normalize());

Added: webservices/commons/trunk/policy/test/org/apache/ws/policy/util/PolicyComparator.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/policy/test/org/apache/ws/policy/util/PolicyComparator.java?rev=355490&view=auto
==============================================================================
--- webservices/commons/trunk/policy/test/org/apache/ws/policy/util/PolicyComparator.java
(added)
+++ webservices/commons/trunk/policy/test/org/apache/ws/policy/util/PolicyComparator.java
Fri Dec  9 05:55:22 2005
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ws.policy.util;
+
+import org.apache.ws.policy.model.Assertion;
+import org.apache.ws.policy.model.PrimitiveAssertion;
+
+/**
+ * @author Sanka Samaranayake (sanka@apache.org)
+ */
+public class PolicyComparator {
+    public static boolean compare(Assertion arg1, Assertion arg2) {
+        
+        
+       return true;
+    }
+    
+    public static boolean compare(PrimitiveAssertion prim1, PrimitiveAssertion prim2) {
+        if (!(prim1.getName().equals(prim2.getName()))) {
+            return false;
+        } 
+        
+        String value1 = prim1.getStrValue();
+        String value2 = prim2.getStrValue();
+        
+        //if (value1 == null  value2 != null )
+        return true;
+        
+    }
+    
+}



Mime
View raw message