You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ru...@apache.org on 2006/03/26 22:00:46 UTC

svn commit: r388950 - in /webservices/axis2/trunk/java/modules: doom/src/org/apache/axis2/soap/impl/dom/ saaj/test/org/apache/axis2/saaj/ security/src/org/apache/axis2/security/trust/ security/src/org/apache/axis2/security/trust/impl/

Author: ruchithf
Date: Sun Mar 26 12:00:44 2006
New Revision: 388950

URL: http://svn.apache.org/viewcvs?rev=388950&view=rev
Log:
- Fixed AXIS2-517
- Updated the SCTIssuer to store the created SCT using the SimpleTokenStore and use the service context to hold the token store


Added:
    webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPNamespaceTest.java
Modified:
    webservices/axis2/trunk/java/modules/doom/src/org/apache/axis2/soap/impl/dom/SOAPEnvelopeImpl.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/TokenStorage.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/impl/SCTIssuer.java

Modified: webservices/axis2/trunk/java/modules/doom/src/org/apache/axis2/soap/impl/dom/SOAPEnvelopeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/doom/src/org/apache/axis2/soap/impl/dom/SOAPEnvelopeImpl.java?rev=388950&r1=388949&r2=388950&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/doom/src/org/apache/axis2/soap/impl/dom/SOAPEnvelopeImpl.java (original)
+++ webservices/axis2/trunk/java/modules/doom/src/org/apache/axis2/soap/impl/dom/SOAPEnvelopeImpl.java Sun Mar 26 12:00:44 2006
@@ -23,7 +23,6 @@
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.OMOutputImpl;
-import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axiom.soap.SOAPBody;
 import org.apache.axiom.soap.SOAPConstants;
@@ -32,9 +31,7 @@
 import org.apache.axiom.soap.SOAPHeader;
 import org.apache.axiom.soap.SOAPProcessingException;
 import org.apache.axis2.om.impl.dom.DocumentImpl;
-import org.apache.axis2.om.impl.dom.NamespaceImpl;
 import org.apache.axis2.soap.impl.dom.factory.DOMSOAPFactory;
-import org.apache.axis2.soap.impl.dom.soap11.SOAP11Factory;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
@@ -54,9 +51,7 @@
 		super(
 				doc,
 				SOAPConstants.SOAPENVELOPE_LOCAL_NAME,
-				(NamespaceImpl)factory
-						.createOMNamespace((factory instanceof SOAP11Factory) ? SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI
-								: SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI, SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX),
+                null,
 				builder, factory);
 	}
 	/**

Added: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPNamespaceTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPNamespaceTest.java?rev=388950&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPNamespaceTest.java (added)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPNamespaceTest.java Sun Mar 26 12:00:44 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.saaj;
+
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPMessage;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+import junit.framework.TestCase;
+
+public class SOAPNamespaceTest extends TestCase {
+
+    public SOAPNamespaceTest(String arg0) {
+        super(arg0);
+    }
+
+    
+    public void test() {
+        try
+        {
+            String xml = "<?xml version='1.0' ?><env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\"><env:Body/></env:Envelope>";
+            
+            SOAPMessage msg = MessageFactory.newInstance().createMessage(null, new ByteArrayInputStream(xml.getBytes()));
+            msg.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true");
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            msg.writeTo(baos);
+            String producedMag = new String(baos.toByteArray());
+            String [] splitParts = producedMag.split("http://schemas.xmlsoap.org/soap/envelope");
+            assertEquals("Extra namespace declaration" ,2 ,splitParts.length);
+        }
+        catch (Exception e)
+        {
+            fail(e.getMessage());
+        }
+    }
+    
+}

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/TokenStorage.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/TokenStorage.java?rev=388950&r1=388949&r2=388950&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/TokenStorage.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/TokenStorage.java Sun Mar 26 12:00:44 2006
@@ -24,6 +24,8 @@
  */
 public interface TokenStorage {
     
+    public final static String TOKEN_STORAGE_KEY = "tokenStorage";
+    
     /**
      * Add the given token to the list.
      * @param token The token to be added

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/impl/SCTIssuer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/impl/SCTIssuer.java?rev=388950&r1=388949&r2=388950&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/impl/SCTIssuer.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/impl/SCTIssuer.java Sun Mar 26 12:00:44 2006
@@ -22,7 +22,10 @@
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.om.DOOMAbstractFactory;
 import org.apache.axis2.security.trust.Constants;
+import org.apache.axis2.security.trust.SimpleTokenStore;
+import org.apache.axis2.security.trust.Token;
 import org.apache.axis2.security.trust.TokenIssuer;
+import org.apache.axis2.security.trust.TokenStorage;
 import org.apache.axis2.security.trust.TrustException;
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSSecurityEngineResult;
@@ -149,7 +152,8 @@
         }
         
         SecurityContextToken sct = new SecurityContextToken(doc);
-        sct.setID("sctId-" + sct.getElement().hashCode());
+        String sctId = "sctId-" + sct.getElement().hashCode();
+        sct.setID(sctId);
         
         OMElement rstrElem = env.getOMFactory().createOMElement(
                 new QName(Constants.WST_NS, "RequestSecurityTokenResponse",
@@ -175,6 +179,10 @@
         }
         
         reqProofTok.addChild((OMElement)encryptedKeyElem);
+    
+        //Store the tokens
+        Token sctToken = new Token(sctId, (OMElement)sct.getElement());
+        this.getTokenStore(msgCtx).add(sctToken);
         
         return env;
     }
@@ -206,6 +214,25 @@
      */
     public void setConfigurationElement(OMElement configElement) {
         this.configElement = configElement;
+    }
+    
+    /**
+     * Returns the token store.
+     * If the token store is aleady available in the service context then
+     * fetch it and return it. If not create a new one, hook it up in the 
+     * service context and return it
+     * @param msgCtx
+     * @return
+     */
+    private TokenStorage getTokenStore(MessageContext msgCtx) {
+        TokenStorage storage = (TokenStorage) msgCtx.getServiceContext()
+                .getProperty(TokenStorage.TOKEN_STORAGE_KEY);
+        if (storage == null) {
+            storage = new SimpleTokenStore();
+            msgCtx.getServiceContext().setProperty(
+                    TokenStorage.TOKEN_STORAGE_KEY, storage);
+        }
+        return storage;
     }
     
 }