ws-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wer...@apache.org
Subject svn commit: r355506 - in /webservices/commons/trunk/policy/src/examples: SimplePolicyExample.java WSSPolicyProcessor.java policy2.xml
Date Fri, 09 Dec 2005 14:47:14 GMT
Author: werner
Date: Fri Dec  9 06:47:09 2005
New Revision: 355506

URL: http://svn.apache.org/viewcvs?rev=355506&view=rev
Log:
Fix examples to use the new structure of PolicyReader and
PolicyWriter. Add wsu:Id attribute to policy2.xml to show
if it works.

Modified:
    webservices/commons/trunk/policy/src/examples/SimplePolicyExample.java
    webservices/commons/trunk/policy/src/examples/WSSPolicyProcessor.java
    webservices/commons/trunk/policy/src/examples/policy2.xml

Modified: webservices/commons/trunk/policy/src/examples/SimplePolicyExample.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/policy/src/examples/SimplePolicyExample.java?rev=355506&r1=355505&r2=355506&view=diff
==============================================================================
--- webservices/commons/trunk/policy/src/examples/SimplePolicyExample.java (original)
+++ webservices/commons/trunk/policy/src/examples/SimplePolicyExample.java Fri Dec  9 06:47:09
2005
@@ -20,10 +20,9 @@
 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.PolicyReader;
 import org.apache.ws.policy.util.PolicyFactory;
-import org.apache.ws.policy.util.StAXPolicyWriter;
+import org.apache.ws.policy.util.PolicyWriter;
 
 /**
  * @author Werner Dittmann (werner@apache.org)
@@ -40,10 +39,10 @@
             fis = new FileInputStream("policy/src/examples/policy2.xml");
         }
 
-        OMPolicyReader prdr = (OMPolicyReader) PolicyFactory
-                .getPolicyReader(PolicyFactory.DOM_POLICY_READER);
-        StAXPolicyWriter pwrt = (StAXPolicyWriter) PolicyFactory
-                .getPolicyWriter();
+        PolicyReader prdr = PolicyFactory
+                .getPolicyReader(PolicyFactory.OM_POLICY_READER);
+        PolicyWriter pwrt = PolicyFactory
+                .getPolicyWriter(PolicyFactory.StAX_POLICY_WRITER);
 
         Policy argOne = prdr.readPolicy(fis);
         Policy norm = (Policy) argOne.normalize();
@@ -51,6 +50,8 @@
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         pwrt.writePolicy(norm, baos);
 
+        System.out.println("Policy Id: " + norm.getId());
+        System.out.println("Policy base: " + norm.getBase());
         System.out.println(baos.toString());
         System.out.println("-----\n");
 
@@ -63,15 +64,17 @@
         } else {
             fis = new FileInputStream("policy/src/examples/policy2.xml");
         }
-        DOMPolicyReader readerDom = (DOMPolicyReader) PolicyFactory
+        prdr = PolicyFactory
                 .getPolicyReader(PolicyFactory.DOM_POLICY_READER);
 
-        Policy pDom = readerDom.readPolicy(fis);
-        Policy normDom = (Policy) pDom.normalize();
+        argOne = prdr.readPolicy(fis);
+        norm = (Policy) argOne.normalize();
 
         baos = new ByteArrayOutputStream();
-        pwrt.writePolicy(normDom, baos);
+        pwrt.writePolicy(norm, baos);
 
+        System.out.println("Policy Id: " + norm.getId());
+        System.out.println("Policy base: " + norm.getBase());
         System.out.println(baos.toString());
 
         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=355506&r1=355505&r2=355506&view=diff
==============================================================================
--- webservices/commons/trunk/policy/src/examples/WSSPolicyProcessor.java (original)
+++ webservices/commons/trunk/policy/src/examples/WSSPolicyProcessor.java Fri Dec  9 06:47:09
2005
@@ -25,8 +25,7 @@
 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.PolicyReader;
 import org.apache.ws.policy.util.PolicyFactory;
 
 /**
@@ -60,16 +59,16 @@
         /*
          * Use the Stream based parser, Axis2 OM  
          */
-        OMPolicyReader readerOm = (OMPolicyReader) PolicyFactory.getPolicyReader(PolicyFactory.OM_POLICY_READER);
-        Policy p = readerOm
+        PolicyReader reader = PolicyFactory.getPolicyReader(PolicyFactory.OM_POLICY_READER);
+        Policy p = reader
                 .readPolicy(new ByteArrayInputStream(policy.getBytes()));
         process.processPolicy((Policy) p.normalize());
         
         /*
          * Use standard Parser, w3c DOM
          */
-        DOMPolicyReader readerDom = (DOMPolicyReader) PolicyFactory.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
-        Policy pDom = readerDom
+        reader = PolicyFactory.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
+        Policy pDom = reader
                 .readPolicy(new ByteArrayInputStream(policy.getBytes()));
         process.processPolicy((Policy) pDom.normalize());
     }

Modified: webservices/commons/trunk/policy/src/examples/policy2.xml
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/policy/src/examples/policy2.xml?rev=355506&r1=355505&r2=355506&view=diff
==============================================================================
--- webservices/commons/trunk/policy/src/examples/policy2.xml (original)
+++ webservices/commons/trunk/policy/src/examples/policy2.xml Fri Dec  9 06:47:09 2005
@@ -1,5 +1,6 @@
-<wsp:Policy xml:base="uri:thisBase" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
-            xmlns:sec="http://schemas.xmlsoap.org/ws/2002/12/secext" >
+<wsp:Policy xml:base="uri:thisBase" wsu:Id="myPolicy" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+            xmlns:sec="http://schemas.xmlsoap.org/ws/2002/12/secext"
+            xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
>
   <!-- 2 -->
   <sec:SecurityToken>
     <sec:TokenType>sec:X509v3</sec:TokenType>



Mime
View raw message