You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2006/08/31 13:42:07 UTC

svn commit: r438872 - in /webservices/axis2/trunk/java/modules/secpolicy/src: META-INF/services/ org/apache/ws/secpolicy/ org/apache/ws/secpolicy/builders/

Author: sanka
Date: Thu Aug 31 04:42:07 2006
New Revision: 438872

URL: http://svn.apache.org/viewvc?rev=438872&view=rev
Log:
Adding AssertionBuilder to build assertions concerned with SecureConversation

Added:
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/builders/SecureConversationTokenBuilder.java
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/builders/SecurityContextTokenBuilder.java
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/builders/Trust10Builder.java
Modified:
    webservices/axis2/trunk/java/modules/secpolicy/src/META-INF/services/org.apache.neethi.builders.AssertionBuilder
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/Constants.java

Modified: webservices/axis2/trunk/java/modules/secpolicy/src/META-INF/services/org.apache.neethi.builders.AssertionBuilder
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/secpolicy/src/META-INF/services/org.apache.neethi.builders.AssertionBuilder?rev=438872&r1=438871&r2=438872&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/secpolicy/src/META-INF/services/org.apache.neethi.builders.AssertionBuilder (original)
+++ webservices/axis2/trunk/java/modules/secpolicy/src/META-INF/services/org.apache.neethi.builders.AssertionBuilder Thu Aug 31 04:42:07 2006
@@ -15,4 +15,7 @@
 org.apache.ws.secpolicy.builders.WSS10Builder
 org.apache.ws.secpolicy.builders.WSS11Builder
 org.apache.ws.secpolicy.builders.X509TokenBuilder
+org.apache.ws.secpolicy.builders.Trust10Builder
+org.apache.ws.secpolicy.builders.SecurityContextTokenBuilder
+org.apache.ws.secpolicy.builders.SecureConversationTokenBuilder
 

Modified: webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/Constants.java?rev=438872&r1=438871&r2=438872&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/Constants.java (original)
+++ webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/Constants.java Thu Aug 31 04:42:07 2006
@@ -4,6 +4,10 @@
 
 public class Constants {
 
+    public static final String P_NS = "http://schemas.xmlsoap.org/ws/2004/09/policy";
+    
+    public static final QName POLICY = new QName(P_NS, "Policy");    
+    
     public final static String SP_NS = "http://schemas.xmlsoap.org/ws/2005/07/securitypolicy";
     
     public final static String ATTR_INCLUDE_TOKEN = "IncludeToken";
@@ -19,7 +23,6 @@
 
     public final static String INCLUDE_ALWAYS = Constants.SP_NS
             + "/IncludeToken/Always";
-
     
     public final static int SUPPORTING_TOKEN_SUPPORTING = 1;
     public final static int SUPPORTING_TOKEN_ENDORSING = 2;
@@ -255,7 +258,25 @@
     public static final QName MUST_SUPPORT_REF_ENCRYPTED_KEY = new QName(Constants.SP_NS, "MustSupportRefEncryptedkey");
     
     public static final QName REQUIRE_SIGNATURE_CONFIRMATION = new QName(Constants.SP_NS, "RequireSignatureConfirmation");
+ 
+    public static final QName MUST_SUPPORT_CLIENT_CHALLENGE = new QName(Constants.SP_NS, "MustSupportClientChanllenge");
+    
+    public static final QName MUST_SUPPORT_SERVER_CHALLENGE = new QName(Constants.SP_NS, "MustSupportServerChanllenge");
+    
+    public static final QName REQUIRE_CLIENT_ENTROPY = new QName(Constants.SP_NS, "RequireClientEntropy");
+    
+    public static final QName REQUIRE_SERVER_ENTROPY = new QName(Constants.SP_NS, "RequireServerEntropy");
+    
+    public static final QName MUST_SUPPORT_ISSUED_TOKENS = new QName(Constants.SP_NS, "MustSupportIssuedTokens");
+    
+    public static final QName ISSUER = new QName(Constants.SP_NS, "Issuer");
+    
+    public static final QName REQUIRE_DERIVED_KEYS = new QName(Constants.SP_NS, "RequireDerivedKeys");
+    
+    public static final QName REQUIRE_EXTERNAL_URI_REFERNCE = new QName(Constants.SP_NS, "RequireExternalUriReference");
+    
+    public static final QName SC10_SECURITY_CONTEXT_TOKEN = new QName(Constants.SP_NS, "SC10SecurityContextToken");
+    
+    public static final QName BOOTSTRAP_POLICY = new QName(Constants.SP_NS, "BootstrapPolicy");
     
 }
