Added: 
webservices/commons/trunk/policy/src/examples/secParser/processors/SignedPartsElementsProcessor.java
URL: 
http://svn.apache.org/viewcvs/webservices/commons/trunk/policy/src/examples/secParser/processors/SignedPartsElementsProcessor.java?rev=368034&view=auto
==============================================================================
--- 
webservices/commons/trunk/policy/src/examples/secParser/processors/SignedPartsElementsProcessor.java
 (added)
+++ 
webservices/commons/trunk/policy/src/examples/secParser/processors/SignedPartsElementsProcessor.java
 Wed Jan 11 06:57:47 2006
@@ -0,0 +1,173 @@
+/*
+ * 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 examples.secParser.processors;
+
+import org.apache.ws.policy.PrimitiveAssertion;
+
+import examples.secParser.SecurityPolicy;
+import examples.secParser.SecurityPolicyToken;
+import examples.secParser.SecurityProcessorContext;
+
+/**
+ * @author Werner Dittmann ([EMAIL PROTECTED])
+ */
+
+public class SignedPartsElementsProcessor {
+
+       private boolean initializedSignedParts = false;
+
+       private boolean initializedSignedElements = false;
+
+       public SignedPartsElementsProcessor() {
+       }
+
+       /**
+        * Intialize the SignedParts complex token.
+        * 
+        * This method creates copies of the child tokens that are allowed for
+        * SignedParts. These tokens are Body and Header. These copies are
+        * initialized with handler object and then set as child tokens of
+        * SignedParts. <p/> The handler object must define the methods
+        * <code>doSignedParts, doBody, doHeader</code>.
+        * 
+        * @param spt
+        *            The token that will hold the child tokens.
+        * @throws NoSuchMethodException
+        */
+       private void initializeSignedParts(SecurityPolicyToken spt)
+                       throws NoSuchMethodException {
+               SecurityPolicyToken tmpSpt = SecurityPolicy.body.copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.header.copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+
+       }
+
+       /**
+        * Intialize the SignedElements complex token.
+        * 
+        * This method creates a copy of the child token that is allowed for
+        * SignedElements. The token is XPath. This copy is initialized with a
+        * handler object and then set as child token of SignedElements. <p/> 
The
+        * handler object must define the method <code>doXPath</code>.
+        * 
+        * @param spt
+        *            The token that will hold the child tokens.
+        * @throws NoSuchMethodException
+        */
+       private void initializeSignedElements(SecurityPolicyToken spt)
+                       throws NoSuchMethodException {
+               SecurityPolicyToken tmpSpt = SecurityPolicy.xPath.copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+       }
+
+       public Object doSignedParts(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+
+               SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+
+               switch (spc.getAction()) {
+
+               case SecurityProcessorContext.START:
+                       if (!initializedSignedParts) {
+                               try {
+                                       initializeSignedParts(spt);
+                                       initializedSignedParts = true;
+                               } catch (NoSuchMethodException e) {
+                                       // TODO Auto-generated catch block
+                                       e.printStackTrace();
+                                       return new Boolean(false);
+                               }
+                       }
+                       System.out.println(spt.getTokenName());
+                       PrimitiveAssertion pa = spc.getAssertion();
+                       String text = pa.getStrValue();
+                       if (text != null) {
+                               text = text.trim();
+                               System.out.println("Value: '" + text.toString() 
+ "'");
+                       }
+               case SecurityProcessorContext.COMMIT:
+                       break;
+               case SecurityProcessorContext.ABORT:
+                       break;
+               }
+               return new Boolean(true);
+       }
+
+       public Object doSignedElements(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+
+               SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+
+               switch (spc.getAction()) {
+
+               case SecurityProcessorContext.START:
+                       if (!initializedSignedElements) {
+                               try {
+                                       initializeSignedElements(spt);
+                                       initializedSignedElements = true;
+                               } catch (NoSuchMethodException e) {
+                                       // TODO Auto-generated catch block
+                                       e.printStackTrace();
+                                       return new Boolean(false);
+                               }
+                       }
+                       System.out.println(spt.getTokenName());
+                       PrimitiveAssertion pa = spc.getAssertion();
+                       String text = pa.getStrValue();
+                       if (text != null) {
+                               text = text.trim();
+                               System.out.println("Value: '" + text.toString() 
+ "'");
+                       }
+               case SecurityProcessorContext.COMMIT:
+                       break;
+               case SecurityProcessorContext.ABORT:
+                       break;
+               }
+               return new Boolean(true);
+       }
+
+       public Object doBody(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               return new Boolean(true);
+       }
+
+       public Object doHeader(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               return new Boolean(true);
+       }
+
+       public Object doXPath(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               return new Boolean(true);
+       }
+
+}

Added: 
webservices/commons/trunk/policy/src/examples/secParser/processors/SignedSupportingTokensProcessor.java
URL: 
http://svn.apache.org/viewcvs/webservices/commons/trunk/policy/src/examples/secParser/processors/SignedSupportingTokensProcessor.java?rev=368034&view=auto
==============================================================================
--- 
webservices/commons/trunk/policy/src/examples/secParser/processors/SignedSupportingTokensProcessor.java
 (added)
+++ 
webservices/commons/trunk/policy/src/examples/secParser/processors/SignedSupportingTokensProcessor.java
 Wed Jan 11 06:57:47 2006
@@ -0,0 +1,106 @@
+/*
+ * 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 examples.secParser.processors;
+
+import java.lang.reflect.InvocationTargetException;
+
+import examples.secParser.SecurityPolicy;
+import examples.secParser.SecurityPolicyToken;
+import examples.secParser.SecurityProcessorContext;
+
+/**
+ * @author Werner Dittmann ([EMAIL PROTECTED])
+ * 
+ */
+public class SignedSupportingTokensProcessor {
+       private boolean initializedSignedSupportingTokens = false;
+
+       /**
+        * Intialize the SignedSupportingTokens complex token.
+        * 
+        * This method creates a copy of the SignedSupportingTokens token and 
sets the
+        * handler object to the copy. Then it creates copies of the child 
tokens
+        * that are allowed for SignedSupportingTokens. These tokens are:
+        * 
+        * These copies are also initialized with the handler object and then 
set as
+        * child tokens of SignedSupportingTokens.
+        * 
+        * @param spt
+        *            The token that will hold the child tokens.
+        * @throws NoSuchMethodException
+        */
+       private void initializeSignedSupportingTokens(SecurityPolicyToken spt)
+                       throws NoSuchMethodException {
+               SecurityPolicyToken tmpSpt = SecurityPolicy.x509Token.copy();
+               tmpSpt.setProcessTokenMethod(new X509TokenProcessor());
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.usernameToken.copy();
+               tmpSpt.setProcessTokenMethod(new UsernameTokenProcessor());
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.algorithmSuite.copy();
+               tmpSpt.setProcessTokenMethod(new AlgorithmSuiteProcessor());
+               spt.setChildToken(tmpSpt);
+
+               SignedPartsElementsProcessor spep = new 
SignedPartsElementsProcessor();
+               tmpSpt = SecurityPolicy.signedParts.copy();
+               tmpSpt.setProcessTokenMethod(spep);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.signedElements.copy();
+               tmpSpt.setProcessTokenMethod(spep);
+               spt.setChildToken(tmpSpt);
+
+               EncryptedPartsElementsProcessor epep = new 
EncryptedPartsElementsProcessor();
+               tmpSpt = SecurityPolicy.encryptedParts.copy();
+               tmpSpt.setProcessTokenMethod(epep);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.encryptedElements.copy();
+               tmpSpt.setProcessTokenMethod(epep);
+               spt.setChildToken(tmpSpt);
+
+       }
+
+       public Object doSignedSupportingTokens(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+
+               switch (spc.getAction()) {
+
+               case SecurityProcessorContext.START:
+                       if (!initializedSignedSupportingTokens) {
+                               try {
+                                       initializeSignedSupportingTokens(spt);
+                                       initializedSignedSupportingTokens = 
true;
+                               } catch (NoSuchMethodException e) {
+                                       // TODO Auto-generated catch block
+                                       e.printStackTrace();
+                                       return new Boolean(false);
+                               }
+                       }
+                       break;
+               case SecurityProcessorContext.COMMIT:
+                       break;
+               case SecurityProcessorContext.ABORT:
+                       break;
+               }
+               return new Boolean(true);
+       }
+}

Added: 
webservices/commons/trunk/policy/src/examples/secParser/processors/SupportingTokensProcessor.java
URL: 
http://svn.apache.org/viewcvs/webservices/commons/trunk/policy/src/examples/secParser/processors/SupportingTokensProcessor.java?rev=368034&view=auto
==============================================================================
--- 
webservices/commons/trunk/policy/src/examples/secParser/processors/SupportingTokensProcessor.java
 (added)
+++ 
webservices/commons/trunk/policy/src/examples/secParser/processors/SupportingTokensProcessor.java
 Wed Jan 11 06:57:47 2006
@@ -0,0 +1,105 @@
+/*
+ * 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 examples.secParser.processors;
+
+import examples.secParser.SecurityPolicy;
+import examples.secParser.SecurityPolicyToken;
+import examples.secParser.SecurityProcessorContext;
+
+/**
+ * @author Werner Dittmann ([EMAIL PROTECTED])
+ * 
+ */
+public class SupportingTokensProcessor {
+       private boolean initializedSupportingTokens = false;
+
+       /**
+        * Intialize the SupportingTokens complex token.
+        * 
+        * This method creates a copy of the SupportingTokens token and sets the
+        * handler object to the copy. Then it creates copies of the child 
tokens
+        * that are allowed for SupportingTokens. These tokens are:
+        * 
+        * These copies are also initialized with the handler object and then 
set as
+        * child tokens of SupportingTokens.
+        * 
+        * @param spt
+        *            The token that will hold the child tokens.
+        * @throws NoSuchMethodException
+        */
+       private void initializeSupportingTokens(SecurityPolicyToken spt)
+                       throws NoSuchMethodException {
+               SecurityPolicyToken tmpSpt = SecurityPolicy.x509Token.copy();
+               tmpSpt.setProcessTokenMethod(new X509TokenProcessor());
+               spt.setChildToken(tmpSpt);
+               
+               tmpSpt = SecurityPolicy.usernameToken.copy();
+               tmpSpt.setProcessTokenMethod(new UsernameTokenProcessor());
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.algorithmSuite.copy();
+               tmpSpt.setProcessTokenMethod(new AlgorithmSuiteProcessor());
+               spt.setChildToken(tmpSpt);
+
+               SignedPartsElementsProcessor spep = new 
SignedPartsElementsProcessor();
+               tmpSpt = SecurityPolicy.signedParts.copy();
+               tmpSpt.setProcessTokenMethod(spep);
+               spt.setChildToken(tmpSpt);
+               
+               tmpSpt = SecurityPolicy.signedElements.copy();
+               tmpSpt.setProcessTokenMethod(spep);             
+               spt.setChildToken(tmpSpt);
+
+               EncryptedPartsElementsProcessor epep = new 
EncryptedPartsElementsProcessor();
+               tmpSpt = SecurityPolicy.encryptedParts.copy();
+               tmpSpt.setProcessTokenMethod(epep);
+               spt.setChildToken(tmpSpt);
+               
+               tmpSpt = SecurityPolicy.encryptedElements.copy();
+               tmpSpt.setProcessTokenMethod(epep);
+               spt.setChildToken(tmpSpt);
+
+       }
+
+       public Object doSupportingTokens(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+
+               switch (spc.getAction()) {
+
+               case SecurityProcessorContext.START:
+                       if (!initializedSupportingTokens) {
+                               try {
+                                       initializeSupportingTokens(spt);
+                                       initializedSupportingTokens = true;
+                               } catch (NoSuchMethodException e) {
+                                       // TODO Auto-generated catch block
+                                       e.printStackTrace();
+                                       return new Boolean(false);
+                               }
+                       }
+                       break;
+               case SecurityProcessorContext.COMMIT:
+                       break;
+               case SecurityProcessorContext.ABORT:
+                       break;
+               }
+               return new Boolean(true);
+       }
+
+}

Added: 
webservices/commons/trunk/policy/src/examples/secParser/processors/SymmetricBindingProcessor.java
URL: 
http://svn.apache.org/viewcvs/webservices/commons/trunk/policy/src/examples/secParser/processors/SymmetricBindingProcessor.java?rev=368034&view=auto
==============================================================================
--- 
webservices/commons/trunk/policy/src/examples/secParser/processors/SymmetricBindingProcessor.java
 (added)
+++ 
webservices/commons/trunk/policy/src/examples/secParser/processors/SymmetricBindingProcessor.java
 Wed Jan 11 06:57:47 2006
@@ -0,0 +1,167 @@
+/*
+ * 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 examples.secParser.processors;
+
+import examples.secParser.SecurityPolicy;
+import examples.secParser.SecurityPolicyToken;
+import examples.secParser.SecurityProcessorContext;
+
+/**
+ * @author Werner Dittmann ([EMAIL PROTECTED])
+ * 
+ */
+public class SymmetricBindingProcessor {
+       private boolean initializedSymmetricBinding = false;
+
+       /**
+        * Intialize the SymmetricBinding complex token.
+        * 
+        * This method creates a copy of the SymmetricBinding token and sets the
+        * handler object to the copy. Then it creates copies of the child 
tokens
+        * that are allowed for SymmetricBinding. These tokens are:
+        * 
+        * These copies are also initialized with the handler object and then 
set as
+        * child tokens of SymmetricBinding.
+        * 
+        * @param spt
+        *            The token that will hold the child tokens.
+        * @throws NoSuchMethodException
+        */
+       private void initializeSymmetricBinding(SecurityPolicyToken spt)
+                       throws NoSuchMethodException {
+
+               SignEncProtectTokenProcessor sept = new 
SignEncProtectTokenProcessor();
+               SecurityPolicyToken tmpSpt = 
SecurityPolicy.encryptionToken.copy();
+               tmpSpt.setProcessTokenMethod(sept);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.signatureToken.copy();
+               tmpSpt.setProcessTokenMethod(sept);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.protectionToken.copy();
+               tmpSpt.setProcessTokenMethod(sept);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.algorithmSuite.copy();
+               tmpSpt.setProcessTokenMethod(new AlgorithmSuiteProcessor());
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.layout.copy();
+               tmpSpt.setProcessTokenMethod(new LayoutProcessor());
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.supportingTokens.copy();
+               tmpSpt.setProcessTokenMethod(new SupportingTokensProcessor());
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.signedSupportingTokens.copy();
+               tmpSpt.setProcessTokenMethod(new 
SignedSupportingTokensProcessor());
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.endorsingSupportingTokens.copy();
+               tmpSpt.setProcessTokenMethod(new 
EndorsingSupportingTokensProcessor());
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.signedEndorsingSupportingTokens.copy();
+               tmpSpt.setProcessTokenMethod(new 
SignedEndorsingSupportingTokensProcessor());
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.includeTimestamp.copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.encryptBeforeSigning.copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.encryptSignature.copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.protectTokens.copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.onlySignEntireHeadersAndBody.copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+
+       }
+
+       public Object doSymmetricBinding(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+
+               switch (spc.getAction()) {
+
+               case SecurityProcessorContext.START:
+                       if (!initializedSymmetricBinding) {
+                               try {
+                                       initializeSymmetricBinding(spt);
+                                       initializedSymmetricBinding = true;
+                               } catch (NoSuchMethodException e) {
+                                       // TODO Auto-generated catch block
+                                       e.printStackTrace();
+                                       return new Boolean(false);
+                               }
+                       }
+                       break;
+               case SecurityProcessorContext.COMMIT:
+                       break;
+               case SecurityProcessorContext.ABORT:
+                       break;
+               }
+               return new Boolean(true);
+       }
+
+       public Object doIncludeTimestamp(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               return new Boolean(true);
+       }
+
+       public Object doEncryptBeforeSigning(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               return new Boolean(true);
+       }
+
+       public Object doEncryptSignature(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               return new Boolean(true);
+       }
+
+       public Object doProtectTokens(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               return new Boolean(true);
+       }
+
+       public Object doOnlySignEntireHeadersAndBody(SecurityProcessorContext 
spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               return new Boolean(true);
+       }
+}

