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/09/18 15:51:36 UTC
svn commit: r1172285 [9/48] - in /webservices/wss4j/branches/swssf: ./
cxf-integration/ cxf-integration/src/ cxf-integration/src/main/
cxf-integration/src/main/java/ cxf-integration/src/main/java/org/
cxf-integration/src/main/java/org/swssf/ cxf-integr...
Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/EncryptedPartsBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/EncryptedPartsBuilder.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/EncryptedPartsBuilder.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/EncryptedPartsBuilder.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,90 @@
+/**
+ * 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.swssf.policy.secpolicybuilder;
+
+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.builders.AssertionBuilder;
+import org.swssf.policy.secpolicy.*;
+import org.swssf.policy.secpolicy.model.Header;
+import org.swssf.policy.secpolicy.model.SignedEncryptedParts;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+/**
+ * class lent from apache rampart
+ */
+public class EncryptedPartsBuilder implements AssertionBuilder {
+
+ private static final QName[] KNOWN_ELEMENTS = new QName[]{
+ SP11Constants.ENCRYPTED_PARTS,
+ SP12Constants.ENCRYPTED_PARTS,
+ SP13Constants.ENCRYPTED_PARTS,
+ };
+
+ public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+
+ SPConstants spConstants = PolicyUtil.getSPVersion(element.getQName().getNamespaceURI());
+
+ SignedEncryptedParts signedEncryptedParts = new SignedEncryptedParts(false, spConstants);
+
+ Iterator iterator = element.getChildElements();
+ if (iterator.hasNext()) {
+ for (; iterator.hasNext(); ) {
+ processElement((OMElement) iterator.next(), signedEncryptedParts, spConstants);
+ }
+ } 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);
+ }
+
+ return signedEncryptedParts;
+ }
+
+ public QName[] getKnownElements() {
+ return KNOWN_ELEMENTS;
+ }
+
+ private void processElement(OMElement element, SignedEncryptedParts parent, SPConstants spConstants) {
+
+ QName name = element.getQName();
+
+ if (spConstants.getHeader().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 (spConstants.getBody().equals(name)) {
+ parent.setBody(true);
+ }
+ }
+}
Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/EncryptedPartsBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/HttpsTokenBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/HttpsTokenBuilder.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/HttpsTokenBuilder.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/HttpsTokenBuilder.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,125 @@
+/**
+ * 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.swssf.policy.secpolicybuilder;
+
+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.swssf.policy.secpolicy.*;
+import org.swssf.policy.secpolicy.model.HttpsToken;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * class lent from apache rampart
+ */
+
+/**
+ * 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.
+ */
+public class HttpsTokenBuilder implements AssertionBuilder {
+
+ private static final QName[] KNOWN_ELEMENTS = new QName[]{
+ SP11Constants.HTTPS_TOKEN,
+ SP12Constants.HTTPS_TOKEN,
+ SP13Constants.HTTPS_TOKEN
+ };
+
+ /**
+ * {@inheritDoc}
+ */
+ public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+
+ SPConstants spConstants = PolicyUtil.getSPVersion(element.getQName().getNamespaceURI());
+
+ HttpsToken httpsToken = new HttpsToken(spConstants);
+
+ OMElement issuer = element.getFirstChildWithName(spConstants.getIssuer());
+ if (issuer != null) {
+ httpsToken.setIssuer(issuer.getText());
+ }
+
+ OMElement issuerName = element.getFirstChildWithName(spConstants.getIssuerName());
+ if (issuerName != null) {
+ httpsToken.setIssuerName(issuerName.getText());
+ }
+
+ Policy policy = PolicyEngine.getPolicy(element.getFirstChildWithName(SPConstants.POLICY));
+ policy = (Policy) policy.normalize(false);
+
+ for (Iterator iterator = policy.getAlternatives(); iterator.hasNext(); ) {
+ processAlternative((List) iterator.next(), httpsToken, spConstants);
+ break; // since there should be only one alternative
+ }
+
+ return httpsToken;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public QName[] getKnownElements() {
+ return KNOWN_ELEMENTS;
+ }
+
+ /**
+ * 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, SPConstants spConstants) {
+
+ for (Iterator iterator = assertions.iterator(); iterator.hasNext(); ) {
+ Assertion assertion = (Assertion) iterator.next();
+ QName qname = assertion.getName();
+
+ if (qname != null) {
+ if (spConstants.getHttpBasicAuthentication().equals(qname)) {
+ parent.setHttpBasicAuthentication(true);
+ } else if (spConstants.getHttpDigestAuthentication().equals(qname)) {
+ parent.setHttpDigestAuthentication(true);
+ } else if (spConstants.getRequireClientCertificate().equals(qname)) {
+ parent.setRequireClientCertificate(true);
+ }
+ }
+ }
+ }
+}
Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/HttpsTokenBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/InitiatorTokenBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/InitiatorTokenBuilder.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/InitiatorTokenBuilder.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/InitiatorTokenBuilder.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,81 @@
+/**
+ * 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.swssf.policy.secpolicybuilder;
+
+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.swssf.policy.secpolicy.*;
+import org.swssf.policy.secpolicy.model.InitiatorToken;
+import org.swssf.policy.secpolicy.model.Token;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * class lent from apache rampart
+ */
+public class InitiatorTokenBuilder implements AssertionBuilder {
+
+ private static final QName[] KNOWN_ELEMENTS = new QName[]{
+ SP11Constants.INITIATOR_TOKEN,
+ SP12Constants.INITIATOR_TOKEN,
+ SP13Constants.INITIATOR_TOKEN
+ };
+
+ public Assertion build(OMElement element, AssertionBuilderFactory factory)
+ throws IllegalArgumentException {
+
+ SPConstants spConstants = PolicyUtil.getSPVersion(element.getQName().getNamespaceURI());
+
+ InitiatorToken initiatorToken = new InitiatorToken(spConstants);
+
+ 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);
+ }
+ }
+ }
+
+ public QName[] getKnownElements() {
+ return KNOWN_ELEMENTS;
+ }
+
+}
Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/InitiatorTokenBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/IssuedTokenBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/IssuedTokenBuilder.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/IssuedTokenBuilder.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/IssuedTokenBuilder.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,131 @@
+/**
+ * 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.swssf.policy.secpolicybuilder;
+
+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.Policy;
+import org.apache.neethi.PolicyEngine;
+import org.apache.neethi.builders.AssertionBuilder;
+import org.swssf.policy.secpolicy.*;
+import org.swssf.policy.secpolicy.model.IssuedToken;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * class lent from apache rampart
+ */
+public class IssuedTokenBuilder implements AssertionBuilder {
+
+ private static final QName[] KNOWN_ELEMENTS = new QName[]{
+ SP11Constants.ISSUED_TOKEN,
+ SP12Constants.ISSUED_TOKEN,
+ SP13Constants.ISSUED_TOKEN
+ };
+
+ public Assertion build(OMElement element, AssertionBuilderFactory factory)
+ throws IllegalArgumentException {
+
+ SPConstants spConstants = PolicyUtil.getSPVersion(element.getQName().getNamespaceURI());
+
+ IssuedToken issuedToken = new IssuedToken(spConstants);
+
+ OMAttribute includeAttr = element.getAttribute(spConstants.getIncludeToken());
+ if (includeAttr != null) {
+ SPConstants.IncludeTokenType inclusion = spConstants.getInclusionFromAttributeValue(includeAttr.getAttributeValue());
+ issuedToken.setInclusion(inclusion);
+ }
+ // Extract Issuer
+ OMElement issuerElem = element.getFirstChildWithName(spConstants.getIssuer());
+
+ 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(spConstants.getRequestSecurityTokenTemplate());
+ 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);
+
+ for (Iterator iterator = policy.getAlternatives(); iterator
+ .hasNext(); ) {
+ processAlternative((List) iterator.next(), issuedToken, spConstants);
+ break; // since there should be only one alternative ..
+ }
+ }
+
+ return issuedToken;
+ }
+
+ public QName[] getKnownElements() {
+ return KNOWN_ELEMENTS;
+ }
+
+ private void processAlternative(List assertions, IssuedToken parent, SPConstants spConstants) {
+ Assertion assertion;
+ QName name;
+
+ for (Iterator iterator = assertions.iterator(); iterator.hasNext(); ) {
+ assertion = (Assertion) iterator.next();
+ name = assertion.getName();
+
+ if (spConstants.getRequiredDerivedKeys().equals(name)) {
+ parent.setDerivedKeys(true);
+ } else if (spConstants.getRequireExternalRefernce().equals(name)) {
+ parent.setRequireExternalReference(true);
+ } else if (spConstants.getRequireInternalRefernce().equals(name)) {
+ parent.setRequireInternalReference(true);
+ }
+ }
+
+ }
+}
Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/IssuedTokenBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/LayoutBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/LayoutBuilder.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/LayoutBuilder.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/LayoutBuilder.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,84 @@
+/**
+ * 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.swssf.policy.secpolicybuilder;
+
+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.swssf.policy.secpolicy.*;
+import org.swssf.policy.secpolicy.model.Layout;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * class lent from apache rampart
+ */
+public class LayoutBuilder implements AssertionBuilder {
+
+ private static final QName[] KNOWN_ELEMENTS = new QName[]{
+ SP11Constants.LAYOUT,
+ SP12Constants.LAYOUT,
+ SP13Constants.LAYOUT
+ };
+
+ public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+
+ SPConstants spConstants = PolicyUtil.getSPVersion(element.getQName().getNamespaceURI());
+
+ Layout layout = new Layout(spConstants);
+
+ Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
+ policy = (Policy) policy.normalize(false);
+
+ for (Iterator iterator = policy.getAlternatives(); iterator.hasNext(); ) {
+ processAlternative((List) iterator.next(), layout, spConstants);
+ break; // there should be only one alternative
+ }
+
+ return layout;
+ }
+
+ public QName[] getKnownElements() {
+ return KNOWN_ELEMENTS;
+ }
+
+ public void processAlternative(List assertions, Layout parent, SPConstants spConstants) {
+
+ for (Iterator iterator = assertions.iterator(); iterator.hasNext(); ) {
+ Assertion assertion = (Assertion) iterator.next();
+ QName qname = assertion.getName();
+
+ if (spConstants.getStrict().equals(qname)) {
+ parent.setValue(SPConstants.LAYOUT_STRICT);
+ } else if (spConstants.getLax().equals(qname)) {
+ parent.setValue(SPConstants.LAYOUT_LAX);
+ } else if (spConstants.getLaxtsfirst().equals(qname)) {
+ parent.setValue(SPConstants.LAYOUT_LAX_TIMESTAMP_FIRST);
+ } else if (spConstants.getLaxtslast().equals(qname)) {
+ parent.setValue(SPConstants.LAYOUT_LAX_TIMESTAMP_LAST);
+ }
+
+ }
+ }
+}
Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/LayoutBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/ProtectionTokenBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/ProtectionTokenBuilder.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/ProtectionTokenBuilder.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/ProtectionTokenBuilder.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,74 @@
+/**
+ * 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.swssf.policy.secpolicybuilder;
+
+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.swssf.policy.secpolicy.*;
+import org.swssf.policy.secpolicy.model.ProtectionToken;
+import org.swssf.policy.secpolicy.model.Token;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * class lent from apache rampart
+ */
+public class ProtectionTokenBuilder implements AssertionBuilder {
+
+ private static final QName[] KNOWN_ELEMENTS = new QName[]{
+ SP11Constants.PROTECTION_TOKEN,
+ SP12Constants.PROTECTION_TOKEN,
+ SP13Constants.PROTECTION_TOKEN
+ };
+
+ public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+
+ SPConstants spConstants = PolicyUtil.getSPVersion(element.getQName().getNamespaceURI());
+
+ ProtectionToken protectionToken = new ProtectionToken(spConstants);
+
+ 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 KNOWN_ELEMENTS;
+ }
+
+ private void processAlternative(List assertions, ProtectionToken parent) {
+ Object token = assertions.get(0);
+
+ if (token instanceof Token) {
+ parent.setToken((Token) token);
+ }
+ }
+}
Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/ProtectionTokenBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/RecipientTokenBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/RecipientTokenBuilder.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/RecipientTokenBuilder.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/RecipientTokenBuilder.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,85 @@
+/**
+ * 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.swssf.policy.secpolicybuilder;
+
+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.swssf.policy.secpolicy.*;
+import org.swssf.policy.secpolicy.model.RecipientToken;
+import org.swssf.policy.secpolicy.model.Token;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * class lent from apache rampart
+ */
+public class RecipientTokenBuilder implements AssertionBuilder {
+
+ private static final QName[] KNOWN_ELEMENTS = new QName[]{
+ SP11Constants.RECIPIENT_TOKEN,
+ SP12Constants.RECIPIENT_TOKEN,
+ SP13Constants.RECIPIENT_TOKEN
+ };
+
+ public Assertion build(OMElement element, AssertionBuilderFactory factory)
+ throws IllegalArgumentException {
+
+ SPConstants spConstants = PolicyUtil.getSPVersion(element.getQName().getNamespaceURI());
+
+ RecipientToken recipientToken = new RecipientToken(spConstants);
+
+ Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
+ policy = (Policy) policy.normalize(false);
+
+ for (Iterator iterator = policy.getAlternatives(); iterator.hasNext(); ) {
+ processAlternative((List) iterator.next(), recipientToken);
+
+ /*
+ * for the moment we will pick the first token specified in the policy
+ */
+ break;
+ }
+
+ return recipientToken;
+ }
+
+ private void processAlternative(List assertions, RecipientToken parent) {
+
+ Assertion assertion;
+
+ for (Iterator iterator = assertions.iterator(); iterator.hasNext(); ) {
+ assertion = (Assertion) iterator.next();
+
+ if (assertion instanceof Token) {
+ parent.setToken((Token) assertion);
+ }
+ }
+ }
+
+ public QName[] getKnownElements() {
+ return KNOWN_ELEMENTS;
+ }
+
+}
Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/RecipientTokenBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/RequiredElementsBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/RequiredElementsBuilder.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/RequiredElementsBuilder.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/RequiredElementsBuilder.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,78 @@
+/**
+ * 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.swssf.policy.secpolicybuilder;
+
+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.swssf.policy.secpolicy.*;
+import org.swssf.policy.secpolicy.model.RequiredElements;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+/**
+ * class lent from apache rampart
+ */
+public class RequiredElementsBuilder implements AssertionBuilder {
+
+ private static final QName[] KNOWN_ELEMENTS = new QName[]{
+ SP11Constants.REQUIRED_ELEMENTS,
+ SP12Constants.REQUIRED_ELEMENTS,
+ SP13Constants.REQUIRED_ELEMENTS
+ };
+
+ public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+
+ SPConstants spConstants = PolicyUtil.getSPVersion(element.getQName().getNamespaceURI());
+
+ RequiredElements requiredElements = new RequiredElements(spConstants);
+ OMAttribute attrXPathVersion = element.getAttribute(spConstants.getAttrXpathVersion());
+
+ if (attrXPathVersion != null) {
+ requiredElements.setXPathVersion(attrXPathVersion.getAttributeValue());
+ }
+
+ for (Iterator iterator = element.getChildElements(); iterator.hasNext(); ) {
+ processElement((OMElement) iterator.next(), requiredElements, spConstants);
+ }
+
+ return requiredElements;
+ }
+
+ public QName[] getKnownElements() {
+ return KNOWN_ELEMENTS;
+ }
+
+ private void processElement(OMElement element, RequiredElements parent, SPConstants spConstants) {
+ QName name = element.getQName();
+ if (spConstants.getXpath().equals(name)) {
+ parent.addXPathExpression(element.getText());
+ Iterator namespaces = element.getAllDeclaredNamespaces();
+ while (namespaces.hasNext()) {
+ OMNamespace nm = (OMNamespace) namespaces.next();
+ parent.addDeclaredNamespaces(nm.getNamespaceURI(), nm.getPrefix());
+ }
+ }
+ }
+
+}
Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/RequiredElementsBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/RequiredPartsBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/RequiredPartsBuilder.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/RequiredPartsBuilder.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/RequiredPartsBuilder.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,82 @@
+/**
+ * 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.swssf.policy.secpolicybuilder;
+
+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.builders.AssertionBuilder;
+import org.swssf.policy.secpolicy.PolicyUtil;
+import org.swssf.policy.secpolicy.SP12Constants;
+import org.swssf.policy.secpolicy.SP13Constants;
+import org.swssf.policy.secpolicy.SPConstants;
+import org.swssf.policy.secpolicy.model.Header;
+import org.swssf.policy.secpolicy.model.RequiredParts;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+/**
+ * class lent from apache rampart
+ */
+public class RequiredPartsBuilder implements AssertionBuilder {
+
+ private static final QName[] KNOWN_ELEMENTS = new QName[]{
+ SP12Constants.REQUIRED_PARTS,
+ SP13Constants.REQUIRED_PARTS
+ };
+
+ public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+
+ SPConstants spConstants = PolicyUtil.getSPVersion(element.getQName().getNamespaceURI());
+
+ RequiredParts requiredParts = new RequiredParts(spConstants);
+
+ for (Iterator iterator = element.getChildElements(); iterator.hasNext(); ) {
+ processElement((OMElement) iterator.next(), requiredParts, spConstants);
+ }
+
+ return requiredParts;
+ }
+
+ public QName[] getKnownElements() {
+ return KNOWN_ELEMENTS;
+ }
+
+ private void processElement(OMElement element, RequiredParts parent, SPConstants spConstants) {
+
+ QName name = element.getQName();
+
+ if (spConstants.getHeader().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);
+
+ }
+ }
+}
Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/RequiredPartsBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SecureConversationTokenBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SecureConversationTokenBuilder.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SecureConversationTokenBuilder.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SecureConversationTokenBuilder.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,100 @@
+/**
+ * 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.swssf.policy.secpolicybuilder;
+
+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.Policy;
+import org.apache.neethi.PolicyEngine;
+import org.apache.neethi.builders.AssertionBuilder;
+import org.swssf.policy.secpolicy.*;
+import org.swssf.policy.secpolicy.model.SecureConversationToken;
+
+import javax.xml.namespace.QName;
+
+/**
+ * class lent from apache rampart
+ */
+public class SecureConversationTokenBuilder implements AssertionBuilder {
+
+ private static final QName[] KNOWN_ELEMENTS = new QName[]{
+ SP11Constants.SECURE_CONVERSATION_TOKEN,
+ SP12Constants.SECURE_CONVERSATION_TOKEN,
+ SP13Constants.SECURE_CONVERSATION_TOKEN
+ };
+
+ public Assertion build(OMElement element, AssertionBuilderFactory factory)
+ throws IllegalArgumentException {
+
+ SPConstants spConstants = PolicyUtil.getSPVersion(element.getQName().getNamespaceURI());
+
+ SecureConversationToken conversationToken = new SecureConversationToken(spConstants);
+
+ OMAttribute attribute = element.getAttribute(spConstants.getIncludeToken());
+ if (attribute == null) {
+ throw new IllegalArgumentException(
+ "SecurityContextToken doesn't contain any sp:IncludeToken attribute");
+ }
+
+ String inclusionValue = attribute.getAttributeValue().trim();
+
+ conversationToken.setInclusion(spConstants.getInclusionFromAttributeValue(inclusionValue));
+
+ OMElement issuer = element.getFirstChildWithName(spConstants.getIssuer());
+ if (issuer != null) {
+ conversationToken.setIssuerEpr(issuer.getFirstElement());
+ }
+
+ element = element.getFirstChildWithName(SPConstants.POLICY);
+ if (element != null) {
+ if (element.getFirstChildWithName(spConstants.getRequiredDerivedKeys()) != null) {
+ conversationToken.setDerivedKeys(true);
+ } else if (element.getFirstChildWithName(spConstants.getRequireImpliedDerivedKeys()) != null) {
+ conversationToken.setImpliedDerivedKeys(true);
+ } else if (element.getFirstChildWithName(spConstants.getRequireExplicitDerivedKeys()) != null) {
+ conversationToken.setExplicitDerivedKeys(true);
+ }
+
+ if (element
+ .getFirstChildWithName(spConstants.getRequireExternalUriRefernce()) != null) {
+ conversationToken.setRequireExternalUriRef(true);
+ }
+
+ if (element
+ .getFirstChildWithName(spConstants.getSc10SecurityContextToken()) != null) {
+ conversationToken.setSc10SecurityContextToken(true);
+ }
+
+ OMElement bootstrapPolicyElement = element.getFirstChildWithName(spConstants.getBootstrapPolicy());
+ if (bootstrapPolicyElement != null) {
+ Policy policy = PolicyEngine.getPolicy(bootstrapPolicyElement.getFirstElement());
+ conversationToken.setBootstrapPolicy(policy);
+ }
+ }
+
+ return conversationToken;
+ }
+
+ public QName[] getKnownElements() {
+ return KNOWN_ELEMENTS;
+ }
+
+}
Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SecureConversationTokenBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SecurityContextTokenBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SecurityContextTokenBuilder.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SecurityContextTokenBuilder.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SecurityContextTokenBuilder.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,81 @@
+/**
+ * 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.swssf.policy.secpolicybuilder;
+
+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.builders.AssertionBuilder;
+import org.swssf.policy.secpolicy.*;
+import org.swssf.policy.secpolicy.model.SecurityContextToken;
+
+import javax.xml.namespace.QName;
+
+/**
+ * class lent from apache rampart
+ */
+public class SecurityContextTokenBuilder implements AssertionBuilder {
+
+ private static final QName[] KNOWN_ELEMENTS = new QName[]{
+ SP11Constants.SECURITY_CONTEXT_TOKEN,
+ SP12Constants.SECURITY_CONTEXT_TOKEN,
+ SP13Constants.SECURITY_CONTEXT_TOKEN
+ };
+
+ public Assertion build(OMElement element, AssertionBuilderFactory factory)
+ throws IllegalArgumentException {
+
+ SPConstants spConstants = PolicyUtil.getSPVersion(element.getQName().getNamespaceURI());
+
+ SecurityContextToken contextToken = new SecurityContextToken(spConstants);
+
+ OMAttribute includeAttr = element.getAttribute(spConstants.getIncludeToken());
+ if (includeAttr != null) {
+ SPConstants.IncludeTokenType inclusion = spConstants.getInclusionFromAttributeValue(includeAttr.getAttributeValue());
+ contextToken.setInclusion(inclusion);
+ }
+
+ element = element.getFirstChildWithName(SPConstants.POLICY);
+
+ if (element != null) {
+
+ if (element.getFirstChildWithName(spConstants.getRequiredDerivedKeys()) != null) {
+ contextToken.setDerivedKeys(true);
+ }
+
+ if (element
+ .getFirstChildWithName(spConstants.getRequireExternalUriRefernce()) != null) {
+ contextToken.setRequireExternalUriRef(true);
+ }
+
+ if (element
+ .getFirstChildWithName(spConstants.getSc10SecurityContextToken()) != null) {
+ contextToken.setSc10SecurityContextToken(true);
+ }
+ }
+
+ return contextToken;
+ }
+
+ public QName[] getKnownElements() {
+ return KNOWN_ELEMENTS;
+ }
+
+}
Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SecurityContextTokenBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SignedElementsBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SignedElementsBuilder.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SignedElementsBuilder.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SignedElementsBuilder.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,78 @@
+/**
+ * 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.swssf.policy.secpolicybuilder;
+
+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.swssf.policy.secpolicy.*;
+import org.swssf.policy.secpolicy.model.SignedEncryptedElements;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+/**
+ * class lent from apache rampart
+ */
+public class SignedElementsBuilder implements AssertionBuilder {
+
+ private static final QName[] KNOWN_ELEMENTS = new QName[]{
+ SP11Constants.SIGNED_ELEMENTS,
+ SP12Constants.SIGNED_ELEMENTS,
+ SP13Constants.SIGNED_ELEMENTS
+ };
+
+ public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+
+ SPConstants spConstants = PolicyUtil.getSPVersion(element.getQName().getNamespaceURI());
+
+ SignedEncryptedElements signedEncryptedElements = new SignedEncryptedElements(true, spConstants);
+ OMAttribute attrXPathVersion = element.getAttribute(spConstants.getAttrXpathVersion());
+
+ if (attrXPathVersion != null) {
+ signedEncryptedElements.setXPathVersion(attrXPathVersion.getAttributeValue());
+ }
+
+ for (Iterator iterator = element.getChildElements(); iterator.hasNext(); ) {
+ processElement((OMElement) iterator.next(), signedEncryptedElements, spConstants);
+ }
+
+ return signedEncryptedElements;
+ }
+
+ public QName[] getKnownElements() {
+ return KNOWN_ELEMENTS;
+ }
+
+ private void processElement(OMElement element, SignedEncryptedElements parent, SPConstants spConstants) {
+ QName name = element.getQName();
+ if (spConstants.getXpath().equals(name)) {
+ parent.addXPathExpression(element.getText());
+ Iterator namespaces = element.getAllDeclaredNamespaces();
+ while (namespaces.hasNext()) {
+ OMNamespace nm = (OMNamespace) namespaces.next();
+ parent.addDeclaredNamespaces(nm.getNamespaceURI(), nm.getPrefix());
+ }
+ }
+ }
+
+}
Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SignedElementsBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SignedPartsBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SignedPartsBuilder.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SignedPartsBuilder.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SignedPartsBuilder.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,84 @@
+/**
+ * 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.swssf.policy.secpolicybuilder;
+
+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.builders.AssertionBuilder;
+import org.swssf.policy.secpolicy.*;
+import org.swssf.policy.secpolicy.model.Header;
+import org.swssf.policy.secpolicy.model.SignedEncryptedParts;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+/**
+ * class lent from apache rampart
+ */
+public class SignedPartsBuilder implements AssertionBuilder {
+
+ private static final QName[] KNOWN_ELEMENTS = new QName[]{
+ SP11Constants.SIGNED_PARTS,
+ SP12Constants.SIGNED_PARTS,
+ SP13Constants.SIGNED_PARTS
+ };
+
+ public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+
+ SPConstants spConstants = PolicyUtil.getSPVersion(element.getQName().getNamespaceURI());
+
+ SignedEncryptedParts signedEncryptedParts = new SignedEncryptedParts(true, spConstants);
+
+ for (Iterator iterator = element.getChildElements(); iterator.hasNext(); ) {
+ processElement((OMElement) iterator.next(), signedEncryptedParts, spConstants);
+ }
+
+ return signedEncryptedParts;
+ }
+
+ public QName[] getKnownElements() {
+ return KNOWN_ELEMENTS;
+ }
+
+ private void processElement(OMElement element, SignedEncryptedParts parent, SPConstants spConstants) {
+
+ QName name = element.getQName();
+
+ if (spConstants.getHeader().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 (spConstants.getBody().equals(name)) {
+ parent.setBody(true);
+ } else if (spConstants.getAttachments().equals(name)) {
+ parent.setAttachments(true);
+ }
+ }
+}
Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SignedPartsBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SupportingTokensBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SupportingTokensBuilder.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SupportingTokensBuilder.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SupportingTokensBuilder.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,144 @@
+/**
+ * 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.swssf.policy.secpolicybuilder;
+
+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.swssf.policy.secpolicy.PolicyUtil;
+import org.swssf.policy.secpolicy.SP12Constants;
+import org.swssf.policy.secpolicy.SP13Constants;
+import org.swssf.policy.secpolicy.SPConstants;
+import org.swssf.policy.secpolicy.model.*;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * class lent from apache rampart
+ */
+public class SupportingTokensBuilder implements AssertionBuilder {
+
+ private static final QName[] KNOWN_ELEMENTS = new QName[]{
+ SP12Constants.SUPPORTING_TOKENS,
+ SP12Constants.SIGNED_SUPPORTING_TOKENS,
+ SP12Constants.ENDORSING_SUPPORTING_TOKENS,
+ SP12Constants.SIGNED_ENDORSING_SUPPORTING_TOKENS,
+ SP12Constants.ENCRYPTED_SUPPORTING_TOKENS,
+ SP12Constants.SIGNED_ENCRYPTED_SUPPORTING_TOKENS,
+ SP12Constants.ENDORSING_ENCRYPTED_SUPPORTING_TOKENS,
+ SP12Constants.SIGNED_ENDORSING_ENCRYPTED_SUPPORTING_TOKENS,
+ SP13Constants.SUPPORTING_TOKENS,
+ SP13Constants.SIGNED_SUPPORTING_TOKENS,
+ SP13Constants.ENDORSING_SUPPORTING_TOKENS,
+ SP13Constants.SIGNED_ENDORSING_SUPPORTING_TOKENS,
+ SP13Constants.ENCRYPTED_SUPPORTING_TOKENS,
+ SP13Constants.SIGNED_ENCRYPTED_SUPPORTING_TOKENS,
+ SP13Constants.ENDORSING_ENCRYPTED_SUPPORTING_TOKENS,
+ SP13Constants.SIGNED_ENDORSING_ENCRYPTED_SUPPORTING_TOKENS
+ };
+
+ public Assertion build(OMElement element, AssertionBuilderFactory factory)
+ throws IllegalArgumentException {
+
+ SPConstants spConstants = PolicyUtil.getSPVersion(element.getQName().getNamespaceURI());
+
+ QName name = element.getQName();
+ SupportingToken supportingToken = null;
+
+ if (spConstants.getSupportingTokens().equals(name)) {
+ supportingToken = new SupportingToken(
+ SPConstants.SupportingTokenType.SUPPORTING, spConstants);
+ } else if (spConstants.getSignedSupportingTokens().equals(name)) {
+ supportingToken = new SupportingToken(
+ SPConstants.SupportingTokenType.SIGNED, spConstants);
+ } else if (spConstants.getEndorsingSupportingTokens().equals(name)) {
+ supportingToken = new SupportingToken(
+ SPConstants.SupportingTokenType.ENDORSING, spConstants);
+ } else if (spConstants.getSignedEndorsingSupportingTokens().equals(name)) {
+ supportingToken = new SupportingToken(
+ SPConstants.SupportingTokenType.SIGNED_ENDORSING, spConstants);
+ } else if (spConstants.getEncryptedSupportingTokens().equals(name)) {
+ supportingToken = new SupportingToken(
+ SPConstants.SupportingTokenType.ENCRYPTED, spConstants);
+ } else if (spConstants.getSignedEncryptedSupportingTokens().equals(name)) {
+ supportingToken = new SupportingToken(
+ SPConstants.SupportingTokenType.SIGNED_ENCRYPTED, spConstants);
+ } else if (spConstants.getEndorsingEncryptedSupportingTokens().equals(name)) {
+ supportingToken = new SupportingToken(
+ SPConstants.SupportingTokenType.ENDORSING_ENCRYPTED, spConstants);
+ } else if (spConstants.getSignedEndorsingEncryptedSupportingTokens().equals(name)) {
+ supportingToken = new SupportingToken(
+ SPConstants.SupportingTokenType.SIGNED_ENDORSING_ENCRYPTED, spConstants);
+ }
+
+ Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
+ policy = (Policy) policy.normalize(false);
+
+ for (Iterator iterator = policy.getAlternatives(); iterator.hasNext(); ) {
+ processAlternative((List) iterator.next(), supportingToken, spConstants);
+ /*
+ * for the moment we will say there should be only one alternative
+ */
+ break;
+ }
+
+ return supportingToken;
+ }
+
+ public QName[] getKnownElements() {
+ return KNOWN_ELEMENTS;
+ }
+
+ private void processAlternative(List assertions, SupportingToken supportingToken, SPConstants spConstants) {
+
+ for (Iterator iterator = assertions.iterator(); iterator.hasNext(); ) {
+
+ Assertion primitive = (Assertion) iterator.next();
+ QName qname = primitive.getName();
+
+ if (spConstants.getAlgorithmSuite().equals(qname)) {
+ supportingToken.setAlgorithmSuite((AlgorithmSuite) primitive);
+
+ } else if (spConstants.getSignedParts().equals(qname)) {
+ supportingToken
+ .setSignedParts((SignedEncryptedParts) primitive);
+
+ } else if (spConstants.getSignedElements().equals(qname)) {
+ supportingToken
+ .setSignedElements((SignedEncryptedElements) primitive);
+
+ } else if (spConstants.getEncryptedParts().equals(qname)) {
+ supportingToken
+ .setEncryptedParts((SignedEncryptedParts) primitive);
+
+ } else if (spConstants.getEncryptedElements().equals(qname)) {
+ supportingToken
+ .setEncryptedElements((SignedEncryptedElements) primitive);
+
+ } else if (primitive instanceof Token) {
+ supportingToken.setToken((Token) primitive);
+ }
+ }
+ }
+}
Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SupportingTokensBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SymmetricBindingBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SymmetricBindingBuilder.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SymmetricBindingBuilder.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SymmetricBindingBuilder.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,105 @@
+/**
+ * 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.swssf.policy.secpolicybuilder;
+
+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.swssf.policy.secpolicy.*;
+import org.swssf.policy.secpolicy.model.AlgorithmSuite;
+import org.swssf.policy.secpolicy.model.Layout;
+import org.swssf.policy.secpolicy.model.ProtectionToken;
+import org.swssf.policy.secpolicy.model.SymmetricBinding;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * class lent from apache rampart
+ */
+public class SymmetricBindingBuilder implements AssertionBuilder {
+
+ private static final QName[] KNOWN_ELEMENTS = new QName[]{
+ SP11Constants.SYMMETRIC_BINDING,
+ SP12Constants.SYMMETRIC_BINDING,
+ SP13Constants.SYMMETRIC_BINDING
+ };
+
+ public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+
+ SPConstants spConstants = PolicyUtil.getSPVersion(element.getQName().getNamespaceURI());
+
+ SymmetricBinding symmetricBinding = new SymmetricBinding(spConstants);
+
+ Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
+ policy = (Policy) policy.normalize(false);
+
+ for (Iterator iterator = policy.getAlternatives(); iterator.hasNext(); ) {
+ processAlternatives((List) iterator.next(), symmetricBinding, spConstants);
+
+ /*
+ * since there should be only one alternative ..
+ */
+ break;
+ }
+ return symmetricBinding;
+ }
+
+ public QName[] getKnownElements() {
+ return KNOWN_ELEMENTS;
+ }
+
+ private void processAlternatives(List assertions, SymmetricBinding symmetricBinding, SPConstants spConstants) {
+ Assertion assertion;
+ QName name;
+
+ for (Iterator iterator = assertions.iterator(); iterator.hasNext(); ) {
+ assertion = (Assertion) iterator.next();
+ name = assertion.getName();
+
+ if (spConstants.getAlgorithmSuite().equals(name)) {
+ symmetricBinding.setAlgorithmSuite((AlgorithmSuite) assertion);
+
+ } else if (spConstants.getLayout().equals(name)) {
+ symmetricBinding.setLayout((Layout) assertion);
+
+ } else if (spConstants.getIncludeTimestamp().equals(name)) {
+ symmetricBinding.setIncludeTimestamp(true);
+
+ } else if (spConstants.getProtectionToken().equals(name)) {
+ symmetricBinding.setProtectionToken((ProtectionToken) assertion);
+
+ } else if (spConstants.getEncryptBeforeSigning().equals(name)) {
+ symmetricBinding.setProtectionOrder(SPConstants.ProtectionOrder.EncryptBeforeSigning);
+
+ } else if (spConstants.getSignBeforeEncrypting().equals(name)) {
+ symmetricBinding.setProtectionOrder(SPConstants.ProtectionOrder.SignBeforeEncrypting);
+
+ } else if (spConstants.getOnlySignEntireHeadersAndBody().equals(name)) {
+ symmetricBinding.setEntireHeadersAndBodySignatures(true);
+ } else if (spConstants.getEncryptSignature().equals(name)) {
+ symmetricBinding.setSignatureProtection(true);
+ }
+ }
+ }
+}
Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/SymmetricBindingBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/TransportBindingBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/TransportBindingBuilder.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/TransportBindingBuilder.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/TransportBindingBuilder.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,97 @@
+/**
+ * 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.swssf.policy.secpolicybuilder;
+
+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.swssf.policy.secpolicy.*;
+import org.swssf.policy.secpolicy.model.*;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * class lent from apache rampart
+ */
+public class TransportBindingBuilder implements AssertionBuilder {
+
+ private static final QName[] KNOWN_ELEMENTS = new QName[]{
+ SP11Constants.TRANSPORT_BINDING,
+ SP12Constants.TRANSPORT_BINDING,
+ SP13Constants.TRANSPORT_BINDING
+ };
+
+ public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+
+ SPConstants spConstants = PolicyUtil.getSPVersion(element.getQName().getNamespaceURI());
+
+ TransportBinding transportBinding = new TransportBinding(spConstants);
+
+ Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
+ policy = (Policy) policy.normalize(false);
+
+ for (Iterator iterator = policy.getAlternatives(); iterator.hasNext(); ) {
+ processAlternative((List) iterator.next(), transportBinding, factory, spConstants);
+
+ /*
+ * since there should be only one alternative
+ */
+ break;
+ }
+
+ return transportBinding;
+ }
+
+ public QName[] getKnownElements() {
+ return KNOWN_ELEMENTS;
+ }
+
+ private void processAlternative(List assertionList, TransportBinding parent, AssertionBuilderFactory factory, SPConstants spConstants) {
+
+ for (Iterator iterator = assertionList.iterator(); iterator.hasNext(); ) {
+
+ Assertion primitive = (Assertion) iterator.next();
+ QName name = primitive.getName();
+
+ if (name.equals(spConstants.getAlgorithmSuite())) {
+ parent.setAlgorithmSuite((AlgorithmSuite) primitive);
+
+ } else if (name.equals(spConstants.getTransportToken())) {
+ parent.setTransportToken(((TransportToken) primitive));
+
+ } else if (name.equals(spConstants.getIncludeTimestamp())) {
+ parent.setIncludeTimestamp(true);
+
+ } else if (name.equals(spConstants.getLayout())) {
+ parent.setLayout((Layout) primitive);
+
+ } else if (name.equals(spConstants.getSignedSupportingTokens())) {
+ parent.setSignedSupportingToken((SupportingToken) primitive);
+
+ } else if (name.equals(spConstants.getSignedEndorsingSupportingTokens())) {
+ parent.setSignedEndorsingSupportingTokens((SupportingToken) primitive);
+ }
+ }
+ }
+}
Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/TransportBindingBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/TransportTokenBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/TransportTokenBuilder.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/TransportTokenBuilder.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/TransportTokenBuilder.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,79 @@
+/**
+ * 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.swssf.policy.secpolicybuilder;
+
+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.swssf.policy.secpolicy.*;
+import org.swssf.policy.secpolicy.model.HttpsToken;
+import org.swssf.policy.secpolicy.model.TransportToken;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * class lent from apache rampart
+ */
+public class TransportTokenBuilder implements AssertionBuilder {
+
+ private static final QName[] KNOWN_ELEMENTS = new QName[]{
+ SP11Constants.TRANSPORT_TOKEN,
+ SP12Constants.TRANSPORT_TOKEN,
+ SP13Constants.TRANSPORT_TOKEN
+ };
+
+ public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+
+ SPConstants spConstants = PolicyUtil.getSPVersion(element.getQName().getNamespaceURI());
+
+ TransportToken transportToken = new TransportToken(spConstants);
+
+ Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
+ policy = (Policy) policy.normalize(false);
+
+ for (Iterator iterator = policy.getAlternatives(); iterator.hasNext(); ) {
+ processAlternative((List) iterator.next(), transportToken, spConstants);
+ break; // since there should be only one alternative
+ }
+
+ return transportToken;
+ }
+
+ public QName[] getKnownElements() {
+ return KNOWN_ELEMENTS;
+ }
+
+ private void processAlternative(List assertions, TransportToken parent, SPConstants spConstants) {
+
+ Object token;
+
+ for (Iterator iterator = assertions.iterator(); iterator.hasNext(); ) {
+ token = iterator.next();
+
+ if (token instanceof HttpsToken) {
+ parent.setToken((HttpsToken) token);
+ }
+ }
+ }
+}
Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/TransportTokenBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/Trust13Builder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/Trust13Builder.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/Trust13Builder.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/Trust13Builder.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,94 @@
+/**
+ * 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.swssf.policy.secpolicybuilder;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.AssertionBuilderFactory;
+import org.apache.neethi.builders.AssertionBuilder;
+import org.swssf.policy.secpolicy.PolicyUtil;
+import org.swssf.policy.secpolicy.SP12Constants;
+import org.swssf.policy.secpolicy.SP13Constants;
+import org.swssf.policy.secpolicy.SPConstants;
+import org.swssf.policy.secpolicy.model.Trust13;
+
+import javax.xml.namespace.QName;
+
+/**
+ * class lent from apache rampart
+ */
+public class Trust13Builder implements AssertionBuilder {
+
+ private static final QName[] KNOWN_ELEMENTS = new QName[]{
+ SP12Constants.TRUST_13,
+ SP13Constants.TRUST_13
+ };
+
+ public Assertion build(OMElement element, AssertionBuilderFactory factory)
+ throws IllegalArgumentException {
+
+ element = element.getFirstChildWithName(SPConstants.POLICY);
+
+ if (element == null) {
+ throw new IllegalArgumentException(
+ "Trust10 assertion doesn't contain any Policy");
+ }
+
+ SPConstants spConstants = PolicyUtil.getSPVersion(element.getQName().getNamespaceURI());
+
+ Trust13 trust13 = new Trust13(spConstants);
+
+ if (element
+ .getFirstChildWithName(spConstants.getMustSupportClientChallenge()) != null) {
+ trust13.setMustSupportClientChallenge(true);
+ }
+
+ if (element
+ .getFirstChildWithName(spConstants.getMustSupportServerChallenge()) != null) {
+ trust13.setMustSupportServerChallenge(true);
+ }
+
+ if (element.getFirstChildWithName(spConstants.getRequireClientEntropy()) != null) {
+ trust13.setRequireClientEntropy(true);
+ }
+
+ if (element.getFirstChildWithName(spConstants.getRequireServerEntropy()) != null) {
+ trust13.setRequireServerEntropy(true);
+ }
+
+ if (element.getFirstChildWithName(spConstants.getMustSupportIssuedTokens()) != null) {
+ trust13.setMustSupportIssuedTokens(true);
+ }
+
+ if (element.getFirstChildWithName(spConstants.getRequireRequestSecurityTokenCollection()) != null) {
+ trust13.setRequireRequestSecurityTokenCollection(true);
+ }
+
+ if (element.getFirstChildWithName(spConstants.getRequireAppliesTo()) != null) {
+ trust13.setRequireAppliesTo(true);
+ }
+
+ return trust13;
+ }
+
+ public QName[] getKnownElements() {
+ return KNOWN_ELEMENTS;
+ }
+
+}
Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/Trust13Builder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/UsernameTokenBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/UsernameTokenBuilder.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/UsernameTokenBuilder.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/UsernameTokenBuilder.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,110 @@
+/**
+ * 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.swssf.policy.secpolicybuilder;
+
+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.Policy;
+import org.apache.neethi.PolicyEngine;
+import org.apache.neethi.builders.AssertionBuilder;
+import org.swssf.policy.secpolicy.*;
+import org.swssf.policy.secpolicy.model.UsernameToken;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * class lent from apache rampart
+ */
+public class UsernameTokenBuilder implements AssertionBuilder {
+
+ private static final QName[] KNOWN_ELEMENTS = new QName[]{
+ SP11Constants.USERNAME_TOKEN,
+ SP12Constants.USERNAME_TOKEN,
+ SP13Constants.USERNAME_TOKEN
+ };
+
+ public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
+
+ SPConstants spConstants = PolicyUtil.getSPVersion(element.getQName().getNamespaceURI());
+
+ UsernameToken usernameToken = new UsernameToken(spConstants);
+
+ OMAttribute attribute = element.getAttribute(spConstants.getIncludeToken());
+
+ if (attribute != null) {
+ SPConstants.IncludeTokenType inclusion = spConstants.getInclusionFromAttributeValue(attribute.getAttributeValue());
+ usernameToken.setInclusion(inclusion);
+ }
+
+ OMElement policyElement = element.getFirstElement();
+
+ if (policyElement != null && policyElement.getQName().equals(org.apache.neethi.Constants.Q_ELEM_POLICY)) {
+
+ Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
+ policy = (Policy) policy.normalize(false);
+
+ for (Iterator iterator = policy.getAlternatives(); iterator.hasNext(); ) {
+ processAlternative((List) iterator.next(), usernameToken, spConstants);
+
+ /*
+ * since there should be only one alternative
+ */
+ break;
+ }
+ }
+
+ return usernameToken;
+ }
+
+ public QName[] getKnownElements() {
+ return KNOWN_ELEMENTS;
+ }
+
+ private void processAlternative(List assertions, UsernameToken parent, SPConstants spConstants) {
+
+ for (Iterator iterator = assertions.iterator(); iterator.hasNext(); ) {
+ Assertion assertion = (Assertion) iterator.next();
+ QName qname = assertion.getName();
+
+ if (spConstants.getWssUsernameToken10().equals(qname)) {
+ parent.setUseUTProfile10(true);
+ } else if (spConstants.getWssUsernameToken11().equals(qname)) {
+ parent.setUseUTProfile11(true);
+ } else if (spConstants.getNoPassword().equals(qname)) {
+ parent.setNoPassword(true);
+ } else if (spConstants.getHashPassword().equals(qname)) {
+ parent.setHashPassword(true);
+ } else if (spConstants.getCreated().equals(qname)) {
+ parent.setCreatedTimestamp(true);
+ } else if (spConstants.getNonce().equals(qname)) {
+ parent.setNonce(true);
+ } else if (spConstants.getRequireDerivedKeys().equals(qname)) {
+ parent.setDerivedKeys(true);
+ } else if (spConstants.getRequireExplicitDerivedKeys().equals(qname)) {
+ parent.setExplicitDerivedKeys(true);
+ } else if (spConstants.getRequireImpliedDerivedKeys().equals(qname)) {
+ parent.setImpliedDerivedKeys(true);
+ }
+ }
+ }
+}
Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicybuilder/UsernameTokenBuilder.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision