You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ru...@apache.org on 2006/01/24 10:14:27 UTC

svn commit: r371870 [3/4] - in /webservices/axis2/trunk/java/modules/security: ./ src/org/apache/axis2/security/ src/org/apache/axis2/security/handler/config/ src/org/apache/ws/ src/org/apache/ws/security/ src/org/apache/ws/security/policy/ src/org/apa...

Added: webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/AsymmetricBindingProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/AsymmetricBindingProcessor.java?rev=371870&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/AsymmetricBindingProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/AsymmetricBindingProcessor.java Tue Jan 24 01:13:40 2006
@@ -0,0 +1,168 @@
+/*
+ * 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.security.policy.parser.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.policy.parser.SecurityPolicy;
+import org.apache.ws.security.policy.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy.parser.SecurityProcessorContext;
+
+/**
+ * @author Werner Dittmann (werner@apache.org)
+ * 
+ */
+public class AsymmetricBindingProcessor {
+
+    private Log log = LogFactory.getLog(getClass());
+    
+    private boolean initializedAsymmetricBinding = 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 initializeAsymmetricBinding(SecurityPolicyToken spt)
+			throws NoSuchMethodException {
+
+		InitiatorRecipientTokenProcessor irt = new InitiatorRecipientTokenProcessor();
+		SecurityPolicyToken tmpSpt = SecurityPolicy.initiatorToken.copy();
+		tmpSpt.setProcessTokenMethod(irt);
+		spt.setChildToken(tmpSpt);
+
+		tmpSpt = SecurityPolicy.recipientToken.copy();
+		tmpSpt.setProcessTokenMethod(irt);
+		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 doAsymmetricBinding(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+		SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+
+		switch (spc.getAction()) {
+
+		case SecurityProcessorContext.START:
+			if (!initializedAsymmetricBinding) {
+				try {
+					initializeAsymmetricBinding(spt);
+					initializedAsymmetricBinding = 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) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+		return new Boolean(true);
+	}
+
+	public Object doEncryptBeforeSigning(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+		return new Boolean(true);
+	}
+
+	public Object doEncryptSignature(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+		return new Boolean(true);
+	}
+
+	public Object doProtectTokens(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+		return new Boolean(true);
+	}
+
+	public Object doOnlySignEntireHeadersAndBody(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+		return new Boolean(true);
+	}
+}

Added: webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/EncryptedPartsElementsProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/EncryptedPartsElementsProcessor.java?rev=371870&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/EncryptedPartsElementsProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/EncryptedPartsElementsProcessor.java Tue Jan 24 01:13:40 2006
@@ -0,0 +1,211 @@
+/*
+ * 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.security.policy.parser.processors;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.policy.PrimitiveAssertion;
+import org.apache.ws.security.policy.model.Header;
+import org.apache.ws.security.policy.model.PolicyEngineData;
+import org.apache.ws.security.policy.model.SignedEncryptedElements;
+import org.apache.ws.security.policy.model.SignedEncryptedParts;
+import org.apache.ws.security.policy.model.SupportingToken;
+import org.apache.ws.security.policy.parser.SecurityPolicy;
+import org.apache.ws.security.policy.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy.parser.SecurityProcessorContext;
+
+
+/**
+ * @author Werner Dittmann (werner@apache.org)
+ */
+
+public class EncryptedPartsElementsProcessor {
+
+    private Log log = LogFactory.getLog(getClass());
+
+	private boolean initializedEncryptedParts = false;
+
+	private boolean initializedEncryptedElements = false;
+    
+	/**
+	 * Intialize the EncryptedParts 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
+	 * EncryptedParts. <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 initializeEncryptedParts(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 EncryptedElements complex token.
+	 * 
+	 * This method creates a copy of the child token that is allowed for
+	 * EncryptedElements. The token is XPath. This copy is initialized with a
+	 * handler object and then set as child token of EncryptedElements. <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 initializeEncryptedElements(SecurityPolicyToken spt)
+			throws NoSuchMethodException {
+		SecurityPolicyToken tmpSpt = SecurityPolicy.xPath.copy();
+		tmpSpt.setProcessTokenMethod(this);
+		spt.setChildToken(tmpSpt);
+	}
+
+	public Object doEncryptedParts(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+
+		SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+		switch (spc.getAction()) {
+
+		case SecurityProcessorContext.START:
+			if (!initializedEncryptedParts) {
+				try {
+					initializeEncryptedParts(spt);
+                    SignedEncryptedParts parts = (SignedEncryptedParts) spc
+                            .readCurrentPolicyEngineData();
+                    PolicyEngineData parent = spc.readPreviousPolicyEngineData();
+                    if(parent instanceof SupportingToken) {
+                        //Parent is a supporting token
+                        ((SupportingToken)parent).setEncryptedParts(parts);
+                    }
+					initializedEncryptedParts = true;
+				} catch (NoSuchMethodException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+					return new Boolean(false);
+				}
+			}
+			log.debug(spt.getTokenName());
+			PrimitiveAssertion pa = spc.getAssertion();
+			String text = pa.getStrValue();
+			if (text != null) {
+				text = text.trim();
+				log.debug("Value: '" + text.toString() + "'");
+			}
+		case SecurityProcessorContext.COMMIT:
+			break;
+		case SecurityProcessorContext.ABORT:
+			break;
+		}
+		return new Boolean(true);
+	}
+
+	public Object doEncryptedElements(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+
+		SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+		switch (spc.getAction()) {
+
+		case SecurityProcessorContext.START:
+			if (!initializedEncryptedElements) {
+				try {
+					initializeEncryptedElements(spt);
+                    SignedEncryptedElements elements = (SignedEncryptedElements) spc
+                            .readCurrentPolicyEngineData();
+                    PolicyEngineData parent = spc
+                            .readPreviousPolicyEngineData();
+                    if (parent instanceof SupportingToken) {
+                        // Parent is a supporting token
+                        ((SupportingToken) parent).setEncryptedElements(elements);
+                    }
+					initializedEncryptedElements = true;
+				} catch (NoSuchMethodException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+					return new Boolean(false);
+				}
+			}
+			log.debug(spt.getTokenName());
+			PrimitiveAssertion pa = spc.getAssertion();
+			String text = pa.getStrValue();
+			if (text != null) {
+				text = text.trim();
+				log.debug("Value: '" + text.toString() + "'");
+			}
+		case SecurityProcessorContext.COMMIT:
+			break;
+		case SecurityProcessorContext.ABORT:
+			break;
+		}
+		return new Boolean(true);
+	}
+
+	public Object doBody(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+        if(spc.getAction() == 2) {
+            ((SignedEncryptedParts)spc.readCurrentPolicyEngineData()).setBody(true);
+        }
+		return new Boolean(true);
+	}
+
+	public Object doHeader(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+        
+        if(spc.getAction() == 2) {
+            //Extract the sp:Header/@Name and sp:Header/@Namespace attrs
+            //And create a Header
+            Header header = new Header();
+            header.setName(spc.getAssertion().getAttribute(new QName("Name")));
+            header.setNamespace(spc.getAssertion().getAttribute(new QName("Namespace")));
+            ((SignedEncryptedParts)spc.readCurrentPolicyEngineData()).addHeader(header);
+        }
+        
+		return new Boolean(true);
+	}
+
+	public Object doXPath(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+        if(spc.getAction() == 2) {
+            ((SignedEncryptedElements) spc.readCurrentPolicyEngineData())
+                    .addXPathExpression(spc.getAssertion().getStrValue());
+        }
+		return new Boolean(true);
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/EndorsingSupportingTokensProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/EndorsingSupportingTokensProcessor.java?rev=371870&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/EndorsingSupportingTokensProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/EndorsingSupportingTokensProcessor.java Tue Jan 24 01:13:40 2006
@@ -0,0 +1,110 @@
+/*
+ * 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.security.policy.parser.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.policy.parser.SecurityPolicy;
+import org.apache.ws.security.policy.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy.parser.SecurityProcessorContext;
+
+/**
+ * @author Werner Dittmann (werner@apache.org)
+ * 
+ */
+public class EndorsingSupportingTokensProcessor {
+    
+    private Log log = LogFactory.getLog(getClass());
+    
+    private boolean initializedEndorsingSupportingTokens = false;
+
+	/**
+	 * Intialize the EndorsingSupportingTokens complex token.
+	 * 
+	 * This method creates a copy of the EndorsingSupportingTokens token and sets the
+	 * handler object to the copy. Then it creates copies of the child tokens
+	 * that are allowed for EndorsingSupportingTokens. These tokens are:
+	 * 
+	 * These copies are also initialized with the handler object and then set as
+	 * child tokens of EndorsingSupportingTokens.
+	 * 
+	 * @param spt
+	 *            The token that will hold the child tokens.
+	 * @throws NoSuchMethodException
+	 */
+	private void initializeEndorsingSupportingTokens(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 doEndorsingSupportingTokens(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+		SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+
+		switch (spc.getAction()) {
+
+		case SecurityProcessorContext.START:
+			if (!initializedEndorsingSupportingTokens) {
+				try {
+					initializeEndorsingSupportingTokens(spt);
+					initializedEndorsingSupportingTokens = 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/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/InitiatorRecipientTokenProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/InitiatorRecipientTokenProcessor.java?rev=371870&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/InitiatorRecipientTokenProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/InitiatorRecipientTokenProcessor.java Tue Jan 24 01:13:40 2006
@@ -0,0 +1,141 @@
+/*
+ * 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.security.policy.parser.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.policy.model.AsymmetricBinding;
+import org.apache.ws.security.policy.model.InitiatorToken;
+import org.apache.ws.security.policy.model.RecipientToken;
+import org.apache.ws.security.policy.parser.SecurityPolicy;
+import org.apache.ws.security.policy.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy.parser.SecurityProcessorContext;
+
+
+/**
+ * @author Werner Dittmann (werner@apache.org)
+ * 
+ */
+public class InitiatorRecipientTokenProcessor {
+    
+    private Log log = LogFactory.getLog(getClass());
+    
+    private boolean initializedInitiatorToken = false;
+
+	private boolean initializedRecipientToken = false;
+
+	/**
+	 * Intialize the InitiatorToken complex token.
+	 * 
+	 * This method creates a copy of the InitiatorToken token and sets the
+	 * handler object to the copy. Then it creates copies of the child tokens
+	 * that are allowed for InitiatorToken. These tokens are:
+	 * 
+	 * These copies are also initialized with the handler object and then set as
+	 * child tokens of InitiatorToken.
+	 * 
+	 * @param spt
+	 *            The token that will hold the child tokens.
+	 * @throws NoSuchMethodException
+	 */
+	private void initializeInitiatorToken(SecurityPolicyToken spt)
+			throws NoSuchMethodException {
+		SecurityPolicyToken tmpSpt = SecurityPolicy.x509Token.copy();
+		tmpSpt.setProcessTokenMethod(new X509TokenProcessor());
+		spt.setChildToken(tmpSpt);
+	}
+
+	/**
+	 * Intialize the RecipientToken complex token.
+	 * 
+	 * This method creates a copy of the RecipientToken token and sets the
+	 * handler object to the copy. Then it creates copies of the child tokens
+	 * that are allowed for RecipientToken. These tokens are:
+	 * 
+	 * These copies are also initialized with the handler object and then set as
+	 * child tokens of RecipientToken.
+	 * 
+	 * @param spt
+	 *            The token that will hold the child tokens.
+	 * @throws NoSuchMethodException
+	 */
+	private void initializeRecipientToken(SecurityPolicyToken spt)
+			throws NoSuchMethodException {
+		SecurityPolicyToken tmpSpt = SecurityPolicy.x509Token.copy();
+		tmpSpt.setProcessTokenMethod(new X509TokenProcessor());
+		spt.setChildToken(tmpSpt);
+	}
+
+
+	public Object doInitiatorToken(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+		SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+
+		switch (spc.getAction()) {
+
+		case SecurityProcessorContext.START:
+			if (!initializedInitiatorToken) {
+				try {
+					initializeInitiatorToken(spt);
+                    InitiatorToken initiatorToken = (InitiatorToken)spc.readCurrentPolicyEngineData();
+                    ((AsymmetricBinding)spc.readPreviousPolicyEngineData()).setInitiatorToken(initiatorToken);
+					initializedInitiatorToken = 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 doRecipientToken(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+		SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+		switch (spc.getAction()) {
+
+		case SecurityProcessorContext.START:
+			if (!initializedRecipientToken) {
+				try {
+					initializeRecipientToken(spt);
+                    RecipientToken recipientToken = (RecipientToken)spc.readCurrentPolicyEngineData();
+                    ((AsymmetricBinding)spc.readPreviousPolicyEngineData()).setRecipientToken(recipientToken);
+					initializedRecipientToken = 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/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/LayoutProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/LayoutProcessor.java?rev=371870&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/LayoutProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/LayoutProcessor.java Tue Jan 24 01:13:40 2006
@@ -0,0 +1,177 @@
+/*
+ * 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.security.policy.parser.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.policy.PrimitiveAssertion;
+import org.apache.ws.security.policy.WSSPolicyException;
+import org.apache.ws.security.policy.model.Binding;
+import org.apache.ws.security.policy.model.Layout;
+import org.apache.ws.security.policy.parser.SecurityPolicy;
+import org.apache.ws.security.policy.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy.parser.SecurityProcessorContext;
+
+
+/**
+ * @author Werner Dittmann (werner@apache.org)
+ * 
+ */
+public class LayoutProcessor {
+
+    private Log log = LogFactory.getLog(getClass());
+
+    private boolean initializedLayout = false;
+    
+	/**
+	 * Intialize the Layout complex token.
+	 * 
+	 * This method creates a copy of the Layout token and sets the handler
+	 * object to the copy. Then it creates copies of the child tokens that are
+	 * allowed for Layout. These tokens are:
+	 * 
+	 * These copies are also initialized with the handler object and then set as
+	 * child tokens of Layout.
+	 * 
+	 * <p/> The handler object that must contain the methods
+	 * <code>doLayout</code>.
+	 * 
+	 * @param spt
+	 *            The token that will hold the child tokens.
+	 * @throws NoSuchMethodException
+	 */
+	private void initializeLayout(SecurityPolicyToken spt)
+			throws NoSuchMethodException {
+
+		SecurityPolicyToken tmpSpt = SecurityPolicy.strict.copy();
+		tmpSpt.setProcessTokenMethod(this);
+		spt.setChildToken(tmpSpt);
+
+		tmpSpt = SecurityPolicy.lax.copy();
+		tmpSpt.setProcessTokenMethod(this);
+		spt.setChildToken(tmpSpt);
+
+		tmpSpt = SecurityPolicy.laxTsFirst.copy();
+		tmpSpt.setProcessTokenMethod(this);
+		spt.setChildToken(tmpSpt);
+
+		tmpSpt = SecurityPolicy.laxTsLast.copy();
+		tmpSpt.setProcessTokenMethod(this);
+		spt.setChildToken(tmpSpt);
+	}
+
+	public Object doLayout(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+
+		SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+		switch (spc.getAction()) {
+
+		case SecurityProcessorContext.START:
+			if (!initializedLayout) {
+				try {
+					initializeLayout(spt);
+					initializedLayout = true;
+				} catch (NoSuchMethodException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+					return new Boolean(false);
+				}
+			}
+			log.debug(spt.getTokenName());
+			PrimitiveAssertion pa = spc.getAssertion();
+			String text = pa.getStrValue();
+			if (text != null) {
+				text = text.trim();
+				log.debug("Value: '" + text.toString() + "'");
+			}
+		case SecurityProcessorContext.COMMIT:
+			break;
+		case SecurityProcessorContext.ABORT:
+			break;
+		}
+		return new Boolean(true);
+	}
+
+	public Object doStrict(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+        try {
+            if(spc.getAction() == 2) {
+                Layout layout = (Layout) spc.readCurrentPolicyEngineData();
+                layout.setValue(spc.getAssertion().getName().getLocalPart());
+                ((Binding)spc.readPreviousPolicyEngineData()).setLayout(layout);
+            }
+        } catch (WSSPolicyException e) {
+            // TODO Throw this exception out
+            e.printStackTrace();
+        }
+		return new Boolean(true);
+	}
+
+	public Object doLax(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+        try {
+            if(spc.getAction() == 2) {
+                Layout layout = (Layout) spc.readCurrentPolicyEngineData();
+                layout.setValue(spc.getAssertion().getName().getLocalPart());
+                ((Binding)spc.readPreviousPolicyEngineData()).setLayout(layout);
+            }
+        } catch (WSSPolicyException e) {
+            // TODO Throw this exception out
+            e.printStackTrace();
+        }
+		return new Boolean(true);
+	}
+
+	public Object doLaxTsFirst(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+        try {
+            if(spc.getAction() == 2) {
+                Layout layout = (Layout) spc.readCurrentPolicyEngineData();
+                layout.setValue(spc.getAssertion().getName().getLocalPart());
+                ((Binding)spc.readPreviousPolicyEngineData()).setLayout(layout);
+            }
+        } catch (WSSPolicyException e) {
+            // TODO Throw this exception out
+            e.printStackTrace();
+        }
+		return new Boolean(true);
+	}
+
+	public Object doLaxTsLast(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+        try {
+            if(spc.getAction() == 2) {
+                Layout layout = (Layout) spc.readCurrentPolicyEngineData();
+                layout.setValue(spc.getAssertion().getName().getLocalPart());
+                ((Binding)spc.readPreviousPolicyEngineData()).setLayout(layout);
+            }
+        } catch (WSSPolicyException e) {
+            // TODO Throw this exception out
+            e.printStackTrace();
+        }
+		return new Boolean(true);
+	}
+}

Added: webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SignEncProtectTokenProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SignEncProtectTokenProcessor.java?rev=371870&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SignEncProtectTokenProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SignEncProtectTokenProcessor.java Tue Jan 24 01:13:40 2006
@@ -0,0 +1,195 @@
+/*
+ * 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.security.policy.parser.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.policy.WSSPolicyException;
+import org.apache.ws.security.policy.model.ProtectionToken;
+import org.apache.ws.security.policy.model.SymmetricBinding;
+import org.apache.ws.security.policy.parser.SecurityPolicy;
+import org.apache.ws.security.policy.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy.parser.SecurityProcessorContext;
+
+
+/**
+ * @author Werner Dittmann (werner@apache.org)
+ * 
+ */
+public class SignEncProtectTokenProcessor {
+    
+    private Log log = LogFactory.getLog(getClass());
+    
+    private boolean initializedSignatureToken = false;
+
+	private boolean initializedEncryptionToken = false;
+
+	private boolean initializedProtectionToken = false;
+
+	/**
+	 * Intialize the SignatureToken complex token.
+	 * 
+	 * This method creates a copy of the SignatureToken token and sets the
+	 * handler object to the copy. Then it creates copies of the child tokens
+	 * that are allowed for SignatureToken. These tokens are:
+	 * 
+	 * These copies are also initialized with the handler object and then set as
+	 * child tokens of SignatureToken.
+	 * 
+	 * @param spt
+	 *            The token that will hold the child tokens.
+	 * @throws NoSuchMethodException
+	 */
+	private void initializeSignatureToken(SecurityPolicyToken spt)
+			throws NoSuchMethodException {
+		SecurityPolicyToken tmpSpt = SecurityPolicy.x509Token.copy();
+		tmpSpt.setProcessTokenMethod(new X509TokenProcessor());
+		spt.setChildToken(tmpSpt);
+	}
+
+	/**
+	 * Intialize the EncryptionToken complex token.
+	 * 
+	 * This method creates a copy of the EncryptionToken token and sets the
+	 * handler object to the copy. Then it creates copies of the child tokens
+	 * that are allowed for EncryptionToken. These tokens are:
+	 * 
+	 * These copies are also initialized with the handler object and then set as
+	 * child tokens of SignatureToken.
+	 * 
+	 * @param spt
+	 *            The token that will hold the child tokens.
+	 * @throws NoSuchMethodException
+	 */
+	private void initializeEncryptionToken(SecurityPolicyToken spt)
+			throws NoSuchMethodException {
+		SecurityPolicyToken tmpSpt = SecurityPolicy.x509Token.copy();
+		tmpSpt.setProcessTokenMethod(new X509TokenProcessor());
+		spt.setChildToken(tmpSpt);
+	}
+
+	/**
+	 * Intialize the ProtectionToken complex token.
+	 * 
+	 * This method creates a copy of the ProtectionToken token and sets the
+	 * handler object to the copy. Then it creates copies of the child tokens
+	 * that are allowed for ProtectionToken. These tokens are:
+	 * 
+	 * These copies are also initialized with the handler object and then set as
+	 * child tokens of ProtectionToken.
+	 * 
+	 * @param spt
+	 *            The token that will hold the child tokens.
+	 * @throws NoSuchMethodException
+	 */
+	private void initializeProtectionToken(SecurityPolicyToken spt)
+			throws NoSuchMethodException {
+		SecurityPolicyToken tmpSpt = SecurityPolicy.x509Token.copy();
+		tmpSpt.setProcessTokenMethod(new X509TokenProcessor());
+		spt.setChildToken(tmpSpt);
+	}
+
+	public Object doSignatureToken(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+		SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+
+		switch (spc.getAction()) {
+
+		case SecurityProcessorContext.START:
+			if (!initializedSignatureToken) {
+				try {
+					initializeSignatureToken(spt);
+					initializedSignatureToken = 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 doEncryptionToken(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+		SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+		switch (spc.getAction()) {
+
+		case SecurityProcessorContext.START:
+			if (!initializedEncryptionToken) {
+				try {
+					initializeEncryptionToken(spt);
+					initializedEncryptionToken = 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 doProtectionToken(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+		SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+		switch (spc.getAction()) {
+
+		case SecurityProcessorContext.START:
+			if (!initializedProtectionToken) {
+				try {
+					initializeProtectionToken(spt);
+                    ProtectionToken protectionToken = (ProtectionToken) spc
+                            .readCurrentPolicyEngineData();
+                    try {
+                        ((SymmetricBinding) spc.readPreviousPolicyEngineData())
+                                .setProtectionToken(protectionToken);
+                    } catch (WSSPolicyException e) {
+                        // TODO Throw this out
+                        e.printStackTrace();
+                    }
+					initializedProtectionToken = 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/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SignedEndorsingSupportingTokensProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SignedEndorsingSupportingTokensProcessor.java?rev=371870&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SignedEndorsingSupportingTokensProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SignedEndorsingSupportingTokensProcessor.java Tue Jan 24 01:13:40 2006
@@ -0,0 +1,110 @@
+/*
+ * 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.security.policy.parser.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.policy.parser.SecurityPolicy;
+import org.apache.ws.security.policy.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy.parser.SecurityProcessorContext;
+
+/**
+ * @author Werner Dittmann (werner@apache.org)
+ * 
+ */
+public class SignedEndorsingSupportingTokensProcessor {
+
+    private Log log = LogFactory.getLog(getClass());
+    
+    private boolean initializedSignedEndorsingSupportingTokens = false;
+    
+	/**
+	 * Intialize the SignedEndorsingSupportingTokens complex token.
+	 * 
+	 * This method creates a copy of the SignedEndorsingSupportingTokens token and sets the
+	 * handler object to the copy. Then it creates copies of the child tokens
+	 * that are allowed for SignedEndorsingSupportingTokens. These tokens are:
+	 * 
+	 * These copies are also initialized with the handler object and then set as
+	 * child tokens of SignedEndorsingSupportingTokens.
+	 * 
+	 * @param spt
+	 *            The token that will hold the child tokens.
+	 * @throws NoSuchMethodException
+	 */
+	private void initializeSignedEndorsingSupportingTokens(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 doSignedEndorsingSupportingTokens(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+		SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+
+		switch (spc.getAction()) {
+
+		case SecurityProcessorContext.START:
+			if (!initializedSignedEndorsingSupportingTokens) {
+				try {
+					initializeSignedEndorsingSupportingTokens(spt);
+					initializedSignedEndorsingSupportingTokens = 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/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SignedPartsElementsProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SignedPartsElementsProcessor.java?rev=371870&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SignedPartsElementsProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SignedPartsElementsProcessor.java Tue Jan 24 01:13:40 2006
@@ -0,0 +1,216 @@
+/*
+ * 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.security.policy.parser.processors;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.policy.PrimitiveAssertion;
+import org.apache.ws.security.policy.model.Header;
+import org.apache.ws.security.policy.model.PolicyEngineData;
+import org.apache.ws.security.policy.model.SignedEncryptedElements;
+import org.apache.ws.security.policy.model.SignedEncryptedParts;
+import org.apache.ws.security.policy.model.SupportingToken;
+import org.apache.ws.security.policy.parser.SecurityPolicy;
+import org.apache.ws.security.policy.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy.parser.SecurityProcessorContext;
+
+
+/**
+ * @author Werner Dittmann (werner@apache.org)
+ */
+
+public class SignedPartsElementsProcessor {
+    
+    private Log log = LogFactory.getLog(getClass());
+    
+	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) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+
+		SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+
+		switch (spc.getAction()) {
+
+		case SecurityProcessorContext.START:
+			if (!initializedSignedParts) {
+				try {
+					initializeSignedParts(spt);
+                    SignedEncryptedParts parts = (SignedEncryptedParts) spc
+                            .readCurrentPolicyEngineData();
+                    PolicyEngineData parent = spc
+                            .readPreviousPolicyEngineData();
+                    if (parent instanceof SupportingToken) {
+                        // Parent is a supporting token
+                        ((SupportingToken) parent).setSignedParts(parts);
+                    }
+					initializedSignedParts = true;
+				} catch (NoSuchMethodException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+					return new Boolean(false);
+				}
+			}
+			log.debug(spt.getTokenName());
+			PrimitiveAssertion pa = spc.getAssertion();
+			String text = pa.getStrValue();
+			if (text != null) {
+				text = text.trim();
+				log.debug("Value: '" + text.toString() + "'");
+			}
+		case SecurityProcessorContext.COMMIT:
+			break;
+		case SecurityProcessorContext.ABORT:
+			break;
+		}
+		return new Boolean(true);
+	}
+
+	public Object doSignedElements(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+
+		SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+
+		switch (spc.getAction()) {
+
+		case SecurityProcessorContext.START:
+			if (!initializedSignedElements) {
+				try {
+					initializeSignedElements(spt);
+                    SignedEncryptedElements elements = (SignedEncryptedElements) spc
+                            .readCurrentPolicyEngineData();
+                    PolicyEngineData parent = spc
+                            .readPreviousPolicyEngineData();
+                    if (parent instanceof SupportingToken) {
+                        // Parent is a supporting token
+                        ((SupportingToken) parent)
+                                .setSignedElements(elements);
+                    }
+					initializedSignedElements = true;
+				} catch (NoSuchMethodException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+					return new Boolean(false);
+				}
+			}
+			log.debug(spt.getTokenName());
+			PrimitiveAssertion pa = spc.getAssertion();
+			String text = pa.getStrValue();
+			if (text != null) {
+				text = text.trim();
+				log.debug("Value: '" + text.toString() + "'");
+			}
+		case SecurityProcessorContext.COMMIT:
+			break;
+		case SecurityProcessorContext.ABORT:
+			break;
+		}
+		return new Boolean(true);
+	}
+
+	public Object doBody(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+            if(spc.getAction() == 2) {
+                ((SignedEncryptedParts)spc.readCurrentPolicyEngineData()).setBody(true);
+            }
+		return new Boolean(true);
+	}
+
+	public Object doHeader(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+        if(spc.getAction() == 2) {
+            //Extract the sp:Header/@Name and sp:Header/@Namespace attrs
+            //And create a Header
+            Header header = new Header();
+            header.setName(spc.getAssertion().getAttribute(new QName("Name")));
+            header.setNamespace(spc.getAssertion().getAttribute(new QName("Namespace")));
+            ((SignedEncryptedParts)spc.readCurrentPolicyEngineData()).addHeader(header);
+        }
+		return new Boolean(true);
+	}
+
+	public Object doXPath(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+        if(spc.getAction() == 2) {
+            ((SignedEncryptedElements) spc.readCurrentPolicyEngineData())
+                    .addXPathExpression(spc.getAssertion().getStrValue());
+        }
+		return new Boolean(true);
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SignedSupportingTokensProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SignedSupportingTokensProcessor.java?rev=371870&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SignedSupportingTokensProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SignedSupportingTokensProcessor.java Tue Jan 24 01:13:40 2006
@@ -0,0 +1,109 @@
+/*
+ * 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.security.policy.parser.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.policy.parser.SecurityPolicy;
+import org.apache.ws.security.policy.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy.parser.SecurityProcessorContext;
+
+/**
+ * @author Werner Dittmann (werner@apache.org)
+ * 
+ */
+public class SignedSupportingTokensProcessor {
+    
+    private Log log = LogFactory.getLog(getClass());
+    
+    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) {
+		log.debug("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/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SupportingTokensProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SupportingTokensProcessor.java?rev=371870&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SupportingTokensProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SupportingTokensProcessor.java Tue Jan 24 01:13:40 2006
@@ -0,0 +1,110 @@
+/*
+ * 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.security.policy.parser.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.policy.parser.SecurityPolicy;
+import org.apache.ws.security.policy.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy.parser.SecurityProcessorContext;
+
+/**
+ * @author Werner Dittmann (werner@apache.org)
+ * 
+ */
+public class SupportingTokensProcessor {
+    
+    private Log log = LogFactory.getLog(getClass());
+    
+	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) {
+		log.debug("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/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SymmetricBindingProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SymmetricBindingProcessor.java?rev=371870&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SymmetricBindingProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/SymmetricBindingProcessor.java Tue Jan 24 01:13:40 2006
@@ -0,0 +1,194 @@
+/*
+ * 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.security.policy.parser.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.policy.WSSPolicyException;
+import org.apache.ws.security.policy.model.Binding;
+import org.apache.ws.security.policy.model.PolicyEngineData;
+import org.apache.ws.security.policy.model.SymmetricBinding;
+import org.apache.ws.security.policy.parser.SecurityPolicy;
+import org.apache.ws.security.policy.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy.parser.SecurityProcessorContext;
+
+
+/**
+ * @author Werner Dittmann (werner@apache.org)
+ * 
+ */
+public class SymmetricBindingProcessor {
+    
+    private Log log = LogFactory.getLog(getClass());
+    
+	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) {
+		log.debug("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) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+        if(spc.getAction() == 2) {
+            ((Binding)spc.readCurrentPolicyEngineData()).setIncludeTimestamp(true);
+        }
+		return new Boolean(true);
+	}
+
+	public Object doEncryptBeforeSigning(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+        if(spc.getAction() == 2) {
+            try {
+                ((SymmetricBinding) spc.readCurrentPolicyEngineData()).setProtectionOrder(spc
+                        .getAssertion().getName().getLocalPart());
+            } catch (WSSPolicyException e) {
+                // TODO Throw this exception out
+                e.printStackTrace();
+            }
+        }
+		return new Boolean(true);
+	}
+
+	public Object doEncryptSignature(SecurityProcessorContext spc) {
+	    log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+        PolicyEngineData readCurrentPolicyEngineData = spc.readCurrentPolicyEngineData();
+        ((SymmetricBinding) readCurrentPolicyEngineData).setSignatureProtection(true);
+		return new Boolean(true);
+	}
+
+	public Object doProtectTokens(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+        ((SymmetricBinding) spc.readCurrentPolicyEngineData()).setTokenProtection(true);
+		return new Boolean(true);
+	}
+
+	public Object doOnlySignEntireHeadersAndBody(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+        ((SymmetricBinding) spc.readCurrentPolicyEngineData()).setEntireHeaderAndBodySignatures(true);
+		return new Boolean(true);
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/Trust10Processor.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/Trust10Processor.java?rev=371870&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/Trust10Processor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/Trust10Processor.java Tue Jan 24 01:13:40 2006
@@ -0,0 +1,145 @@
+/*
+ * 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.security.policy.parser.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.policy.PrimitiveAssertion;
+import org.apache.ws.security.policy.parser.SecurityPolicy;
+import org.apache.ws.security.policy.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy.parser.SecurityProcessorContext;
+
+
+/**
+ * @author Werner Dittmann (werner@apache.org)
+ * 
+ */
+public class Trust10Processor {
+    
+    private Log log = LogFactory.getLog(getClass());
+    
+	private boolean initializedTrust10 = false;
+
+	/**
+	 * Intialize the Trust10 complex token.
+	 * 
+	 * This method creates a copy of the Trust10 token and sets the handler object
+	 * to the copy. Then it creates copies of the child tokens that are allowed
+	 * for Trust10. These tokens are:
+	 * 
+	 * These copies are also initialized with the handler object and then set as
+	 * child tokens of Trust10.
+	 * 
+	 * <p/> The handler object that must contain the methods
+	 * <code>doTrust10</code>.
+	 * 
+	 * @param spt
+	 *            The token that will hold the child tokens.
+	 * @throws NoSuchMethodException
+	 */
+	public void initializeTrust10(SecurityPolicyToken spt)
+			throws NoSuchMethodException {
+		SecurityPolicyToken tmpSpt = SecurityPolicy.mustSupportClientChallenge
+				.copy();
+		tmpSpt.setProcessTokenMethod(this);
+		spt.setChildToken(tmpSpt);
+
+		tmpSpt = SecurityPolicy.mustSupportServerChallenge.copy();
+		tmpSpt.setProcessTokenMethod(this);
+		spt.setChildToken(tmpSpt);
+
+		tmpSpt = SecurityPolicy.requireClientEntropy.copy();
+		tmpSpt.setProcessTokenMethod(this);
+		spt.setChildToken(tmpSpt);
+
+		tmpSpt = SecurityPolicy.requireServerEntropy.copy();
+		tmpSpt.setProcessTokenMethod(this);
+		spt.setChildToken(tmpSpt);
+
+		tmpSpt = SecurityPolicy.mustSupportIssuedTokens.copy();
+		tmpSpt.setProcessTokenMethod(this);
+		spt.setChildToken(tmpSpt);
+	}
+
+	public Object doTrust10(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+
+		SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+
+		switch (spc.getAction()) {
+
+		case SecurityProcessorContext.START:
+			if (!initializedTrust10) {
+				try {
+					initializeTrust10(spt);
+					initializedTrust10 = 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();
+				log.debug("Value: '" + text.toString() + "'");
+			}
+		case SecurityProcessorContext.COMMIT:
+			break;
+		case SecurityProcessorContext.ABORT:
+			break;
+		}
+		return new Boolean(true);
+	}
+	
+	public Object doMustSupportClientChallenge(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+		return new Boolean(true);
+	}
+
+	public Object doMustSupportServerChallenge(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+		return new Boolean(true);
+	}
+
+	public Object doRequireClientEntropy(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+		return new Boolean(true);
+	}
+
+	public Object doRequireServerEntropy(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+		return new Boolean(true);
+	}
+
+	public Object doMustSupportIssuedTokens(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+		return new Boolean(true);
+	}
+}

Added: webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/UsernameTokenProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/UsernameTokenProcessor.java?rev=371870&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/UsernameTokenProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/UsernameTokenProcessor.java Tue Jan 24 01:13:40 2006
@@ -0,0 +1,133 @@
+/*
+ * 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.security.policy.parser.processors;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.policy.PrimitiveAssertion;
+import org.apache.ws.security.policy.Constants;
+import org.apache.ws.security.policy.WSSPolicyException;
+import org.apache.ws.security.policy.model.TokenWrapper;
+import org.apache.ws.security.policy.model.UsernameToken;
+import org.apache.ws.security.policy.parser.SecurityPolicy;
+import org.apache.ws.security.policy.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy.parser.SecurityProcessorContext;
+
+
+/**
+ * @author Werner Dittmann (werner@apache.org)
+ */
+public class UsernameTokenProcessor {
+    
+    private Log log = LogFactory.getLog(getClass());
+
+	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 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) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+
+		SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+		switch (spc.getAction()) {
+
+		case SecurityProcessorContext.START:
+			if (!initializedUsernameToken) {
+				try {
+					initializeUsernameToken(spt);
+                    UsernameToken unt = (UsernameToken)spc.readCurrentPolicyEngineData();
+                    
+                    //Get the includeToken attr info
+                    String includetokenUri = spc.getAssertion().getAttribute(
+                            new QName(Constants.SP_NS,
+                                    Constants.ATTR_INCLUDE_TOKEN));
+                    try {
+                        if(includetokenUri != null) { //since its optional
+                            unt.setInclusion(includetokenUri);
+                        }
+                        ((TokenWrapper)spc.readPreviousPolicyEngineData()).setToken(unt);
+                    } catch (WSSPolicyException e) {
+                        // TODO Throw this out
+                        e.printStackTrace();
+                    }
+					initializedUsernameToken = true;
+				} catch (NoSuchMethodException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+					return new Boolean(false);
+				}
+			}
+			log.debug(spt.getTokenName());
+			PrimitiveAssertion pa = spc.getAssertion();
+			String text = pa.getStrValue();
+			if (text != null) {
+				text = text.trim();
+				log.debug("Value: '" + text.toString() + "'");
+			}
+		case SecurityProcessorContext.COMMIT:
+			break;
+		case SecurityProcessorContext.ABORT:
+			break;
+		}
+		return new Boolean(true);
+	}
+
+	public Object doWssUsernameToken10(SecurityProcessorContext spc) {
+		log.debug("Processing wssUsernameToken10");
+        if(spc.getAction() == 2) {
+            ((UsernameToken)spc.readCurrentPolicyEngineData()).setUseUTProfile11(false);
+        }
+		return new Boolean(true);
+	}
+
+	public Object doWssUsernameToken11(SecurityProcessorContext spc) {
+		log.debug("Processing wssUsernameToken11");
+        if(spc.getAction() == 2) {
+            ((UsernameToken)spc.readCurrentPolicyEngineData()).setUseUTProfile11(true);
+        }
+		return new Boolean(true);
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/Wss10Processor.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/Wss10Processor.java?rev=371870&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/Wss10Processor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy/parser/processors/Wss10Processor.java Tue Jan 24 01:13:40 2006
@@ -0,0 +1,148 @@
+/*
+ * 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.security.policy.parser.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.policy.PrimitiveAssertion;
+import org.apache.ws.security.policy.model.Wss10;
+import org.apache.ws.security.policy.parser.SecurityPolicy;
+import org.apache.ws.security.policy.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy.parser.SecurityProcessorContext;
+
+
+/**
+ * @author Werner Dittmann (werner@apache.org)
+ * 
+ */
+public class Wss10Processor {
+
+    private Log log = LogFactory.getLog(getClass());
+    
+	private boolean initializedWss10 = false;
+
+	/**
+	 * Intialize the Wss10 complex token.
+	 * 
+	 * This method creates a copy of the Wss10 token and sets the handler object
+	 * to the copy. Then it creates copies of the child tokens that are allowed
+	 * for Wss10. These tokens are:
+	 * 
+	 * These copies are also initialized with the handler object and then set as
+	 * child tokens of Wss10.
+	 * 
+	 * <p/> The handler object that must contain the methods
+	 * <code>doWss10</code>.
+	 * 
+	 * @param spt
+	 *            The token that will hold the child tokens.
+	 * @throws NoSuchMethodException
+	 */
+	public void initializeWss10(SecurityPolicyToken spt)
+			throws NoSuchMethodException {
+		SecurityPolicyToken tmpSpt = SecurityPolicy.mustSupportRefKeyIdentifier
+				.copy();
+		tmpSpt.setProcessTokenMethod(this);
+		spt.setChildToken(tmpSpt);
+
+		tmpSpt = SecurityPolicy.mustSupportRefIssuerSerial.copy();
+		tmpSpt.setProcessTokenMethod(this);
+		spt.setChildToken(tmpSpt);
+
+		tmpSpt = SecurityPolicy.mustSupportRefExternalUri.copy();
+		tmpSpt.setProcessTokenMethod(this);
+		spt.setChildToken(tmpSpt);
+
+		tmpSpt = SecurityPolicy.mustSupportRefEmbeddedToken.copy();
+		tmpSpt.setProcessTokenMethod(this);
+		spt.setChildToken(tmpSpt);
+	}
+
+	
+	public Object doWss10(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+
+		SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+
+		switch (spc.getAction()) {
+
+		case SecurityProcessorContext.START:
+			if (!initializedWss10) {
+				try {
+					initializeWss10(spt);
+					initializedWss10 = 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();
+				log.debug("Value: '" + text.toString() + "'");
+			}
+		case SecurityProcessorContext.COMMIT:
+			break;
+		case SecurityProcessorContext.ABORT:
+			break;
+		}
+		return new Boolean(true);
+	}
+	
+	public Object doMustSupportRefKeyIdentifier(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+        if(spc.getAction() == SecurityProcessorContext.COMMIT) {
+            ((Wss10)spc.readCurrentPolicyEngineData()).setMustSupportRefKeyIdentifier(true);
+        }
+		return new Boolean(true);
+	}
+
+	public Object doMustSupportRefIssuerSerial(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+        if(spc.getAction() == SecurityProcessorContext.COMMIT) {
+            ((Wss10)spc.readCurrentPolicyEngineData()).setMustSupportRefIssuerSerial(true);
+        }
+        return new Boolean(true);
+	}
+
+	public Object doMustSupportRefExternalURI(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+        if(spc.getAction() == SecurityProcessorContext.COMMIT) {
+            ((Wss10)spc.readCurrentPolicyEngineData()).setMustSupportRefExternalURI(true);
+        }
+        return new Boolean(true);
+	}
+
+	public Object doMustSupportRefEmbeddedToken(SecurityProcessorContext spc) {
+		log.debug("Processing "
+				+ spc.readCurrentSecurityToken().getTokenName() + ": "
+				+ SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+        if(spc.getAction() == SecurityProcessorContext.COMMIT) {
+            ((Wss10)spc.readCurrentPolicyEngineData()).setMustSupportRefEmbeddedToken(true);
+        }
+        return new Boolean(true);
+	}
+}