-
-

Added: webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/builders/SecureConversationTokenBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/builders/SecureConversationTokenBuilder.java?rev=438872&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/builders/SecureConversationTokenBuilder.java (added)
+++ webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/builders/SecureConversationTokenBuilder.java Thu Aug 31 04:42:07 2006
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+package org.apache.ws.secpolicy.builders;
+
+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.Policy;
+import org.apache.neethi.PolicyEngine;
+import org.apache.neethi.builders.AssertionBuilder;
+import org.apache.ws.secpolicy.Constants;
+import org.apache.ws.secpolicy.model.SecureConversationToken;
+
+public class SecureConversationTokenBuilder implements AssertionBuilder {
+
+    public Assertion build(OMElement element, AssertionBuilderFactory factory)
+            throws IllegalArgumentException {
+        SecureConversationToken conversationToken = new SecureConversationToken();
+        
+        OMAttribute attribute = element.getAttribute(Constants.INCLUDE_TOKEN);
+        if (attribute == null) {
+            throw new IllegalArgumentException(
+                    "SecurityContextToken doesn't contain any sp:IncludeToken attribute");
+        }
+        
+        String inclusionValue = attribute.getAttributeValue().trim();
+        
+        if (inclusionValue.endsWith(Constants.INCLUDE_NEVER)) {
+            conversationToken.setInclusion(Constants.INCLUDE_NEVER);
+
+        } else if (inclusionValue.endsWith(Constants.INCLUDE_ONCE)) {
+            conversationToken.setInclusion(Constants.INCLUDE_ONCE);
+
+        } else if (inclusionValue
+                .endsWith(Constants.INCLUDE_ALWAYS_TO_RECIPIENT)) {
+            conversationToken.setInclusion(Constants.INCLUDE_ALWAYS_TO_RECIPIENT);
+
+        } else if (inclusionValue.endsWith(Constants.INCLUDE_ALWAYS)) {
+            conversationToken.setInclusion(Constants.INCLUDE_ALWAYS);
+        }
+        
+        OMElement issuer = element.getFirstChildWithName(Constants.ISSUER);
+        if ( issuer != null) {
+            conversationToken.setIssuerEpr(issuer.getFirstElement());
+        }
+        
+        element = element.getFirstChildWithName(Constants.POLICY);
+        if (element != null) {
+            if (element.getFirstChildWithName(Constants.REQUIRE_DERIVED_KEYS) != null) {
+                conversationToken.setDerivedKeys(true);
+            }
+
+            if (element
+                    .getFirstChildWithName(Constants.REQUIRE_EXTERNAL_URI_REFERNCE) != null) {
+                conversationToken.setRequireExternalUriRef(true);
+            }
+
+            if (element
+                    .getFirstChildWithName(Constants.SC10_SECURITY_CONTEXT_TOKEN) != null) {
+                conversationToken.setSc10SecurityContextToken(true);
+            }
+            
+            OMElement bootstrapPolicyElement = element.getFirstChildWithName(Constants.BOOTSTRAP_POLICY);
+            if (bootstrapPolicyElement != null) {
+                Policy policy = PolicyEngine.getPolicy(bootstrapPolicyElement.getFirstElement());
+                conversationToken.setBootstrapPolicy(policy);
+            }
+        }
+        
+        return conversationToken;
+    }
+
+    public QName getKnownElement() {
+        return Constants.SECURE_CONVERSATION_TOKEN;
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/builders/SecurityContextTokenBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/builders/SecurityContextTokenBuilder.java?rev=438872&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/builders/SecurityContextTokenBuilder.java (added)
+++ webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/builders/SecurityContextTokenBuilder.java Thu Aug 31 04:42:07 2006
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+package org.apache.ws.secpolicy.builders;
+
+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.builders.AssertionBuilder;
+import org.apache.ws.secpolicy.Constants;
+import org.apache.ws.secpolicy.model.SecurityContextToken;
+
+public class SecurityContextTokenBuilder implements AssertionBuilder {
+
+    public Assertion build(OMElement element, AssertionBuilderFactory factory)
+            throws IllegalArgumentException {
+
+        SecurityContextToken contextToken = new SecurityContextToken();
+
+        OMAttribute attribute = element.getAttribute(Constants.INCLUDE_TOKEN);
+        if (attribute == null) {
+            throw new IllegalArgumentException(
+                    "SecurityContextToken doesn't contain any sp:IncludeToken attribute");
+        }
+        
+        String inclusionValue = attribute.getAttributeValue().trim();
+        
+        if (inclusionValue.endsWith(Constants.INCLUDE_NEVER)) {
+            contextToken.setInclusion(Constants.INCLUDE_NEVER);
+
+        } else if (inclusionValue.endsWith(Constants.INCLUDE_ONCE)) {
+            contextToken.setInclusion(Constants.INCLUDE_ONCE);
+
+        } else if (inclusionValue
+                .endsWith(Constants.INCLUDE_ALWAYS_TO_RECIPIENT)) {
+            contextToken.setInclusion(Constants.INCLUDE_ALWAYS_TO_RECIPIENT);
+
+        } else if (inclusionValue.endsWith(Constants.INCLUDE_ALWAYS)) {
+            contextToken.setInclusion(Constants.INCLUDE_ALWAYS);
+        }
+
+        element = element.getFirstChildWithName(Constants.POLICY);
+
+        if (element != null) {
+
+            if (element.getFirstChildWithName(Constants.REQUIRE_DERIVED_KEYS) != null) {
+                contextToken.setDerivedKeys(true);
+            }
+
+            if (element
+                    .getFirstChildWithName(Constants.REQUIRE_EXTERNAL_URI_REFERNCE) != null) {
+                contextToken.setRequireExternalUriRef(true);
+            }
+
+            if (element
+                    .getFirstChildWithName(Constants.SC10_SECURITY_CONTEXT_TOKEN) != null) {
+                contextToken.setSc10SecurityContextToken(true);
+            }
+        }
+
+        return contextToken;
+    }
+
+    public QName getKnownElement() {
+        return Constants.SECURE_CONVERSATION_TOKEN;
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/builders/Trust10Builder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/builders/Trust10Builder.java?rev=438872&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/builders/Trust10Builder.java (added)
+++ webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/builders/Trust10Builder.java Thu Aug 31 04:42:07 2006
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+package org.apache.ws.secpolicy.builders;
+
+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.builders.AssertionBuilder;
+import org.apache.ws.secpolicy.Constants;
+import org.apache.ws.secpolicy.model.Trust10;
+
+public class Trust10Builder implements AssertionBuilder {
+
+    public Assertion build(OMElement element, AssertionBuilderFactory factory)
+            throws IllegalArgumentException {
+
+        element = element.getFirstChildWithName(Constants.POLICY);
+
+        if (element == null) {
+            throw new IllegalArgumentException(
+                    "Trust10 assertion doesn't contain any Policy");
+        }
+
+        Trust10 trust10 = new Trust10();
+
+        if (element
+                .getFirstChildWithName(Constants.MUST_SUPPORT_CLIENT_CHALLENGE) != null) {
+            trust10.setMustSupportClientChallenge(true);
+        }
+
+        if (element
+                .getFirstChildWithName(Constants.MUST_SUPPORT_SERVER_CHALLENGE) != null) {
+            trust10.setMustSupportServerChallenge(true);
+        }
+
+        if (element.getFirstChildWithName(Constants.REQUIRE_CLIENT_ENTROPY) != null) {
+            trust10.setRequireClientEntropy(true);
+        }
+
+        if (element.getFirstChildWithName(Constants.REQUIRE_SERVER_ENTROPY) != null) {
+            trust10.setRequireServerEntropy(true);
+        }
+
+        if (element.getFirstChildWithName(Constants.MUST_SUPPORT_ISSUED_TOKENS) != null) {
+            trust10.setMustSupportIssuedTokens(true);
+        }
+
+        return trust10;
+    }
+
+    public QName getKnownElement() {
+        return Constants.TRUST_10;
+    }
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org