Added: 
webservices/commons/trunk/policy/src/examples/secParser/processors/UsernameTokenProcessor.java
URL: 
http://svn.apache.org/viewcvs/webservices/commons/trunk/policy/src/examples/secParser/processors/UsernameTokenProcessor.java?rev=368034&view=auto
==============================================================================
--- 
webservices/commons/trunk/policy/src/examples/secParser/processors/UsernameTokenProcessor.java
 (added)
+++ 
webservices/commons/trunk/policy/src/examples/secParser/processors/UsernameTokenProcessor.java
 Wed Jan 11 06:57:47 2006
@@ -0,0 +1,104 @@
+/*
+ * 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 examples.secParser.processors;
+
+import org.apache.ws.policy.PrimitiveAssertion;
+
+import examples.secParser.SecurityPolicy;
+import examples.secParser.SecurityPolicyToken;
+import examples.secParser.SecurityProcessorContext;
+
+/**
+ * @author Werner Dittmann ([EMAIL PROTECTED])
+ */
+public class UsernameTokenProcessor {
+
+       private boolean initializedUsernameToken = false;
+
+       /**
+        * Intialize the UsernameToken complex token.
+        * 
+        * This method creates copies of the child tokens that are allowed for
+        * UsernameToken. These tokens are WssUsernameToken10 and
+        * WssUsernameToken11. These copies are also initialized with the 
handler
+        * object and then set as child tokens of UsernameToken.
+        * 
+        * <p/> The handler object must define the methods
+        * <code>doWssUsernameToken10, doWssUsernameToken11</code>.
+        * 
+        * @param spt
+        *            The token that will hold the child tokens.
+        * @throws NoSuchMethodException
+        */
+       public void initializeUsernameToken(SecurityPolicyToken spt)
+                       throws NoSuchMethodException {
+               // SecurityPolicyToken spt = secPol.usernameToken.copy();
+               // spt.setProcessTokenMethod(handler);
+
+               SecurityPolicyToken tmpSpt = 
SecurityPolicy.wssUsernameToken10.copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.wssUsernameToken11.copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+       }
+
+       public Object doUsernameToken(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+
+               SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+               switch (spc.getAction()) {
+
+               case SecurityProcessorContext.START:
+                       if (!initializedUsernameToken) {
+                               try {
+                                       initializeUsernameToken(spt);
+                                       initializedUsernameToken = true;
+                               } catch (NoSuchMethodException e) {
+                                       // TODO Auto-generated catch block
+                                       e.printStackTrace();
+                                       return new Boolean(false);
+                               }
+                       }
+                       System.out.println(spt.getTokenName());
+                       PrimitiveAssertion pa = spc.getAssertion();
+                       String text = pa.getStrValue();
+                       if (text != null) {
+                               text = text.trim();
+                               System.out.println("Value: '" + text.toString() 
+ "'");
+                       }
+               case SecurityProcessorContext.COMMIT:
+                       break;
+               case SecurityProcessorContext.ABORT:
+                       break;
+               }
+               return new Boolean(true);
+       }
+
+       public Object doWssUsernameToken10(SecurityProcessorContext spc) {
+               System.out.println("Processing wssUsernameToken10");
+               return new Boolean(true);
+       }
+
+       public Object doWssUsernameToken11(SecurityProcessorContext spc) {
+               System.out.println("Processing wssUsernameToken11");
+               return new Boolean(true);
+       }
+
+}

Added: 
webservices/commons/trunk/policy/src/examples/secParser/processors/X509TokenProcessor.java
URL: 
http://svn.apache.org/viewcvs/webservices/commons/trunk/policy/src/examples/secParser/processors/X509TokenProcessor.java?rev=368034&view=auto
==============================================================================
--- 
webservices/commons/trunk/policy/src/examples/secParser/processors/X509TokenProcessor.java
 (added)
+++ 
webservices/commons/trunk/policy/src/examples/secParser/processors/X509TokenProcessor.java
 Wed Jan 11 06:57:47 2006
