You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by gi...@apache.org on 2011/12/04 21:33:12 UTC
svn commit: r1210203 [3/16] - in
/webservices/wss4j/branches/swssf/rampart-policy: ./
src/main/java/META-INF/ src/main/java/org/apache/ws/secpolicy/
src/main/java/org/apache/ws/secpolicy/builders/
src/main/java/org/apache/ws/secpolicy/model/ src/main/j...
Modified: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/AlgorithmSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/AlgorithmSuiteBuilder.java?rev=1210203&r1=1197660&r2=1210203&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/AlgorithmSuiteBuilder.java (original)
+++ webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/AlgorithmSuiteBuilder.java Sun Dec 4 20:33:05 2011
@@ -1,66 +1,57 @@
-/*
- * Copyright 2001-2004 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.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.secpolicy12.builders;
+package org.apache.ws.secpolicy.builders;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.axiom.om.OMElement;
import org.apache.neethi.Assertion;
import org.apache.neethi.AssertionBuilderFactory;
import org.apache.neethi.Policy;
-import org.apache.neethi.PolicyEngine;
import org.apache.neethi.builders.AssertionBuilder;
+import org.apache.ws.secpolicy.SP11Constants;
+import org.apache.ws.secpolicy.SP13Constants;
import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.SP12Constants;
-import org.apache.ws.secpolicy.WSSPolicyException;
+import org.apache.ws.secpolicy.SPUtils;
import org.apache.ws.secpolicy.model.AlgorithmSuite;
+import org.w3c.dom.Element;
import javax.xml.namespace.QName;
-public class AlgorithmSuiteBuilder implements AssertionBuilder<OMElement> {
-
- public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
-
- AlgorithmSuite algorithmSuite = new AlgorithmSuite(SPConstants.SP_V12);
-
- Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
- policy = (Policy) policy.normalize(false);
-
- Iterator iterAlterns = policy.getAlternatives();
- List assertions = ((List) iterAlterns.next());
-
- processAlternative(assertions, algorithmSuite);
-
+/**
+ * @author $Author$
+ * @version $Revision$ $Date$
+ */
+public class AlgorithmSuiteBuilder implements AssertionBuilder<Element> {
+
+ public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+
+ final SPConstants.SPVersion spVersion = SPConstants.SPVersion.getSPVersion(element.getNamespaceURI());
+ final Element nestedPolicyElement = SPUtils.getFirstPolicyChildElement(element);
+ final Policy nestedPolicy = nestedPolicyElement != null ? factory.getPolicyEngine().getPolicy(nestedPolicyElement) : new Policy();
+ AlgorithmSuite algorithmSuite = new AlgorithmSuite(
+ spVersion,
+ nestedPolicy
+ );
+ algorithmSuite.setOptional(SPUtils.isOptional(element));
+ algorithmSuite.setIgnorable(SPUtils.isIgnorable(element));
return algorithmSuite;
-
- }
-
- private void processAlternative(List assertions, AlgorithmSuite algorithmSuite) {
- Iterator iterator = assertions.iterator();
- Assertion assertion = ((Assertion) iterator.next());
- String name = assertion.getName().getLocalPart();
- try {
- algorithmSuite.setAlgorithmSuite(name);
- } catch (WSSPolicyException e) {
- throw new IllegalArgumentException(e);
- }
}
-
+
public QName[] getKnownElements() {
- return new QName[] {SP12Constants.ALGORITHM_SUITE};
+ return new QName[]{SP13Constants.ALGORITHM_SUITE, SP11Constants.ALGORITHM_SUITE};
}
}
Propchange: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/AlgorithmSuiteBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/AsymmetricBindingBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/AsymmetricBindingBuilder.java?rev=1210203&r1=1197660&r2=1210203&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/AsymmetricBindingBuilder.java (original)
+++ webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/AsymmetricBindingBuilder.java Sun Dec 4 20:33:05 2011
@@ -1,107 +1,59 @@
-/*
- * Copyright 2001-2004 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.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.secpolicy12.builders;
+package org.apache.ws.secpolicy.builders;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMElement;
import org.apache.neethi.Assertion;
import org.apache.neethi.AssertionBuilderFactory;
import org.apache.neethi.Policy;
-import org.apache.neethi.PolicyEngine;
import org.apache.neethi.builders.AssertionBuilder;
+import org.apache.ws.secpolicy.SP11Constants;
+import org.apache.ws.secpolicy.SP13Constants;
import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.SP12Constants;
-import org.apache.ws.secpolicy.model.AlgorithmSuite;
+import org.apache.ws.secpolicy.SPUtils;
import org.apache.ws.secpolicy.model.AsymmetricBinding;
-import org.apache.ws.secpolicy.model.InitiatorToken;
-import org.apache.ws.secpolicy.model.Layout;
-import org.apache.ws.secpolicy.model.RecipientToken;
-
-public class AsymmetricBindingBuilder implements AssertionBuilder<OMElement> {
-
- public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
-
- AsymmetricBinding asymmetricBinding = new AsymmetricBinding(SPConstants.SP_V12);
-
- Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
- policy = (Policy) policy.normalize(false);
-
- for (Iterator iterator = policy.getAlternatives(); iterator.hasNext();) {
- processAlternative((List) iterator.next(), asymmetricBinding);
-
- /*
- * since there should be only one alternative
- */
- break;
- }
-
+import org.w3c.dom.Element;
+
+import javax.xml.namespace.QName;
+
+/**
+ * @author $Author$
+ * @version $Revision$ $Date$
+ */
+public class AsymmetricBindingBuilder implements AssertionBuilder<Element> {
+
+ public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+
+ final SPConstants.SPVersion spVersion = SPConstants.SPVersion.getSPVersion(element.getNamespaceURI());
+ final Element nestedPolicyElement = SPUtils.getFirstPolicyChildElement(element);
+ final Policy nestedPolicy = nestedPolicyElement != null ? factory.getPolicyEngine().getPolicy(nestedPolicyElement) : new Policy();
+ AsymmetricBinding asymmetricBinding = new AsymmetricBinding(
+ spVersion,
+ nestedPolicy
+ );
+ asymmetricBinding.setOptional(SPUtils.isOptional(element));
+ asymmetricBinding.setIgnorable(SPUtils.isIgnorable(element));
return asymmetricBinding;
}
-
- private void processAlternative(List assertions, AsymmetricBinding asymmetricBinding) {
-
- Assertion assertion;
- QName name;
-
- for (Iterator iterator = assertions.iterator(); iterator.hasNext();) {
- assertion = (Assertion) iterator.next();
- name = assertion.getName();
-
- if (SP12Constants.INITIATOR_TOKEN.equals(name)) {
- asymmetricBinding.setInitiatorToken((InitiatorToken) assertion);
-
- } else if (SP12Constants.RECIPIENT_TOKEN.equals(name)){
- asymmetricBinding.setRecipientToken((RecipientToken) assertion);
-
- } else if (SP12Constants.ALGORITHM_SUITE.equals(name)) {
- asymmetricBinding.setAlgorithmSuite((AlgorithmSuite) assertion);
-
- } else if (SP12Constants.LAYOUT.equals(name)) {
- asymmetricBinding.setLayout((Layout) assertion);
-
- } else if (SP12Constants.INCLUDE_TIMESTAMP.equals(name)) {
- asymmetricBinding.setIncludeTimestamp(true);
- asymmetricBinding.setIncludeTimestampOptional(assertion.isOptional());
-
- } else if (SP12Constants.ENCRYPT_BEFORE_SIGNING.equals(name)) {
- asymmetricBinding.setProtectionOrder(SPConstants.ENCRYPT_BEFORE_SIGNING);
-
- } else if (SP12Constants.SIGN_BEFORE_ENCRYPTING.equals(name)) {
- asymmetricBinding.setProtectionOrder(SPConstants.SIGN_BEFORE_ENCRYPTING);
-
- } else if (SP12Constants.ENCRYPT_SIGNATURE.equals(name)) {
- asymmetricBinding.setSignatureProtection(true);
-
- } else if (SP12Constants.PROTECT_TOKENS.equals(name)) {
- asymmetricBinding.setTokenProtection(true);
-
- } else if (SPConstants.ONLY_SIGN_ENTIRE_HEADERS_AND_BODY
- .equals(name.getLocalPart())) {
- asymmetricBinding.setEntireHeadersAndBodySignatures(true);
- }
- }
- }
-
+
public QName[] getKnownElements() {
- return new QName[]{SP12Constants.ASYMMETRIC_BINDING};
+ return new QName[]{SP13Constants.ASYMMETRIC_BINDING, SP11Constants.ASYMMETRIC_BINDING};
}
-
+
}
\ No newline at end of file
Propchange: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/AsymmetricBindingBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/ContentEncryptedElementsBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/ContentEncryptedElementsBuilder.java?rev=1210203&r1=1197660&r2=1210203&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/ContentEncryptedElementsBuilder.java (original)
+++ webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/ContentEncryptedElementsBuilder.java Sun Dec 4 20:33:05 2011
@@ -1,67 +1,53 @@
-/*
- * Copyright 2001-2004 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.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.secpolicy12.builders;
+package org.apache.ws.secpolicy.builders;
-import java.util.Iterator;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMAttribute;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMNamespace;
import org.apache.neethi.Assertion;
import org.apache.neethi.AssertionBuilderFactory;
-import org.apache.neethi.builders.AssertionBuilder;
+import org.apache.ws.secpolicy.SP13Constants;
import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.SP12Constants;
+import org.apache.ws.secpolicy.SPUtils;
import org.apache.ws.secpolicy.model.ContentEncryptedElements;
+import org.apache.ws.secpolicy.model.XPath;
+import org.w3c.dom.Element;
+
+import javax.xml.namespace.QName;
+import java.util.List;
-public class ContentEncryptedElementsBuilder implements AssertionBuilder<OMElement> {
+/**
+ * @author $Author$
+ * @version $Revision$ $Date$
+ */
+public class ContentEncryptedElementsBuilder extends EncryptedElementsBuilder {
+
+ public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException {
-
- public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
-
- ContentEncryptedElements contentEncryptedElements = new ContentEncryptedElements(SPConstants.SP_V12);
- OMAttribute attrXPathVersion = element.getAttribute(SP12Constants.ATTR_XPATH_VERSION);
-
- if (attrXPathVersion != null) {
- contentEncryptedElements.setXPathVersion(attrXPathVersion.getAttributeValue());
- }
-
- for (Iterator iterator = element.getChildElements(); iterator.hasNext();) {
- processElement((OMElement) iterator.next(),contentEncryptedElements);
- }
-
+ final SPConstants.SPVersion spVersion = SPConstants.SPVersion.getSPVersion(element.getNamespaceURI());
+ final String xPathVersion = getXPathVersion(element);
+ final List<XPath> xPaths = getXPathExpressions(element, spVersion);
+ ContentEncryptedElements contentEncryptedElements = new ContentEncryptedElements(spVersion, xPathVersion, xPaths);
+ contentEncryptedElements.setOptional(SPUtils.isOptional(element));
+ contentEncryptedElements.setIgnorable(SPUtils.isIgnorable(element));
return contentEncryptedElements;
}
-
- public QName[] getKnownElements() {
- return new QName[] {SP12Constants.CONTENT_ENCRYPTED_ELEMENTS};
- }
- private void processElement(OMElement element, ContentEncryptedElements parent) {
- QName name = element.getQName();
- if (SP12Constants.XPATH.equals(name)) {
- parent.addXPathExpression(element.getText());
- Iterator namespaces = element.getNamespacesInScope();
- while (namespaces.hasNext()) {
- OMNamespace nm = (OMNamespace) namespaces.next();
- parent.addDeclaredNamespaces(nm.getNamespaceURI(), nm.getPrefix());
- }
- }
+ public QName[] getKnownElements() {
+ return new QName[]{SP13Constants.CONTENT_ENCRYPTED_ELEMENTS};
}
-
}
Propchange: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/ContentEncryptedElementsBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/EncryptedElementsBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/EncryptedElementsBuilder.java?rev=1210203&r1=1197660&r2=1210203&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/EncryptedElementsBuilder.java (original)
+++ webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/EncryptedElementsBuilder.java Sun Dec 4 20:33:05 2011
@@ -1,77 +1,54 @@
-/*
- * Copyright 2001-2004 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.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.secpolicy12.builders;
+package org.apache.ws.secpolicy.builders;
-import java.util.Iterator;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMAttribute;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMNamespace;
import org.apache.neethi.Assertion;
import org.apache.neethi.AssertionBuilderFactory;
-import org.apache.neethi.Constants;
-import org.apache.neethi.builders.AssertionBuilder;
+import org.apache.ws.secpolicy.SP11Constants;
+import org.apache.ws.secpolicy.SP13Constants;
import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.SP12Constants;
-import org.apache.ws.secpolicy.model.SignedEncryptedElements;
+import org.apache.ws.secpolicy.SPUtils;
+import org.apache.ws.secpolicy.model.EncryptedElements;
+import org.apache.ws.secpolicy.model.XPath;
+import org.w3c.dom.Element;
-public class EncryptedElementsBuilder implements AssertionBuilder<OMElement> {
+import javax.xml.namespace.QName;
+import java.util.List;
- public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
- SignedEncryptedElements signedEncryptedElements = new SignedEncryptedElements(false, SPConstants.SP_V12);
-
- OMAttribute attribute = element.getAttribute(SP12Constants.ATTR_XPATH_VERSION);
- if (attribute != null) {
- signedEncryptedElements.setXPathVersion(attribute.getAttributeValue());
- }
-
- for (Iterator iterator = element.getChildElements(); iterator.hasNext();) {
- processElement((OMElement) iterator.next(), signedEncryptedElements);
- }
-
- OMAttribute isOptional = element
- .getAttribute(Constants.Q_ELEM_OPTIONAL_ATTR);
- if (isOptional != null) {
- signedEncryptedElements.setOptional(Boolean.valueOf(isOptional
- .getAttributeValue()).booleanValue());
- }
-
- return signedEncryptedElements;
- }
-
-
-
- public QName[] getKnownElements() {
- return new QName[] {SP12Constants.ENCRYPTED_ELEMENTS};
- }
+/**
+ * @author $Author$
+ * @version $Revision$ $Date$
+ */
+public class EncryptedElementsBuilder extends SignedElementsBuilder {
+ public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+ final SPConstants.SPVersion spVersion = SPConstants.SPVersion.getSPVersion(element.getNamespaceURI());
+ final String xPathVersion = getXPathVersion(element);
+ final List<XPath> xPaths = getXPathExpressions(element, spVersion);
+ EncryptedElements encryptedElements = new EncryptedElements(spVersion, xPathVersion, xPaths);
+ encryptedElements.setOptional(SPUtils.isOptional(element));
+ encryptedElements.setIgnorable(SPUtils.isIgnorable(element));
+ return encryptedElements;
+ }
- private void processElement(OMElement element, SignedEncryptedElements parent) {
- if (SP12Constants.XPATH.equals(element.getQName())) {
- parent.addXPathExpression(element.getText());
- Iterator namespaces = element.getNamespacesInScope();
- while (namespaces.hasNext()) {
- OMNamespace nm = (OMNamespace) namespaces.next();
- parent.addDeclaredNamespaces(nm.getNamespaceURI(), nm.getPrefix());
- }
- }
+ public QName[] getKnownElements() {
+ return new QName[]{SP13Constants.ENCRYPTED_ELEMENTS, SP11Constants.ENCRYPTED_ELEMENTS};
}
-
-
}
Propchange: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/EncryptedElementsBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/EncryptedPartsBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/EncryptedPartsBuilder.java?rev=1210203&r1=1197660&r2=1210203&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/EncryptedPartsBuilder.java (original)
+++ webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/EncryptedPartsBuilder.java Sun Dec 4 20:33:05 2011
@@ -1,87 +1,58 @@
-/*
- * Copyright 2001-2004 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.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.secpolicy.builders;
-package org.apache.ws.secpolicy12.builders;
-
-import java.util.Iterator;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMAttribute;
-import org.apache.axiom.om.OMElement;
import org.apache.neethi.Assertion;
import org.apache.neethi.AssertionBuilderFactory;
-import org.apache.neethi.Constants;
-import org.apache.neethi.builders.AssertionBuilder;
+import org.apache.ws.secpolicy.SP11Constants;
+import org.apache.ws.secpolicy.SP13Constants;
import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.SP12Constants;
+import org.apache.ws.secpolicy.SPUtils;
+import org.apache.ws.secpolicy.model.Attachments;
+import org.apache.ws.secpolicy.model.EncryptedParts;
import org.apache.ws.secpolicy.model.Header;
-import org.apache.ws.secpolicy.model.SignedEncryptedParts;
+import org.w3c.dom.Element;
-public class EncryptedPartsBuilder implements AssertionBuilder<OMElement> {
-
- public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
-
- SignedEncryptedParts signedEncryptedParts = new SignedEncryptedParts(false, SPConstants.SP_V12);
-
- Iterator iterator = element.getChildElements();
- if (iterator.hasNext()) {
- for (; iterator.hasNext();) {
- processElement((OMElement) iterator.next(),
- signedEncryptedParts);
- }
- } else {
- // If we have only <sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"/>
- // then we need to encrypt the whole body (refer to http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/ws-securitypolicy-1.2-spec-os.html#_Toc161826515).
- signedEncryptedParts.setBody(true);
- }
-
- OMAttribute isOptional = element
- .getAttribute(Constants.Q_ELEM_OPTIONAL_ATTR);
- if (isOptional != null) {
- signedEncryptedParts.setOptional(Boolean.valueOf(isOptional
- .getAttributeValue()).booleanValue());
- }
-
- return signedEncryptedParts;
- }
-
- public QName[] getKnownElements() {
- return new QName[] {SP12Constants.ENCRYPTED_PARTS};
+import javax.xml.namespace.QName;
+import java.util.List;
+
+/**
+ * @author $Author$
+ * @version $Revision$ $Date$
+ */
+public class EncryptedPartsBuilder extends SignedPartsBuilder {
+
+ public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+
+ final SPConstants.SPVersion spVersion = SPConstants.SPVersion.getSPVersion(element.getNamespaceURI());
+ boolean body = SPUtils.hasChildElementWithName(element, spVersion.getSPConstants().getBody());
+ final List<Header> headers = getHeaders(element, spVersion);
+ final Attachments attachments = getAttachments(element, spVersion);
+ body |= !SPUtils.hasChildElements(element);
+
+ EncryptedParts encryptedParts = new EncryptedParts(spVersion, body, attachments, headers);
+ encryptedParts.setOptional(SPUtils.isOptional(element));
+ encryptedParts.setIgnorable(SPUtils.isIgnorable(element));
+ return encryptedParts;
}
- private void processElement(OMElement element, SignedEncryptedParts parent) {
-
- QName name = element.getQName();
-
- if (SP12Constants.HEADER.equals(name)) {
- Header header = new Header();
-
- OMAttribute nameAttribute = element.getAttribute(SPConstants.NAME);
- if( nameAttribute != null ) {
- header.setName(nameAttribute.getAttributeValue());
- }
-
- OMAttribute namespaceAttribute = element.getAttribute(SPConstants.NAMESPACE);
- header.setNamespace(namespaceAttribute.getAttributeValue());
-
- parent.addHeader(header);
-
- } else if (SP12Constants.BODY.equals(name)) {
- parent.setBody(true);
- }
+ public QName[] getKnownElements() {
+ return new QName[]{SP13Constants.ENCRYPTED_PARTS, SP11Constants.ENCRYPTED_PARTS};
}
}
Propchange: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/EncryptedPartsBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/EncryptionTokenBuilder.java (from r1197660, axis/axis2/java/rampart/trunk/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy12/builders/ProtectionTokenBuilder.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/EncryptionTokenBuilder.java?p2=webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/EncryptionTokenBuilder.java&p1=axis/axis2/java/rampart/trunk/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy12/builders/ProtectionTokenBuilder.java&r1=1197660&r2=1210203&rev=1210203&view=diff
==============================================================================
--- axis/axis2/java/rampart/trunk/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy12/builders/ProtectionTokenBuilder.java (original)
+++ webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/EncryptionTokenBuilder.java Sun Dec 4 20:33:05 2011
@@ -1,61 +1,56 @@
-/*
- * Copyright 2001-2004 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.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.secpolicy12.builders;
+package org.apache.ws.secpolicy.builders;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMElement;
import org.apache.neethi.Assertion;
import org.apache.neethi.AssertionBuilderFactory;
import org.apache.neethi.Policy;
-import org.apache.neethi.PolicyEngine;
import org.apache.neethi.builders.AssertionBuilder;
+import org.apache.ws.secpolicy.SP11Constants;
+import org.apache.ws.secpolicy.SP13Constants;
import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.SP12Constants;
-import org.apache.ws.secpolicy.model.ProtectionToken;
-import org.apache.ws.secpolicy.model.Token;
+import org.apache.ws.secpolicy.SPUtils;
+import org.apache.ws.secpolicy.model.EncryptionToken;
+import org.w3c.dom.Element;
-public class ProtectionTokenBuilder implements AssertionBuilder<OMElement> {
+import javax.xml.namespace.QName;
- public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
- ProtectionToken protectionToken = new ProtectionToken(SPConstants.SP_V12);
-
- Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
- policy = (Policy) policy.normalize(false);
-
- for (Iterator iterator = policy.getAlternatives(); iterator.hasNext();) {
- processAlternative((List) iterator.next(), protectionToken);
- break; // since there should be only one alternative ..
- }
-
- return protectionToken;
- }
-
- public QName[] getKnownElements() {
- return new QName[] {SP12Constants.PROTECTION_TOKEN};
+/**
+ * @author $Author$
+ * @version $Revision$ $Date$
+ */
+public class EncryptionTokenBuilder implements AssertionBuilder<Element> {
+
+ public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+ final SPConstants.SPVersion spVersion = SPConstants.SPVersion.getSPVersion(element.getNamespaceURI());
+ final Element nestedPolicyElement = SPUtils.getFirstPolicyChildElement(element);
+ final Policy nestedPolicy = nestedPolicyElement != null ? factory.getPolicyEngine().getPolicy(nestedPolicyElement) : new Policy();
+ EncryptionToken encryptionToken = new EncryptionToken(
+ spVersion,
+ nestedPolicy
+ );
+ encryptionToken.setOptional(SPUtils.isOptional(element));
+ encryptionToken.setIgnorable(SPUtils.isIgnorable(element));
+ return encryptionToken;
}
- private void processAlternative(List assertions, ProtectionToken parent) {
- Object token = assertions.get(0);
-
- if (token instanceof Token) {
- parent.setToken((Token) token);
- }
+ public QName[] getKnownElements() {
+ return new QName[]{SP13Constants.ENCRYPTION_TOKEN, SP11Constants.ENCRYPTION_TOKEN};
}
}
Propchange: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/EncryptionTokenBuilder.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/EncryptionTokenBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/HttpsTokenBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/HttpsTokenBuilder.java?rev=1210203&r1=1197660&r2=1210203&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/HttpsTokenBuilder.java (original)
+++ webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/HttpsTokenBuilder.java Sun Dec 4 20:33:05 2011
@@ -1,102 +1,71 @@
-/*
- * Copyright 2001-2004 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.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.secpolicy12.builders;
+package org.apache.ws.secpolicy.builders;
-import org.apache.axiom.om.OMElement;
import org.apache.neethi.Assertion;
import org.apache.neethi.AssertionBuilderFactory;
import org.apache.neethi.Policy;
-import org.apache.neethi.PolicyEngine;
import org.apache.neethi.builders.AssertionBuilder;
-import org.apache.ws.secpolicy.SP12Constants;
+import org.apache.ws.secpolicy.SP11Constants;
+import org.apache.ws.secpolicy.SP13Constants;
import org.apache.ws.secpolicy.SPConstants;
+import org.apache.ws.secpolicy.SPUtils;
import org.apache.ws.secpolicy.model.HttpsToken;
+import org.w3c.dom.Element;
import javax.xml.namespace.QName;
-import java.util.Iterator;
-import java.util.List;
/**
- * This is a standard assertion builder implementation for the https token
- * as specified by the ws security policy 1.2 specification. In order for this builder to be used
- * it is required that the security policy namespace uri is {@link SP12Constants#SP_NS}
- * The builder will handle
- * <ul>
- * <li><code>HttpBasicAuthentication</code></li>
- * <li><code>HttpDigestAuthentication</code></li>
- * <li><code>RequireClientCertificate</code></li>
- * </ul>
- * alternatives in the HttpsToken considering both cases whether the policy is normalized or not.
- *
+ * @author $Author$
+ * @version $Revision$ $Date$
*/
-public class HttpsTokenBuilder implements AssertionBuilder<OMElement> {
-
- /**
- * {@inheritDoc}
- */
- public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
- HttpsToken httpsToken = new HttpsToken(SPConstants.SP_V12);
-
- if (element.getFirstElement()!= null) {
- Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
- policy = (Policy) policy.normalize(false);
-
- for (Iterator iterator = policy.getAlternatives(); iterator.hasNext();) {
- processAlternative((List) iterator.next(), httpsToken);
- break; // since there should be only one alternative
- }
- }
+public class HttpsTokenBuilder implements AssertionBuilder<Element> {
+ public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+
+ final SPConstants.SPVersion spVersion = SPConstants.SPVersion.getSPVersion(element.getNamespaceURI());
+ final String includeTokenValue = SPUtils.getAttribute(element, spVersion.getSPConstants().getIncludeToken());
+ final Element issuer = SPUtils.getFirstChildElement(element, spVersion.getSPConstants().getIssuer());
+ if (spVersion == SPConstants.SPVersion.SP11 && issuer != null) {
+ throw new IllegalArgumentException(SPConstants.ERR_INVALID_POLICY);
+ }
+ final String issuerName = SPUtils.getFirstChildElementText(element, spVersion.getSPConstants().getIssuerName());
+ if (spVersion == SPConstants.SPVersion.SP11 && issuerName != null) {
+ throw new IllegalArgumentException(SPConstants.ERR_INVALID_POLICY);
+ }
+ final Element claims = SPUtils.getFirstChildElement(element, spVersion.getSPConstants().getClaims());
+ final Element nestedPolicyElement = SPUtils.getFirstPolicyChildElement(element);
+ final Policy nestedPolicy = nestedPolicyElement != null ? factory.getPolicyEngine().getPolicy(nestedPolicyElement) : new Policy();
+ HttpsToken httpsToken = new HttpsToken(
+ spVersion,
+ spVersion.getSPConstants().getInclusionFromAttributeValue(includeTokenValue),
+ issuer,
+ issuerName,
+ claims,
+ nestedPolicy
+ );
+ httpsToken.setOptional(SPUtils.isOptional(element));
+ httpsToken.setIgnorable(SPUtils.isIgnorable(element));
return httpsToken;
}
- /**
- * {@inheritDoc}
- */
public QName[] getKnownElements() {
- return new QName[] {SP12Constants.HTTPS_TOKEN};
- }
-
- /**
- * Process policy alternatives inside the HttpsToken element.
- * Essentially this method will search for<br>
- * <ul>
- * <li><code>HttpBasicAuthentication</code></li>
- * <li><code>HttpDigestAuthentication</code></li>
- * <li><code>RequireClientCertificate</code></li>
- * </ul>
- * elements.
- * @param assertions the list of assertions to be searched through.
- * @param parent the https token, that is to be populated with retrieved data.
- */
- private void processAlternative(List assertions, HttpsToken parent) {
-
- for (Iterator iterator = assertions.iterator(); iterator.hasNext();) {
- Assertion primtive = (Assertion) iterator.next();
- QName qname = primtive.getName();
-
- if (qname != null) {
- if (SP12Constants.HTTP_BASIC_AUTHENTICATION.equals(qname)) {
- parent.setHttpBasicAuthentication(true);
- } else if (SP12Constants.HTTP_DIGEST_AUTHENTICATION.equals(qname)) {
- parent.setHttpDigestAuthentication(true);
- } else if (SP12Constants.REQUIRE_CLIENT_CERTIFICATE.equals(qname)) {
- parent.setRequireClientCertificate(true);
- }
- }
- }
+ return new QName[]{SP13Constants.HTTPS_TOKEN, SP11Constants.HTTPS_TOKEN};
}
}
Propchange: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/HttpsTokenBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/InitiatorEncryptionTokenBuilder.java (from r1197660, axis/axis2/java/rampart/trunk/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy12/builders/InitiatorTokenBuilder.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/InitiatorEncryptionTokenBuilder.java?p2=webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/InitiatorEncryptionTokenBuilder.java&p1=axis/axis2/java/rampart/trunk/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy12/builders/InitiatorTokenBuilder.java&r1=1197660&r2=1210203&rev=1210203&view=diff
==============================================================================
--- axis/axis2/java/rampart/trunk/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy12/builders/InitiatorTokenBuilder.java (original)
+++ webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/InitiatorEncryptionTokenBuilder.java Sun Dec 4 20:33:05 2011
@@ -1,68 +1,56 @@
-/*
- * Copyright 2001-2004 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.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.secpolicy12.builders;
+package org.apache.ws.secpolicy.builders;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMElement;
import org.apache.neethi.Assertion;
import org.apache.neethi.AssertionBuilderFactory;
import org.apache.neethi.Policy;
-import org.apache.neethi.PolicyEngine;
import org.apache.neethi.builders.AssertionBuilder;
+import org.apache.ws.secpolicy.SP13Constants;
import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.SP12Constants;
-import org.apache.ws.secpolicy.model.InitiatorToken;
-import org.apache.ws.secpolicy.model.Token;
-
-public class InitiatorTokenBuilder implements AssertionBuilder<OMElement> {
-
- public Assertion build(OMElement element, AssertionBuilderFactory factory)
- throws IllegalArgumentException {
- InitiatorToken initiatorToken = new InitiatorToken(SPConstants.SP_V12);
-
- Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
- policy = (Policy) policy.normalize(false);
-
- for (Iterator iterator = policy.getAlternatives(); iterator.hasNext();) {
- processAlternative((List) iterator.next(), initiatorToken);
- break; // TODO process all the token that must be set ..
- }
-
- return initiatorToken;
- }
-
- private void processAlternative(List assertions, InitiatorToken parent) {
-
- Object token;
-
- for (Iterator iterator = assertions.iterator(); iterator.hasNext();) {
- token = iterator.next();
-
- if (token instanceof Token) {
- parent.setInitiatorToken((Token) token);
- }
- }
+import org.apache.ws.secpolicy.SPUtils;
+import org.apache.ws.secpolicy.model.InitiatorEncryptionToken;
+import org.w3c.dom.Element;
+
+import javax.xml.namespace.QName;
+
+/**
+ * @author $Author$
+ * @version $Revision$ $Date$
+ */
+public class InitiatorEncryptionTokenBuilder implements AssertionBuilder<Element> {
+
+ public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+
+ final SPConstants.SPVersion spVersion = SPConstants.SPVersion.getSPVersion(element.getNamespaceURI());
+ final Element nestedPolicyElement = SPUtils.getFirstPolicyChildElement(element);
+ final Policy nestedPolicy = nestedPolicyElement != null ? factory.getPolicyEngine().getPolicy(nestedPolicyElement) : new Policy();
+ InitiatorEncryptionToken initiatorEncryptionToken = new InitiatorEncryptionToken(
+ spVersion,
+ nestedPolicy
+ );
+ initiatorEncryptionToken.setOptional(SPUtils.isOptional(element));
+ initiatorEncryptionToken.setIgnorable(SPUtils.isIgnorable(element));
+ return initiatorEncryptionToken;
}
public QName[] getKnownElements() {
- return new QName[] {SP12Constants.INITIATOR_TOKEN};
+ return new QName[]{SP13Constants.INITIATOR_ENCRYPTION_TOKEN};
}
-
}
Propchange: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/InitiatorEncryptionTokenBuilder.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/InitiatorEncryptionTokenBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/InitiatorSignatureTokenBuilder.java (from r1197660, axis/axis2/java/rampart/trunk/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy12/builders/InitiatorTokenBuilder.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/InitiatorSignatureTokenBuilder.java?p2=webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/InitiatorSignatureTokenBuilder.java&p1=axis/axis2/java/rampart/trunk/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy12/builders/InitiatorTokenBuilder.java&r1=1197660&r2=1210203&rev=1210203&view=diff
==============================================================================
--- axis/axis2/java/rampart/trunk/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy12/builders/InitiatorTokenBuilder.java (original)
+++ webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/InitiatorSignatureTokenBuilder.java Sun Dec 4 20:33:05 2011
@@ -1,68 +1,56 @@
-/*
- * Copyright 2001-2004 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.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.secpolicy12.builders;
+package org.apache.ws.secpolicy.builders;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMElement;
import org.apache.neethi.Assertion;
import org.apache.neethi.AssertionBuilderFactory;
import org.apache.neethi.Policy;
-import org.apache.neethi.PolicyEngine;
import org.apache.neethi.builders.AssertionBuilder;
+import org.apache.ws.secpolicy.SP13Constants;
import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.SP12Constants;
-import org.apache.ws.secpolicy.model.InitiatorToken;
-import org.apache.ws.secpolicy.model.Token;
-
-public class InitiatorTokenBuilder implements AssertionBuilder<OMElement> {
-
- public Assertion build(OMElement element, AssertionBuilderFactory factory)
- throws IllegalArgumentException {
- InitiatorToken initiatorToken = new InitiatorToken(SPConstants.SP_V12);
-
- Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
- policy = (Policy) policy.normalize(false);
-
- for (Iterator iterator = policy.getAlternatives(); iterator.hasNext();) {
- processAlternative((List) iterator.next(), initiatorToken);
- break; // TODO process all the token that must be set ..
- }
-
- return initiatorToken;
- }
-
- private void processAlternative(List assertions, InitiatorToken parent) {
-
- Object token;
-
- for (Iterator iterator = assertions.iterator(); iterator.hasNext();) {
- token = iterator.next();
-
- if (token instanceof Token) {
- parent.setInitiatorToken((Token) token);
- }
- }
+import org.apache.ws.secpolicy.SPUtils;
+import org.apache.ws.secpolicy.model.InitiatorSignatureToken;
+import org.w3c.dom.Element;
+
+import javax.xml.namespace.QName;
+
+/**
+ * @author $Author$
+ * @version $Revision$ $Date$
+ */
+public class InitiatorSignatureTokenBuilder implements AssertionBuilder<Element> {
+
+ public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+
+ final SPConstants.SPVersion spVersion = SPConstants.SPVersion.getSPVersion(element.getNamespaceURI());
+ final Element nestedPolicyElement = SPUtils.getFirstPolicyChildElement(element);
+ final Policy nestedPolicy = nestedPolicyElement != null ? factory.getPolicyEngine().getPolicy(nestedPolicyElement) : new Policy();
+ InitiatorSignatureToken initiatorSignatureToken = new InitiatorSignatureToken(
+ spVersion,
+ nestedPolicy
+ );
+ initiatorSignatureToken.setOptional(SPUtils.isOptional(element));
+ initiatorSignatureToken.setIgnorable(SPUtils.isIgnorable(element));
+ return initiatorSignatureToken;
}
public QName[] getKnownElements() {
- return new QName[] {SP12Constants.INITIATOR_TOKEN};
+ return new QName[]{SP13Constants.INITIATOR_SIGNATURE_TOKEN};
}
-
}
Propchange: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/InitiatorSignatureTokenBuilder.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/InitiatorSignatureTokenBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/InitiatorTokenBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/InitiatorTokenBuilder.java?rev=1210203&r1=1197660&r2=1210203&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/InitiatorTokenBuilder.java (original)
+++ webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/InitiatorTokenBuilder.java Sun Dec 4 20:33:05 2011
@@ -1,68 +1,57 @@
-/*
- * Copyright 2001-2004 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.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.secpolicy12.builders;
+package org.apache.ws.secpolicy.builders;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMElement;
import org.apache.neethi.Assertion;
import org.apache.neethi.AssertionBuilderFactory;
import org.apache.neethi.Policy;
-import org.apache.neethi.PolicyEngine;
import org.apache.neethi.builders.AssertionBuilder;
+import org.apache.ws.secpolicy.SP11Constants;
+import org.apache.ws.secpolicy.SP13Constants;
import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.SP12Constants;
+import org.apache.ws.secpolicy.SPUtils;
import org.apache.ws.secpolicy.model.InitiatorToken;
-import org.apache.ws.secpolicy.model.Token;
+import org.w3c.dom.Element;
-public class InitiatorTokenBuilder implements AssertionBuilder<OMElement> {
+import javax.xml.namespace.QName;
- public Assertion build(OMElement element, AssertionBuilderFactory factory)
- throws IllegalArgumentException {
- InitiatorToken initiatorToken = new InitiatorToken(SPConstants.SP_V12);
-
- Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
- policy = (Policy) policy.normalize(false);
-
- for (Iterator iterator = policy.getAlternatives(); iterator.hasNext();) {
- processAlternative((List) iterator.next(), initiatorToken);
- break; // TODO process all the token that must be set ..
- }
-
+/**
+ * @author $Author$
+ * @version $Revision$ $Date$
+ */
+public class InitiatorTokenBuilder implements AssertionBuilder<Element> {
+
+ public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+
+ final SPConstants.SPVersion spVersion = SPConstants.SPVersion.getSPVersion(element.getNamespaceURI());
+ final Element nestedPolicyElement = SPUtils.getFirstPolicyChildElement(element);
+ final Policy nestedPolicy = nestedPolicyElement != null ? factory.getPolicyEngine().getPolicy(nestedPolicyElement) : new Policy();
+ InitiatorToken initiatorToken = new InitiatorToken(
+ spVersion,
+ nestedPolicy
+ );
+ initiatorToken.setOptional(SPUtils.isOptional(element));
+ initiatorToken.setIgnorable(SPUtils.isIgnorable(element));
return initiatorToken;
}
-
- private void processAlternative(List assertions, InitiatorToken parent) {
-
- Object token;
-
- for (Iterator iterator = assertions.iterator(); iterator.hasNext();) {
- token = iterator.next();
-
- if (token instanceof Token) {
- parent.setInitiatorToken((Token) token);
- }
- }
- }
public QName[] getKnownElements() {
- return new QName[] {SP12Constants.INITIATOR_TOKEN};
+ return new QName[]{SP13Constants.INITIATOR_TOKEN, SP11Constants.INITIATOR_TOKEN};
}
-
}
Propchange: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/InitiatorTokenBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/IssuedTokenBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/IssuedTokenBuilder.java?rev=1210203&r1=1197660&r2=1210203&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/IssuedTokenBuilder.java (original)
+++ webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/IssuedTokenBuilder.java Sun Dec 4 20:33:05 2011
@@ -1,119 +1,69 @@
-/*
- * Copyright 2001-2004 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.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.secpolicy12.builders;
+package org.apache.ws.secpolicy.builders;
-import org.apache.axiom.om.OMAttribute;
-import org.apache.axiom.om.OMElement;
-import org.apache.axis2.addressing.AddressingConstants;
import org.apache.neethi.Assertion;
import org.apache.neethi.AssertionBuilderFactory;
import org.apache.neethi.Policy;
-import org.apache.neethi.PolicyEngine;
import org.apache.neethi.builders.AssertionBuilder;
+import org.apache.ws.secpolicy.SP11Constants;
+import org.apache.ws.secpolicy.SP13Constants;
import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.SP12Constants;
+import org.apache.ws.secpolicy.SPUtils;
import org.apache.ws.secpolicy.model.IssuedToken;
+import org.w3c.dom.Element;
import javax.xml.namespace.QName;
-import java.util.Iterator;
-import java.util.List;
-
-public class IssuedTokenBuilder implements AssertionBuilder<OMElement> {
-
- public Assertion build(OMElement element, AssertionBuilderFactory factory)
- throws IllegalArgumentException {
- IssuedToken issuedToken = new IssuedToken(SPConstants.SP_V12);
-
- OMAttribute includeAttr = element.getAttribute(SP12Constants.INCLUDE_TOKEN);
- if(includeAttr != null) {
- int inclusion = SP12Constants.getInclusionFromAttributeValue(includeAttr.getAttributeValue());
- issuedToken.setInclusion(inclusion);
- }
- // Extract Issuer
- OMElement issuerElem = element.getFirstChildWithName(SP12Constants.ISSUER);
-
- if(issuerElem != null) {
- OMElement issuerEpr = issuerElem.getFirstChildWithName(new QName(AddressingConstants.Final.WSA_NAMESPACE,"Address"));
-
- //try the other addressing namespace
- if (issuerEpr == null) {
- issuerEpr = issuerElem.getFirstChildWithName(new QName(AddressingConstants.Submission.WSA_NAMESPACE,"Address"));
- }
-
- issuedToken.setIssuerEpr(issuerEpr);
- }
-
- //TODO check why this returns an Address element
- //iter = issuerElem.getChildrenWithLocalName("Metadata");
-
- if (issuerElem != null ) {
- OMElement issuerMex = issuerElem.getFirstChildWithName(new QName(AddressingConstants.Final.WSA_NAMESPACE,"Metadata"));
-
- //try the other addressing namespace
- if (issuerMex == null) {
- issuerMex = issuerElem.getFirstChildWithName(new QName(AddressingConstants.Submission.WSA_NAMESPACE,"Metadata"));
- }
-
- issuedToken.setIssuerMex(issuerMex);
- }
-
- // Extract RSTTemplate
- OMElement rstTmplElem = element.getFirstChildWithName(SP12Constants.REQUEST_SECURITY_TOKEN_TEMPLATE);
- if (rstTmplElem != null) {
- issuedToken.setRstTemplate(rstTmplElem);
- }
-
- OMElement policyElement = element.getFirstChildWithName(org.apache.neethi.Constants.Q_ELEM_POLICY);
-
- if (policyElement != null) {
-
- Policy policy = PolicyEngine.getPolicy(policyElement);
- policy = (Policy) policy.normalize(false);
+/**
+ * @author $Author$
+ * @version $Revision$ $Date$
+ */
+public class IssuedTokenBuilder implements AssertionBuilder<Element> {
- for (Iterator iterator = policy.getAlternatives(); iterator
- .hasNext();) {
- processAlternative((List) iterator.next(), issuedToken);
- break; // since there should be only one alternative ..
- }
- }
+ public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+ final SPConstants.SPVersion spVersion = SPConstants.SPVersion.getSPVersion(element.getNamespaceURI());
+ final String includeTokenValue = SPUtils.getAttribute(element, spVersion.getSPConstants().getIncludeToken());
+ final Element issuer = SPUtils.getFirstChildElement(element, spVersion.getSPConstants().getIssuer());
+ final String issuerName = SPUtils.getFirstChildElementText(element, spVersion.getSPConstants().getIssuerName());
+ if (spVersion == SPConstants.SPVersion.SP11 && issuerName != null) {
+ throw new IllegalArgumentException(SPConstants.ERR_INVALID_POLICY);
+ }
+ final Element claims = SPUtils.getFirstChildElement(element, spVersion.getSPConstants().getClaims());
+ final Element nestedPolicyElement = SPUtils.getFirstPolicyChildElement(element);
+ final Policy nestedPolicy = nestedPolicyElement != null ? factory.getPolicyEngine().getPolicy(nestedPolicyElement) : new Policy();
+ IssuedToken issuedToken = new IssuedToken(
+ spVersion,
+ spVersion.getSPConstants().getInclusionFromAttributeValue(includeTokenValue),
+ issuer,
+ issuerName,
+ SPUtils.getFirstChildElement(element, spVersion.getSPConstants().getRequestSecurityTokenTemplate()),
+ claims,
+ nestedPolicy
+ );
+ issuedToken.setOptional(SPUtils.isOptional(element));
+ issuedToken.setIgnorable(SPUtils.isIgnorable(element));
return issuedToken;
}
public QName[] getKnownElements() {
- return new QName[] { SP12Constants.ISSUED_TOKEN };
- }
-
- private void processAlternative(List assertions, IssuedToken parent) {
- Assertion assertion;
- QName name;
-
- for (Iterator iterator = assertions.iterator(); iterator.hasNext();) {
- assertion = (Assertion) iterator.next();
- name = assertion.getName();
-
- if (SP12Constants.REQUIRE_DERIVED_KEYS.equals(name)) {
- parent.setDerivedKeys(true);
- } else if (SP12Constants.REQUIRE_EXTERNAL_REFERNCE.equals(name)) {
- parent.setRequireExternalReference(true);
- } else if (SP12Constants.REQUIRE_INTERNAL_REFERNCE.equals(name)) {
- parent.setRequireInternalReference(true);
- }
- }
-
+ return new QName[]{SP13Constants.ISSUED_TOKEN, SP11Constants.ISSUED_TOKEN};
}
}
Propchange: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/IssuedTokenBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/KerberosTokenBuilder.java (from r1197660, axis/axis2/java/rampart/trunk/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy12/builders/HttpsTokenBuilder.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/KerberosTokenBuilder.java?p2=webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/KerberosTokenBuilder.java&p1=axis/axis2/java/rampart/trunk/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy12/builders/HttpsTokenBuilder.java&r1=1197660&r2=1210203&rev=1210203&view=diff
==============================================================================
--- axis/axis2/java/rampart/trunk/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy12/builders/HttpsTokenBuilder.java (original)
+++ webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/KerberosTokenBuilder.java Sun Dec 4 20:33:05 2011
@@ -1,102 +1,71 @@
-/*
- * Copyright 2001-2004 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.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.secpolicy12.builders;
+package org.apache.ws.secpolicy.builders;
-import org.apache.axiom.om.OMElement;
import org.apache.neethi.Assertion;
import org.apache.neethi.AssertionBuilderFactory;
import org.apache.neethi.Policy;
-import org.apache.neethi.PolicyEngine;
import org.apache.neethi.builders.AssertionBuilder;
-import org.apache.ws.secpolicy.SP12Constants;
+import org.apache.ws.secpolicy.SP11Constants;
+import org.apache.ws.secpolicy.SP13Constants;
import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.model.HttpsToken;
+import org.apache.ws.secpolicy.SPUtils;
+import org.apache.ws.secpolicy.model.KerberosToken;
+import org.w3c.dom.Element;
import javax.xml.namespace.QName;
-import java.util.Iterator;
-import java.util.List;
/**
- * This is a standard assertion builder implementation for the https token
- * as specified by the ws security policy 1.2 specification. In order for this builder to be used
- * it is required that the security policy namespace uri is {@link SP12Constants#SP_NS}
- * The builder will handle
- * <ul>
- * <li><code>HttpBasicAuthentication</code></li>
- * <li><code>HttpDigestAuthentication</code></li>
- * <li><code>RequireClientCertificate</code></li>
- * </ul>
- * alternatives in the HttpsToken considering both cases whether the policy is normalized or not.
- *
+ * @author $Author$
+ * @version $Revision$ $Date$
*/
-public class HttpsTokenBuilder implements AssertionBuilder<OMElement> {
-
- /**
- * {@inheritDoc}
- */
- public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
- HttpsToken httpsToken = new HttpsToken(SPConstants.SP_V12);
-
- if (element.getFirstElement()!= null) {
- Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
- policy = (Policy) policy.normalize(false);
-
- for (Iterator iterator = policy.getAlternatives(); iterator.hasNext();) {
- processAlternative((List) iterator.next(), httpsToken);
- break; // since there should be only one alternative
- }
- }
+public class KerberosTokenBuilder implements AssertionBuilder<Element> {
- return httpsToken;
+ public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+
+ final SPConstants.SPVersion spVersion = SPConstants.SPVersion.getSPVersion(element.getNamespaceURI());
+ final String includeTokenValue = SPUtils.getAttribute(element, spVersion.getSPConstants().getIncludeToken());
+ final Element issuer = SPUtils.getFirstChildElement(element, spVersion.getSPConstants().getIssuer());
+ if (spVersion == SPConstants.SPVersion.SP11 && issuer != null) {
+ throw new IllegalArgumentException(SPConstants.ERR_INVALID_POLICY);
+ }
+ final String issuerName = SPUtils.getFirstChildElementText(element, spVersion.getSPConstants().getIssuerName());
+ if (spVersion == SPConstants.SPVersion.SP11 && issuerName != null) {
+ throw new IllegalArgumentException(SPConstants.ERR_INVALID_POLICY);
+ }
+ final Element claims = SPUtils.getFirstChildElement(element, spVersion.getSPConstants().getClaims());
+ final Element nestedPolicyElement = SPUtils.getFirstPolicyChildElement(element);
+ final Policy nestedPolicy = nestedPolicyElement != null ? factory.getPolicyEngine().getPolicy(nestedPolicyElement) : new Policy();
+ KerberosToken kerberosToken = new KerberosToken(
+ spVersion,
+ spVersion.getSPConstants().getInclusionFromAttributeValue(includeTokenValue),
+ issuer,
+ issuerName,
+ claims,
+ nestedPolicy
+ );
+ kerberosToken.setOptional(SPUtils.isOptional(element));
+ kerberosToken.setIgnorable(SPUtils.isIgnorable(element));
+ return kerberosToken;
}
- /**
- * {@inheritDoc}
- */
public QName[] getKnownElements() {
- return new QName[] {SP12Constants.HTTPS_TOKEN};
- }
-
- /**
- * Process policy alternatives inside the HttpsToken element.
- * Essentially this method will search for<br>
- * <ul>
- * <li><code>HttpBasicAuthentication</code></li>
- * <li><code>HttpDigestAuthentication</code></li>
- * <li><code>RequireClientCertificate</code></li>
- * </ul>
- * elements.
- * @param assertions the list of assertions to be searched through.
- * @param parent the https token, that is to be populated with retrieved data.
- */
- private void processAlternative(List assertions, HttpsToken parent) {
-
- for (Iterator iterator = assertions.iterator(); iterator.hasNext();) {
- Assertion primtive = (Assertion) iterator.next();
- QName qname = primtive.getName();
-
- if (qname != null) {
- if (SP12Constants.HTTP_BASIC_AUTHENTICATION.equals(qname)) {
- parent.setHttpBasicAuthentication(true);
- } else if (SP12Constants.HTTP_DIGEST_AUTHENTICATION.equals(qname)) {
- parent.setHttpDigestAuthentication(true);
- } else if (SP12Constants.REQUIRE_CLIENT_CERTIFICATE.equals(qname)) {
- parent.setRequireClientCertificate(true);
- }
- }
- }
+ return new QName[]{SP13Constants.KERBEROS_TOKEN, SP11Constants.KERBEROS_TOKEN};
}
}
Propchange: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/KerberosTokenBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/KeyValueTokenBuilder.java (from r1197660, axis/axis2/java/rampart/trunk/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy12/builders/HttpsTokenBuilder.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/KeyValueTokenBuilder.java?p2=webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/KeyValueTokenBuilder.java&p1=axis/axis2/java/rampart/trunk/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy12/builders/HttpsTokenBuilder.java&r1=1197660&r2=1210203&rev=1210203&view=diff
==============================================================================
--- axis/axis2/java/rampart/trunk/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy12/builders/HttpsTokenBuilder.java (original)
+++ webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/KeyValueTokenBuilder.java Sun Dec 4 20:33:05 2011
@@ -1,102 +1,66 @@
-/*
- * Copyright 2001-2004 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.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.secpolicy12.builders;
+package org.apache.ws.secpolicy.builders;
-import org.apache.axiom.om.OMElement;
import org.apache.neethi.Assertion;
import org.apache.neethi.AssertionBuilderFactory;
import org.apache.neethi.Policy;
-import org.apache.neethi.PolicyEngine;
import org.apache.neethi.builders.AssertionBuilder;
-import org.apache.ws.secpolicy.SP12Constants;
+import org.apache.ws.secpolicy.SP13Constants;
import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.model.HttpsToken;
+import org.apache.ws.secpolicy.SPUtils;
+import org.apache.ws.secpolicy.model.KeyValueToken;
+import org.w3c.dom.Element;
import javax.xml.namespace.QName;
-import java.util.Iterator;
-import java.util.List;
/**
- * This is a standard assertion builder implementation for the https token
- * as specified by the ws security policy 1.2 specification. In order for this builder to be used
- * it is required that the security policy namespace uri is {@link SP12Constants#SP_NS}
- * The builder will handle
- * <ul>
- * <li><code>HttpBasicAuthentication</code></li>
- * <li><code>HttpDigestAuthentication</code></li>
- * <li><code>RequireClientCertificate</code></li>
- * </ul>
- * alternatives in the HttpsToken considering both cases whether the policy is normalized or not.
- *
+ * @author $Author$
+ * @version $Revision$ $Date$
*/
-public class HttpsTokenBuilder implements AssertionBuilder<OMElement> {
-
- /**
- * {@inheritDoc}
- */
- public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
- HttpsToken httpsToken = new HttpsToken(SPConstants.SP_V12);
-
- if (element.getFirstElement()!= null) {
- Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
- policy = (Policy) policy.normalize(false);
-
- for (Iterator iterator = policy.getAlternatives(); iterator.hasNext();) {
- processAlternative((List) iterator.next(), httpsToken);
- break; // since there should be only one alternative
- }
- }
+public class KeyValueTokenBuilder implements AssertionBuilder<Element> {
- return httpsToken;
+ public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+
+ final SPConstants.SPVersion spVersion = SPConstants.SPVersion.getSPVersion(element.getNamespaceURI());
+ final String includeTokenValue = SPUtils.getAttribute(element, spVersion.getSPConstants().getIncludeToken());
+ final Element issuer = SPUtils.getFirstChildElement(element, spVersion.getSPConstants().getIssuer());
+ if (issuer != null) {
+ throw new IllegalArgumentException(SPConstants.ERR_INVALID_POLICY);
+ }
+ final String issuerName = SPUtils.getFirstChildElementText(element, spVersion.getSPConstants().getIssuerName());
+ if (issuerName != null) {
+ throw new IllegalArgumentException(SPConstants.ERR_INVALID_POLICY);
+ }
+ final Element nestedPolicyElement = SPUtils.getFirstPolicyChildElement(element);
+ final Policy nestedPolicy = nestedPolicyElement != null ? factory.getPolicyEngine().getPolicy(nestedPolicyElement) : new Policy();
+ KeyValueToken keyValueToken = new KeyValueToken(
+ spVersion,
+ spVersion.getSPConstants().getInclusionFromAttributeValue(includeTokenValue),
+ nestedPolicy
+ );
+ keyValueToken.setOptional(SPUtils.isOptional(element));
+ keyValueToken.setIgnorable(SPUtils.isIgnorable(element));
+ return keyValueToken;
}
- /**
- * {@inheritDoc}
- */
public QName[] getKnownElements() {
- return new QName[] {SP12Constants.HTTPS_TOKEN};
- }
-
- /**
- * Process policy alternatives inside the HttpsToken element.
- * Essentially this method will search for<br>
- * <ul>
- * <li><code>HttpBasicAuthentication</code></li>
- * <li><code>HttpDigestAuthentication</code></li>
- * <li><code>RequireClientCertificate</code></li>
- * </ul>
- * elements.
- * @param assertions the list of assertions to be searched through.
- * @param parent the https token, that is to be populated with retrieved data.
- */
- private void processAlternative(List assertions, HttpsToken parent) {
-
- for (Iterator iterator = assertions.iterator(); iterator.hasNext();) {
- Assertion primtive = (Assertion) iterator.next();
- QName qname = primtive.getName();
-
- if (qname != null) {
- if (SP12Constants.HTTP_BASIC_AUTHENTICATION.equals(qname)) {
- parent.setHttpBasicAuthentication(true);
- } else if (SP12Constants.HTTP_DIGEST_AUTHENTICATION.equals(qname)) {
- parent.setHttpDigestAuthentication(true);
- } else if (SP12Constants.REQUIRE_CLIENT_CERTIFICATE.equals(qname)) {
- parent.setRequireClientCertificate(true);
- }
- }
- }
+ return new QName[]{SP13Constants.KEY_VALUE_TOKEN};
}
}
Propchange: webservices/wss4j/branches/swssf/rampart-policy/src/main/java/org/apache/ws/secpolicy/builders/KeyValueTokenBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision