You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sa...@apache.org on 2006/09/12 11:23:26 UTC
svn commit: r442539 [3/4] - in
/webservices/axis2/trunk/java/modules/security: src/META-INF/services/
src/org/apache/rampart/ src/org/apache/ws/security/policy/
src/org/apache/ws/security/policy1/
src/org/apache/ws/security/policy1/extension/ src/org/a...
Added: webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/AlgorithmSuiteProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/AlgorithmSuiteProcessor.java?view=auto&rev=442539
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/AlgorithmSuiteProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/AlgorithmSuiteProcessor.java Tue Sep 12 02:23:24 2006
@@ -0,0 +1,384 @@
+/*
+ * 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.policy1.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.policy1.Constants;
+import org.apache.ws.security.policy1.WSSPolicyException;
+import org.apache.ws.security.policy1.model.AlgorithmSuite;
+import org.apache.ws.security.policy1.model.AlgorithmWrapper;
+import org.apache.ws.security.policy1.parser.SecurityPolicy;
+import org.apache.ws.security.policy1.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy1.parser.SecurityProcessorContext;
+
+
+public class AlgorithmSuiteProcessor {
+
+ private static final Log log = LogFactory.getLog(AlgorithmSuiteProcessor.class);
+
+ private boolean initializedAlgorithmSuite = false;
+
+ /**
+ * Intialize the AlgorithmSuite complex token.
+ *
+ * This method creates a copy of the AlgorithmSuite token and sets the
+ * handler object to the copy. Then it creates copies of the child tokens
+ * that are allowed for AlgorithmSuite. These tokens are:
+ *
+ * These copies are also initialized with the handler object and then set as
+ * child tokens of AlgorithmSuite.
+ *
+ * <p/> The handler object that must contain the methods
+ * <code>doAlgorithmSuite</code>.
+ *
+ * @param spt
+ * The token that will hold the child tokens.
+ * @throws NoSuchMethodException
+ */
+
+ private void initializeAlgorithmSuite(SecurityPolicyToken spt)
+ throws NoSuchMethodException {
+
+ SecurityPolicyToken tmpSpt;
+
+ tmpSpt = SecurityPolicy.basic256.copy();
+ tmpSpt.setProcessTokenMethod(this);
+ spt.setChildToken(tmpSpt);
+
+ tmpSpt = SecurityPolicy.basic192.copy();
+ tmpSpt.setProcessTokenMethod(this);
+ spt.setChildToken(tmpSpt);
+
+ tmpSpt = SecurityPolicy.basic128.copy();
+ tmpSpt.setProcessTokenMethod(this);
+ spt.setChildToken(tmpSpt);
+
+ tmpSpt = SecurityPolicy.tripleDes.copy();
+ tmpSpt.setProcessTokenMethod(this);
+ spt.setChildToken(tmpSpt);
+
+ tmpSpt = SecurityPolicy.basic256Rsa15.copy();
+ tmpSpt.setProcessTokenMethod(this);
+ spt.setChildToken(tmpSpt);
+
+ tmpSpt = SecurityPolicy.basic192Rsa15.copy();
+ tmpSpt.setProcessTokenMethod(this);
+ spt.setChildToken(tmpSpt);
+
+ tmpSpt = SecurityPolicy.basic128Rsa15.copy();
+ tmpSpt.setProcessTokenMethod(this);
+ spt.setChildToken(tmpSpt);
+
+ tmpSpt = SecurityPolicy.tripleDesRsa15.copy();
+ tmpSpt.setProcessTokenMethod(this);
+ spt.setChildToken(tmpSpt);
+
+ tmpSpt = SecurityPolicy.basic256Sha256.copy();
+ tmpSpt.setProcessTokenMethod(this);
+ spt.setChildToken(tmpSpt);
+
+ tmpSpt = SecurityPolicy.basic192Sha256.copy();
+ tmpSpt.setProcessTokenMethod(this);
+ spt.setChildToken(tmpSpt);
+
+ tmpSpt = SecurityPolicy.basic128Sha256.copy();
+ tmpSpt.setProcessTokenMethod(this);
+ spt.setChildToken(tmpSpt);
+
+ tmpSpt = SecurityPolicy.tripleDesSha256.copy();
+ tmpSpt.setProcessTokenMethod(this);
+ spt.setChildToken(tmpSpt);
+
+ tmpSpt = SecurityPolicy.basic256Sha256Rsa15.copy();
+ tmpSpt.setProcessTokenMethod(this);
+ spt.setChildToken(tmpSpt);
+
+ tmpSpt = SecurityPolicy.basic192Sha256Rsa15.copy();
+ tmpSpt.setProcessTokenMethod(this);
+ spt.setChildToken(tmpSpt);
+
+ tmpSpt = SecurityPolicy.basic128Sha256Rsa15.copy();
+ tmpSpt.setProcessTokenMethod(this);
+ spt.setChildToken(tmpSpt);
+
+ tmpSpt = SecurityPolicy.tripleDesSha256Rsa15.copy();
+ tmpSpt.setProcessTokenMethod(this);
+ spt.setChildToken(tmpSpt);
+
+ tmpSpt = SecurityPolicy.inclusiveC14N.copy();
+ tmpSpt.setProcessTokenMethod(this);
+ spt.setChildToken(tmpSpt);
+
+ tmpSpt = SecurityPolicy.soapNormalization10.copy();
+ tmpSpt.setProcessTokenMethod(this);
+ spt.setChildToken(tmpSpt);
+
+ tmpSpt = SecurityPolicy.strTransform10.copy();
+ tmpSpt.setProcessTokenMethod(this);
+ spt.setChildToken(tmpSpt);
+
+ tmpSpt = SecurityPolicy.xPath10.copy();
+ tmpSpt.setProcessTokenMethod(this);
+ spt.setChildToken(tmpSpt);
+
+ tmpSpt = SecurityPolicy.xPathFilter20.copy();
+ tmpSpt.setProcessTokenMethod(this);
+ spt.setChildToken(tmpSpt);
+ }
+
+ public Object doAlgorithmSuite(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+
+ SecurityPolicyToken spt = spc.readCurrentSecurityToken();
+ switch (spc.getAction()) {
+
+ case SecurityProcessorContext.START:
+ if (!initializedAlgorithmSuite) {
+ try {
+ initializeAlgorithmSuite(spt);
+ initializedAlgorithmSuite = true;
+ } catch (NoSuchMethodException e) {
+ log.error(e.getMessage(), e);
+ 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 doBasic256(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ return this.setAlgoGroup(spc);
+ }
+
+ public Object doBasic192(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ return this.setAlgoGroup(spc);
+ }
+
+ public Object doBasic128(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ return this.setAlgoGroup(spc);
+ }
+
+ public Object doTripleDes(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ return this.setAlgoGroup(spc);
+ }
+
+ public Object doBasic256Rsa15(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ return this.setAlgoGroup(spc);
+ }
+
+ public Object doBasic192Rsa15(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ return this.setAlgoGroup(spc);
+ }
+
+ public Object doBasic128Rsa15(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ return this.setAlgoGroup(spc);
+ }
+
+ public Object doTripleDesRsa15(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ return this.setAlgoGroup(spc);
+ }
+
+ public Object doBasic256Sha256(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ return this.setAlgoGroup(spc);
+ }
+
+ public Object doBasic192Sha256(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ return this.setAlgoGroup(spc);
+ }
+
+ public Object doBasic128Sha256(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ return this.setAlgoGroup(spc);
+ }
+
+ public Object doTripleDesSha256(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ return this.setAlgoGroup(spc);
+ }
+
+ public Object doBasic256Sha256Rsa15(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ return this.setAlgoGroup(spc);
+ }
+
+ public Object doBasic192Sha256Rsa15(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ return this.setAlgoGroup(spc);
+ }
+
+ public Object doBasic128Sha256Rsa15(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+
+ return this.setAlgoGroup(spc);
+ }
+
+ public Object doTripleDesSha256Rsa15(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ return this.setAlgoGroup(spc);
+ }
+
+ public Object doInclusiveC14N(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ AlgorithmSuite algoSuite = (AlgorithmSuite)spc.readCurrentPolicyEngineData();
+ if(spc.getAction() == SecurityProcessorContext.START) {
+ try {
+ algoSuite.setC14n(Constants.C14N);
+ } catch (WSSPolicyException e) {
+ log.error(e.getMessage(), e);
+ return new Boolean(false);
+ }
+ }
+ return new Boolean(true);
+ }
+
+ public Object doSoapNormalization10(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ AlgorithmSuite algoSuite = (AlgorithmSuite)spc.readCurrentPolicyEngineData();
+ if(spc.getAction() == SecurityProcessorContext.START) {
+ try {
+ algoSuite.setSoapNormalization(Constants.SNT);
+ } catch (WSSPolicyException e) {
+ log.error(e.getMessage(), e);
+ return new Boolean(false);
+ }
+ }
+ return new Boolean(true);
+ }
+
+ public Object doStrTransform10(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ AlgorithmSuite algoSuite = (AlgorithmSuite)spc.readCurrentPolicyEngineData();
+ if(spc.getAction() == SecurityProcessorContext.START) {
+ try {
+ algoSuite.setStrTransform(Constants.STRT10);
+ } catch (WSSPolicyException e) {
+ log.error(e.getMessage(), e);
+ return new Boolean(false);
+ }
+ }
+ return new Boolean(true);
+ }
+
+ public Object doXPath10(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ AlgorithmSuite algoSuite = (AlgorithmSuite)spc.readCurrentPolicyEngineData();
+ if(spc.getAction() == SecurityProcessorContext.START) {
+ try {
+ algoSuite.setXPath(Constants.XPATH);
+ } catch (WSSPolicyException e) {
+ log.error(e.getMessage(), e);
+ return new Boolean(false);
+ }
+ }
+ return new Boolean(true);
+ }
+
+ public Object doXPathFilter20(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ AlgorithmSuite algoSuite = (AlgorithmSuite)spc.readCurrentPolicyEngineData();
+ if(spc.getAction() == SecurityProcessorContext.START) {
+ try {
+ algoSuite.setXPath(Constants.XPATH20);
+ } catch (WSSPolicyException e) {
+ log.error(e.getMessage(), e);
+ return new Boolean(false);
+ }
+ }
+ return new Boolean(true);
+ }
+
+ private Boolean setAlgoGroup(SecurityProcessorContext spc) {
+ if(spc.getAction() == SecurityProcessorContext.START) {
+ try {
+ AlgorithmSuite algoSuite = (AlgorithmSuite)spc.readCurrentPolicyEngineData();
+ algoSuite.setAlgorithmSuite(spc.getAssertion().getName().getLocalPart());
+ ((AlgorithmWrapper)spc.readPreviousPolicyEngineData()).setAlgorithmSuite(algoSuite);
+ } catch (WSSPolicyException e) {
+ log.error(e.getMessage(), e);
+ return new Boolean(false);
+ }
+ }
+ return new Boolean(true);
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/AsymmetricBindingProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/AsymmetricBindingProcessor.java?view=auto&rev=442539
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/AsymmetricBindingProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/AsymmetricBindingProcessor.java Tue Sep 12 02:23:24 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 org.apache.ws.security.policy1.parser.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.policy1.model.Binding;
+import org.apache.ws.security.policy1.parser.SecurityPolicy;
+import org.apache.ws.security.policy1.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy1.parser.SecurityProcessorContext;
+
+public class AsymmetricBindingProcessor {
+
+ private static final Log log = LogFactory.getLog(AsymmetricBindingProcessor.class);
+
+ 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) {
+ log.error(e.getMessage(), e);
+ 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() == SecurityProcessorContext.START) {
+ ((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()]);
+ 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/policy1/parser/processors/EncryptedPartsElementsProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/EncryptedPartsElementsProcessor.java?view=auto&rev=442539
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/EncryptedPartsElementsProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/EncryptedPartsElementsProcessor.java Tue Sep 12 02:23:24 2006
@@ -0,0 +1,205 @@
+/*
+ * 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.policy1.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.policy1.model.Header;
+import org.apache.ws.security.policy1.model.PolicyEngineData;
+import org.apache.ws.security.policy1.model.SignedEncryptedElements;
+import org.apache.ws.security.policy1.model.SignedEncryptedParts;
+import org.apache.ws.security.policy1.model.SupportingToken;
+import org.apache.ws.security.policy1.parser.SecurityPolicy;
+import org.apache.ws.security.policy1.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy1.parser.SecurityProcessorContext;
+
+import javax.xml.namespace.QName;
+
+
+public class EncryptedPartsElementsProcessor {
+
+ private static final Log log = LogFactory.getLog(EncryptedPartsElementsProcessor.class);
+
+ 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) {
+ log.error(e.getMessage(), e);
+ 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) {
+ log.error(e.getMessage(), e);
+ 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() == SecurityProcessorContext.START) {
+ ((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() == SecurityProcessorContext.START) {
+ //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() == SecurityProcessorContext.START) {
+ ((SignedEncryptedElements) spc.readCurrentPolicyEngineData())
+ .addXPathExpression(spc.getAssertion().getStrValue());
+ }
+ return new Boolean(true);
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/EndorsingSupportingTokensProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/EndorsingSupportingTokensProcessor.java?view=auto&rev=442539
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/EndorsingSupportingTokensProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/EndorsingSupportingTokensProcessor.java Tue Sep 12 02:23:24 2006
@@ -0,0 +1,111 @@
+/*
+ * 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.policy1.parser.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.policy1.model.PolicyEngineData;
+import org.apache.ws.security.policy1.parser.SecurityPolicy;
+import org.apache.ws.security.policy1.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy1.parser.SecurityProcessorContext;
+
+public class EndorsingSupportingTokensProcessor {
+
+ private static final Log log = LogFactory.getLog(EndorsingSupportingTokensProcessor.class);
+
+ 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);
+ PolicyEngineData ped = spc.readCurrentPolicyEngineData();
+ if(ped != null) {
+ //This ped must be a Binding
+ //TODO: Support Supporting tokens in bindings
+ }
+ initializedEndorsingSupportingTokens = true;
+ } catch (NoSuchMethodException e) {
+ log.error(e.getMessage(), e);
+ 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/policy1/parser/processors/InitiatorRecipientTokenProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/InitiatorRecipientTokenProcessor.java?view=auto&rev=442539
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/InitiatorRecipientTokenProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/InitiatorRecipientTokenProcessor.java Tue Sep 12 02:23:24 2006
@@ -0,0 +1,135 @@
+/*
+ * 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.policy1.parser.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.policy1.model.AsymmetricBinding;
+import org.apache.ws.security.policy1.model.InitiatorToken;
+import org.apache.ws.security.policy1.model.RecipientToken;
+import org.apache.ws.security.policy1.parser.SecurityPolicy;
+import org.apache.ws.security.policy1.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy1.parser.SecurityProcessorContext;
+
+
+public class InitiatorRecipientTokenProcessor {
+
+ private static final Log log = LogFactory.getLog(InitiatorRecipientTokenProcessor.class);
+
+ 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) {
+ log.error(e.getMessage(), e);
+ 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) {
+ log.error(e.getMessage(), e);
+ 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/policy1/parser/processors/LayoutProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/LayoutProcessor.java?view=auto&rev=442539
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/LayoutProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/LayoutProcessor.java Tue Sep 12 02:23:24 2006
@@ -0,0 +1,172 @@
+/*
+ * 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.policy1.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.policy1.WSSPolicyException;
+import org.apache.ws.security.policy1.model.Binding;
+import org.apache.ws.security.policy1.model.Layout;
+import org.apache.ws.security.policy1.parser.SecurityPolicy;
+import org.apache.ws.security.policy1.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy1.parser.SecurityProcessorContext;
+
+
+public class LayoutProcessor {
+
+ private static final Log log = LogFactory.getLog(LayoutProcessor.class);
+
+ 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) {
+ log.error(e.getMessage(), e);
+ 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() == SecurityProcessorContext.START) {
+ Layout layout = (Layout) spc.readCurrentPolicyEngineData();
+ layout.setValue(spc.getAssertion().getName().getLocalPart());
+ ((Binding)spc.readPreviousPolicyEngineData()).setLayout(layout);
+ }
+ } catch (WSSPolicyException e) {
+ log.error(e.getMessage(), e);
+ return new Boolean(false);
+ }
+ return new Boolean(true);
+ }
+
+ public Object doLax(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ try {
+ if(spc.getAction() == SecurityProcessorContext.START) {
+ Layout layout = (Layout) spc.readCurrentPolicyEngineData();
+ layout.setValue(spc.getAssertion().getName().getLocalPart());
+ ((Binding)spc.readPreviousPolicyEngineData()).setLayout(layout);
+ }
+ } catch (WSSPolicyException e) {
+ log.error(e.getMessage(), e);
+ return new Boolean(false);
+ }
+ return new Boolean(true);
+ }
+
+ public Object doLaxTsFirst(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ try {
+ if(spc.getAction() == SecurityProcessorContext.START) {
+ Layout layout = (Layout) spc.readCurrentPolicyEngineData();
+ layout.setValue(spc.getAssertion().getName().getLocalPart());
+ ((Binding)spc.readPreviousPolicyEngineData()).setLayout(layout);
+ }
+ } catch (WSSPolicyException e) {
+ log.error(e.getMessage(), e);
+ return new Boolean(false);
+ }
+ return new Boolean(true);
+ }
+
+ public Object doLaxTsLast(SecurityProcessorContext spc) {
+ log.debug("Processing "
+ + spc.readCurrentSecurityToken().getTokenName() + ": "
+ + SecurityProcessorContext.ACTION_NAMES[spc.getAction()]);
+ try {
+ if(spc.getAction() == SecurityProcessorContext.START) {
+ Layout layout = (Layout) spc.readCurrentPolicyEngineData();
+ layout.setValue(spc.getAssertion().getName().getLocalPart());
+ ((Binding)spc.readPreviousPolicyEngineData()).setLayout(layout);
+ }
+ } catch (WSSPolicyException e) {
+ log.error(e.getMessage(), e);
+ return new Boolean(false);
+ }
+ return new Boolean(true);
+ }
+}
Added: webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/SignEncProtectTokenProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/SignEncProtectTokenProcessor.java?view=auto&rev=442539
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/SignEncProtectTokenProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/SignEncProtectTokenProcessor.java Tue Sep 12 02:23:24 2006
@@ -0,0 +1,188 @@
+/*
+ * 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.policy1.parser.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.policy1.WSSPolicyException;
+import org.apache.ws.security.policy1.model.ProtectionToken;
+import org.apache.ws.security.policy1.model.SymmetricBinding;
+import org.apache.ws.security.policy1.parser.SecurityPolicy;
+import org.apache.ws.security.policy1.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy1.parser.SecurityProcessorContext;
+
+
+public class SignEncProtectTokenProcessor {
+
+ private static final Log log = LogFactory.getLog(SignEncProtectTokenProcessor.class);
+
+ 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) {
+ log.error(e.getMessage(), e);
+ 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) {
+ log.error(e.getMessage(), e);
+ 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) {
+ log.error(e.getMessage(), e);
+ return new Boolean(false);
+ }
+ initializedProtectionToken = true;
+ } catch (NoSuchMethodException e) {
+ log.error(e.getMessage(), e);
+ 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/policy1/parser/processors/SignedEndorsingSupportingTokensProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/SignedEndorsingSupportingTokensProcessor.java?view=auto&rev=442539
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/SignedEndorsingSupportingTokensProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/SignedEndorsingSupportingTokensProcessor.java Tue Sep 12 02:23:24 2006
@@ -0,0 +1,111 @@
+/*
+ * 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.policy1.parser.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.policy1.model.PolicyEngineData;
+import org.apache.ws.security.policy1.parser.SecurityPolicy;
+import org.apache.ws.security.policy1.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy1.parser.SecurityProcessorContext;
+
+public class SignedEndorsingSupportingTokensProcessor {
+
+ private static final Log log = LogFactory.getLog(SignedEndorsingSupportingTokensProcessor.class);
+
+ 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);
+ PolicyEngineData ped = spc.readCurrentPolicyEngineData();
+ if(ped != null) {
+ //This ped must be a Binding
+ //TODO: Support Supporting tokens in bindings
+ }
+ initializedSignedEndorsingSupportingTokens = true;
+ } catch (NoSuchMethodException e) {
+ log.error(e.getMessage(), e);
+ 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/policy1/parser/processors/SignedPartsElementsProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/SignedPartsElementsProcessor.java?view=auto&rev=442539
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/SignedPartsElementsProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/SignedPartsElementsProcessor.java Tue Sep 12 02:23:24 2006
@@ -0,0 +1,210 @@
+/*
+ * 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.policy1.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.policy1.model.Header;
+import org.apache.ws.security.policy1.model.PolicyEngineData;
+import org.apache.ws.security.policy1.model.SignedEncryptedElements;
+import org.apache.ws.security.policy1.model.SignedEncryptedParts;
+import org.apache.ws.security.policy1.model.SupportingToken;
+import org.apache.ws.security.policy1.parser.SecurityPolicy;
+import org.apache.ws.security.policy1.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy1.parser.SecurityProcessorContext;
+
+import javax.xml.namespace.QName;
+
+
+public class SignedPartsElementsProcessor {
+
+ private static final Log log = LogFactory.getLog(SignedPartsElementsProcessor.class);
+
+ 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) {
+ log.error(e.getMessage(), e);
+ 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) {
+ log.error(e.getMessage(), e);
+ 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() == SecurityProcessorContext.START) {
+ ((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() == SecurityProcessorContext.START) {
+ //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() == SecurityProcessorContext.START) {
+ ((SignedEncryptedElements) spc.readCurrentPolicyEngineData())
+ .addXPathExpression(spc.getAssertion().getStrValue());
+ }
+ return new Boolean(true);
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/SignedSupportingTokensProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/SignedSupportingTokensProcessor.java?view=auto&rev=442539
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/SignedSupportingTokensProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/SignedSupportingTokensProcessor.java Tue Sep 12 02:23:24 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.policy1.parser.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.policy1.model.PolicyEngineData;
+import org.apache.ws.security.policy1.parser.SecurityPolicy;
+import org.apache.ws.security.policy1.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy1.parser.SecurityProcessorContext;
+
+public class SignedSupportingTokensProcessor {
+
+ private static final Log log = LogFactory.getLog(SignedSupportingTokensProcessor.class);
+
+ 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);
+ PolicyEngineData ped = spc.readCurrentPolicyEngineData();
+ if(ped != null) {
+ //This ped must be a Binding
+ //TODO: Support Supporting tokens in bindings
+ }
+ initializedSignedSupportingTokens = true;
+ } catch (NoSuchMethodException e) {
+ log.error(e.getMessage(), e);
+ 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/policy1/parser/processors/SupportingTokensProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/SupportingTokensProcessor.java?view=auto&rev=442539
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/SupportingTokensProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/SupportingTokensProcessor.java Tue Sep 12 02:23:24 2006
@@ -0,0 +1,112 @@
+/*
+ * 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.policy1.parser.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.policy1.model.PolicyEngineData;
+import org.apache.ws.security.policy1.parser.SecurityPolicy;
+import org.apache.ws.security.policy1.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy1.parser.SecurityProcessorContext;
+
+public class SupportingTokensProcessor {
+
+ private static final Log log = LogFactory.getLog(SupportingTokensProcessor.class);
+
+ 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);
+ PolicyEngineData ped = spc.readCurrentPolicyEngineData();
+ if(ped != null) {
+ //This ped must be a Binding
+ //TODO: Support Supporting tokens in bindings
+ }
+ spc.readPreviousPolicyEngineData();
+ initializedSupportingTokens = true;
+ } catch (NoSuchMethodException e) {
+ log.error(e.getMessage(), e);
+ 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/policy1/parser/processors/SymmetricBindingProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/SymmetricBindingProcessor.java?view=auto&rev=442539
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/SymmetricBindingProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/parser/processors/SymmetricBindingProcessor.java Tue Sep 12 02:23:24 2006
@@ -0,0 +1,189 @@
+/*
+ * 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.policy1.parser.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.policy1.WSSPolicyException;
+import org.apache.ws.security.policy1.model.Binding;
+import org.apache.ws.security.policy1.model.PolicyEngineData;
+import org.apache.ws.security.policy1.model.SymmetricBinding;
+import org.apache.ws.security.policy1.parser.SecurityPolicy;
+import org.apache.ws.security.policy1.parser.SecurityPolicyToken;
+import org.apache.ws.security.policy1.parser.SecurityProcessorContext;
+
+
+public class SymmetricBindingProcessor {
+
+ private static final Log log = LogFactory.getLog(SymmetricBindingProcessor.class);
+
+ 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) {
+ log.error(e.getMessage(), e);
+ 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() == SecurityProcessorContext.START) {
+ ((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() == SecurityProcessorContext.START) {
+ try {
+ ((SymmetricBinding) spc.readCurrentPolicyEngineData()).setProtectionOrder(spc
+ .getAssertion().getName().getLocalPart());
+ } catch (WSSPolicyException e) {
+ log.error(e.getMessage(), e);
+ return new Boolean(false);
+ }
+ }
+ 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);
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org