@@ -0,0 +1,218 @@
+/*
+ * 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 examples.secParser.processors;
+
+import org.apache.ws.policy.PrimitiveAssertion;
+
+import examples.secParser.SecurityPolicy;
+import examples.secParser.SecurityPolicyToken;
+import examples.secParser.SecurityProcessorContext;
+
+/**
+ * @author Werner Dittmann ([EMAIL PROTECTED])
+ */
+public class X509TokenProcessor {
+       private boolean initializedX509Token = false;
+
+       /**
+        * Intialize the X509 complex token.
+        * 
+        * This method creates a copy of the X509Token token and sets the 
handler
+        * object to the copy. Then it creates copies of the child tokens that 
are
+        * allowed for X509Token. These tokens are:
+        * 
+        * These copies are also initialized with the handler object and then 
set as
+        * child tokens of X509Token.
+        * 
+        * <p/> The handler object that must contain the methods
+        * <code>doX509Token</code>.
+        * 
+        * @param spt
+        *            The token that will hold the child tokens.
+        * @throws NoSuchMethodException
+        */
+       private void initializeX509Token(SecurityPolicyToken spt)
+                       throws NoSuchMethodException {
+
+               SecurityPolicyToken tmpSpt = 
SecurityPolicy.requireKeyIdentifierReference
+                               .copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.requireIssuerSerialReference.copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.requireEmbeddedTokenReference.copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.requireThumbprintReference.copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.wssX509V1Token10.copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.wssX509V3Token10.copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.wssX509Pkcs7Token10.copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.wssX509PkiPathV1Token10.copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.wssX509V1Token11.copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.wssX509V3Token11.copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.wssX509Pkcs7Token11.copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+
+               tmpSpt = SecurityPolicy.wssX509PkiPathV1Token11.copy();
+               tmpSpt.setProcessTokenMethod(this);
+               spt.setChildToken(tmpSpt);
+       }
+
+       public Object doX509Token(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+
+               SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+
+               switch (spc.getAction()) {
+
+               case SecurityProcessorContext.START:
+                       if (!initializedX509Token) {
+                               try {
+                                       initializeX509Token(spt);
+                                       initializedX509Token = true;
+                               } catch (NoSuchMethodException e) {
+                                       // TODO Auto-generated catch block
+                                       e.printStackTrace();
+                                       return new Boolean(false);
+                               }
+                       }
+                       PrimitiveAssertion pa = spc.getAssertion();
+                       String text = pa.getStrValue();
+                       if (text != null) {
+                               text = text.trim();
+                               System.out.println("Value: '" + text.toString() 
+ "'");
+                       }
+               case SecurityProcessorContext.COMMIT:
+                       break;
+               case SecurityProcessorContext.ABORT:
+                       break;
+               }
+               return new Boolean(true);
+       }
+
+       public Object doRequireKeyIdentifierReference(SecurityProcessorContext 
spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               return new Boolean(true);
+       }
+
+       public Object doRequireIssuerSerialReference(SecurityProcessorContext 
spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               return new Boolean(true);
+       }
+
+       public Object doRequireEmbeddedTokenReference(SecurityProcessorContext 
spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               return new Boolean(true);
+       }
+
+       public Object doRequireThumbprintReference(SecurityProcessorContext 
spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               return new Boolean(true);
+       }
+
+       public Object doWssX509V1Token10(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               return new Boolean(true);
+       }
+
+       public Object dowssX509V3Token10(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               return new Boolean(true);
+       }
+
+       public Object doWssX509Pkcs7Token10(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               return new Boolean(true);
+       }
+
+       public Object doWssX509PkiPathV1Token10(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               return new Boolean(true);
+       }
+
+       public Object doWssX509V1Token11(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               return new Boolean(true);
+       }
+
+       public Object doWssX509V3Token11(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               return new Boolean(true);
+       }
+
+       public Object doWssX509Pkcs7Token11(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               return new Boolean(true);
+       }
+
+       public Object doWssX509PkiPathV1Token11(SecurityProcessorContext spc) {
+               System.out.println("Processing "
+                               + spc.readCurrentSecurityToken().getTokenName() 
+ ": "
+                               + 
SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+               return new Boolean(true);
+       }
+
+}


Reply via email to