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 ru...@apache.org on 2006/09/08 04:20:33 UTC

svn commit: r441343 - in /webservices/axis2/trunk/java/modules/security/src/org/apache/rampart: MessageBuilder.java RampartMessageData.java errors.properties policy/RampartPolicyBuilder.java policy/model/RampartConfig.java util/RampartUtil.java

Author: ruchithf
Date: Thu Sep  7 19:20:32 2006
New Revision: 441343

URL: http://svn.apache.org/viewvc?view=rev&rev=441343
Log:
Completed setting up the tokens for SymmentricBinding in MessageBuilder.


Modified:
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/MessageBuilder.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartMessageData.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/errors.properties
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/policy/RampartPolicyBuilder.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/policy/model/RampartConfig.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/util/RampartUtil.java

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/MessageBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/MessageBuilder.java?view=diff&rev=441343&r1=441342&r2=441343
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/MessageBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/MessageBuilder.java Thu Sep  7 19:20:32 2006
@@ -19,9 +19,11 @@
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.impl.dom.jaxp.DocumentBuilderFactoryImpl;
 import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.Parameter;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyEngine;
 import org.apache.rahas.RahasConstants;
 import org.apache.rahas.TrustException;
 import org.apache.rahas.TrustUtil;
@@ -38,31 +40,24 @@
 import org.apache.ws.security.SOAPConstants;
 import org.apache.ws.security.WSSecurityException;
 import org.apache.ws.security.components.crypto.Crypto;
+import org.apache.ws.security.conversation.ConversationConstants;
+import org.apache.ws.security.conversation.ConversationException;
 import org.apache.ws.security.message.WSSecHeader;
 import org.apache.ws.security.util.WSSecurityUtil;
 import org.w3c.dom.Document;
 
 import javax.security.auth.callback.CallbackHandler;
 
-import java.util.Iterator;
+import java.io.ByteArrayInputStream;
+import java.util.List;
 
 public class MessageBuilder {
     
     private static Log log = LogFactory.getLog(MessageBuilder.class);
     
-    public void build(MessageContext msgCtx) throws WSSPolicyException, RampartException, WSSecurityException {
+    public void build(MessageContext msgCtx) throws WSSPolicyException,
+            RampartException, WSSecurityException {
         
-        //TODO: Get hold of the policy from the message context
-        Policy policy = new Policy();
-        Iterator it = (Iterator)policy.getAlternatives().next();
-        
-        RampartPolicyData policyData = RampartPolicyBuilder.build(it);
-        
-        processEnvelope(msgCtx, policyData);
-    }
-    
-    private void processEnvelope(MessageContext msgCtx, RampartPolicyData rpd) throws RampartException, WSSecurityException {
-        log.info("Before create Message assym....");
 
         DocumentBuilderFactoryImpl.setDOOMRequired(true);
         
@@ -73,164 +68,248 @@
         Document doc = Axis2Util.getDocumentFromSOAPEnvelope(msgCtx.getEnvelope(), false);
         SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc
                 .getDocumentElement());
-
+        
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
         
         RampartMessageData rmd = new RampartMessageData(msgCtx, doc);
-        rmd.setPolicyData(rpd);
+        
+        Policy policy = null;
+        /*
+         * When creating the RampartMessageData instance we 
+         * extract the service policy is set in the msgCtx.
+         * If it is missing then try to obtain from the configuration files.
+         */
+        if(rmd.getServicePolicy() != null) {
+            if(msgCtx.isServerSide()) {
+                String policyXml = msgCtx.getEffectivePolicy().toString();
+                policy = PolicyEngine.getPolicy(new ByteArrayInputStream(policyXml.getBytes()));
+            } else {
+                Parameter param = msgCtx.getParameter(RampartMessageData.KEY_RAMPART_POLICY);
+                OMElement policyElem = param.getParameterElement().getFirstElement();
+                policy = PolicyEngine.getPolicy(policyElem);
+            }
+        }
+        
+        
+        List it = (List)policy.getAlternatives().next();
+        
+        RampartPolicyData policyData = RampartPolicyBuilder.build(it);
+
+     
+        rmd.setPolicyData(policyData);
         rmd.setSecHeader(secHeader);
         
+        processEnvelope(msgCtx, rmd);
+    }
+    
+    private void processEnvelope(MessageContext msgCtx, RampartMessageData rmd)
+            throws RampartException, WSSecurityException {
+        log.info("Before create Message assym....");
+
+        RampartPolicyData rpd = rmd.getPolicyData();
+
         if(rpd.isIncludeTimestamp()) {
+            
+            log.debug("Adding a timestamp");
+            
             TimestampBuilder tsBuilder = new TimestampBuilder();
             tsBuilder.build(rmd);
         }
         
         
         if(rpd.isSymmetricBinding()) {
+            log.debug("Procesing symmentric binding: " +
+                    "Setting up encryption token and signature token");
             //Setting up encryption token and signature token
             
             Token sigTok = rpd.getSignatureToken();
             Token encrTok = rpd.getEncryptionToken();
-            
             if(sigTok instanceof IssuedToken) {
+                
+                log.debug("SignatureToken is an IssuedToken");
+                
                 if(rmd.getIssuedSignatureTokenId() == null) {
+                    log.debug("No Issuedtoken found, requesting a new token");
+                    
                     IssuedToken issuedToken = (IssuedToken)sigTok;
                     
                     try {
-                        STSClient client = new STSClient(rmd.getMsgContext()
-                                .getConfigurationContext());
-
-                        // Set request action
-                        client.setAction(TrustUtil.getActionValue(rmd
+                        
+                        String action = TrustUtil.getActionValue(rmd
                                 .getWstVersion(),
-                                RahasConstants.RST_ACTON_ISSUE));
+                                RahasConstants.RST_ACTON_ISSUE);
                         
-                        client.setRstTemplate(issuedToken.getRstTemplate());
-
-                        // Set crypto information
-                        Crypto crypto = RampartUtil.getSignatureCrypto(rmd
-                                .getPolicyData().getRampartConfig());
-                        CallbackHandler cbh = RampartUtil.getPasswordCB(rmd);
-                        client.setCryptoInfo(crypto, cbh);
-
-                        // Get service policy
-                        Policy servicePolicy = (Policy) msgCtx
-                                .getProperty(RampartMessageData.KEY_SERVICE_POLICY);
-
-                        // Get STS policy
-                        Policy stsPolicy = (Policy) msgCtx
-                                .getProperty(RampartMessageData.KEY_ISSUER_POLICY);
-
-                        // Get service epr
-                        String servceEprAddress = rmd.getMsgContext()
-                                .getOptions().getTo().getAddress();
                         // Get sts epr
                         String issuerEprAddress = RampartUtil
                                 .processIssuerAddress(issuedToken
                                         .getIssuerEpr());
-
-                        // Request type
-                        String reqType = TrustUtil.getWSTNamespace(rmd
-                                .getWstVersion())
-                                + RahasConstants.REQ_TYPE_ISSUE;
-                        
-                        //Make the request
-                        org.apache.rahas.Token rst = 
-                            client.requestSecurityToken(servicePolicy, 
-                                                        issuerEprAddress,
-                                                        stsPolicy, 
-                                                        reqType, 
-                                                        servceEprAddress);
                         
-                        //Set the token ID
-                        rmd.setIssuedSignatureTokenId(rst.getId());
+                        OMElement rstTemplate = issuedToken.getRstTemplate();
+                        
+                        String id = this.getToken(rmd, rstTemplate,
+                                issuerEprAddress, action);
                         
-                        //Add the token to token storage
-                        rmd.getTokenStorage().add(rst);
+                        log.debug("Issued token obtained: id=" + id);
                         
+                        rmd.setIssuedSignatureTokenId(id);
                     } catch (TrustException e) {
                         throw new RampartException(e.getMessage(), e);
                     }
                     
                 }
+                
             } else if(sigTok instanceof SecureConversationToken) {
+                
+                log.debug("SignatureToken is a SecureConversationToken");
+                
                 if(rmd.getSecConvTokenId() == null) {
-
+                
+                    log.debug("No SecureConversationToken found, " +
+                            "requesting a new token");
+                    
                     SecureConversationToken secConvTok = 
                                         (SecureConversationToken) sigTok;
                     
-                    
                     try {
-                        STSClient client = new STSClient(rmd.getMsgContext()
-                                .getConfigurationContext());
-
-                        // Set request action
-                        client.setAction(TrustUtil.getActionValue(
+                        
+                        String action = TrustUtil.getActionValue(
                                 rmd.getWstVersion(),
-                                RahasConstants.RST_ACTON_ISSUE));
+                                RahasConstants.RST_ACTON_SCT);
                         
+                        // Get sts epr
+                        String issuerEprAddress = RampartUtil
+                                .processIssuerAddress(secConvTok.getIssuerEpr());
+
                         //Find SC version
-                        int conversationVersion = 1;
+                        int conversationVersion = rmd.getSecConvVersion();
+                        
+                        OMElement rstTemplate = RampartUtil.createRSTTempalteForSCT(
+                                conversationVersion, 
+                                rmd.getWstVersion());
                         
-                        client.setRstTemplate(RampartUtil.createRSTTempalteForSCT(conversationVersion, rmd.getWstVersion()));
+                        String id = this.getToken(rmd, rstTemplate,
+                                issuerEprAddress, action);
+                        
+                        log.debug("SecureConversationToken obtained: id=" + id);
+                        
+                        rmd.setSecConvTokenId(id);
 
-                        // Set crypto information
-                        Crypto crypto = RampartUtil.getSignatureCrypto(rmd
-                                .getPolicyData().getRampartConfig());
-                        CallbackHandler cbh = RampartUtil.getPasswordCB(rmd);
-                        client.setCryptoInfo(crypto, cbh);
-
-                        // Get service policy
-                        Policy servicePolicy = (Policy) msgCtx
-                                .getProperty(RampartMessageData.KEY_SERVICE_POLICY);
-
-                        // Get STS policy
-                        Policy stsPolicy = (Policy) msgCtx
-                                .getProperty(RampartMessageData.KEY_ISSUER_POLICY);
-
-                        // Get service epr
-                        String servceEprAddress = rmd.getMsgContext()
-                                .getOptions().getTo().getAddress();
+                        
+                    } catch (TrustException e) {
+                        throw new RampartException(e.getMessage(), e);
+                    }
+                }
+            }
+            
+            //If it was the ProtectionToken assertion then sigTok is the
+            //same as encrTok
+            if(sigTok.equals(encrTok) && sigTok instanceof IssuedToken) {
+                
+                log.debug("Symmetric binding uses a ProtectionToken, both" +
+                        " SignatureToken and EncryptionToken are the same");
+                
+                rmd.setIssuedEncryptionTokenId(rmd.getIssuedEncryptionTokenId());
+            } else {
+                //Now we'll have to obtain the encryption token as well :-)
+                //ASSUMPTION: SecureConversationToken is used as a 
+                //ProtectionToken therfore we only have to process a issued 
+                //token here
+                
+                log.debug("Obtaining the Encryption Token");
+                if(rmd.getIssuedEncryptionTokenId() != null) {
+                    
+                    log.debug("EncrytionToken not alredy set");
+
+                    IssuedToken issuedToken = (IssuedToken)encrTok;
+                    
+                    try {
+                        
+                        String action = TrustUtil.getActionValue(rmd
+                                .getWstVersion(),
+                                RahasConstants.RST_ACTON_ISSUE);
                         
                         // Get sts epr
                         String issuerEprAddress = RampartUtil
-                                .processIssuerAddress(secConvTok.getIssuerEpr());
-
-                        // Request type
-                        String reqType = TrustUtil.getWSTNamespace(rmd
-                                .getWstVersion())
-                                + RahasConstants.REQ_TYPE_ISSUE;
-                        
-                        //Make the request
-                        org.apache.rahas.Token rst = 
-                            client.requestSecurityToken(servicePolicy, 
-                                                        issuerEprAddress,
-                                                        stsPolicy, 
-                                                        reqType, 
-                                                        servceEprAddress);
+                                .processIssuerAddress(issuedToken
+                                        .getIssuerEpr());
                         
-                        //Set the token ID
-                        rmd.setIssuedSignatureTokenId(rst.getId());
+                        OMElement rstTemplate = issuedToken.getRstTemplate();
                         
-                        //Add the token to token storage
-                        rmd.getTokenStorage().add(rst);
+                        String id = this.getToken(rmd, rstTemplate,
+                                issuerEprAddress, action);
                         
+                        log.debug("Issued token obtained: id=" + id);
+                        
+                        rmd.setIssuedEncryptionTokenId(id);
                     } catch (TrustException e) {
                         throw new RampartException(e.getMessage(), e);
                     }
 
+                    
                 }
+                
             }
-        } else if(!rpd.isSymmetricBinding() && !rpd.isTransportBinding()) {
-            //TODO Setup InitiatorToken and receipientToken
             
-        } else {
+        } else if(rpd.isTransportBinding()) {
             //TODO: Handle transport binding
             
+        } else {
+            //TODO Setup InitiatorToken and receipientToken
+            
         }
     }
+    
+    
+    private String getToken(RampartMessageData rmd, OMElement rstTemplate,
+            String issuerEpr, String action) throws RampartException {
 
-
+        try {
+            
+            STSClient client = new STSClient(rmd.getMsgContext()
+                    .getConfigurationContext());
+            // Set request action
+            client.setAction(action);
+            
+            client.setRstTemplate(rstTemplate);
+    
+            // Set crypto information
+            Crypto crypto = RampartUtil.getSignatureCrypto(rmd
+                    .getPolicyData().getRampartConfig());
+            CallbackHandler cbh = RampartUtil.getPasswordCB(rmd);
+            client.setCryptoInfo(crypto, cbh);
+    
+            // Get service policy
+            Policy servicePolicy = rmd.getServicePolicy();
+    
+            // Get STS policy
+            Policy stsPolicy = rmd.getPolicyData()
+                    .getRampartConfig().getTokenIssuerPolicy();
+    
+            // Get service epr
+            String servceEprAddress = rmd.getMsgContext()
+                    .getOptions().getTo().getAddress();
+    
+            // Request type
+            String reqType = TrustUtil.getWSTNamespace(rmd
+                    .getWstVersion())
+                    + RahasConstants.REQ_TYPE_ISSUE;
+            
+            //Make the request
+            org.apache.rahas.Token rst = 
+                client.requestSecurityToken(servicePolicy, 
+                                            issuerEpr,
+                                            stsPolicy, 
+                                            reqType, 
+                                            servceEprAddress);
+            
+            //Add the token to token storage
+            rmd.getTokenStorage().add(rst);
+            
+            return rst.getId();
+        } catch (TrustException e) {
+            throw new RampartException(e.getMessage(), e);
+        }
+    }
     
 }

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartMessageData.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartMessageData.java?view=diff&rev=441343&r1=441342&r2=441343
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartMessageData.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartMessageData.java Thu Sep  7 19:20:32 2006
@@ -17,8 +17,11 @@
 package org.apache.rampart;
 
 import org.apache.axis2.context.MessageContext;
+import org.apache.neethi.Policy;
 import org.apache.rahas.RahasConstants;
 import org.apache.rahas.TokenStorage;
+import org.apache.rahas.TrustException;
+import org.apache.rahas.TrustUtil;
 import org.apache.rampart.policy.RampartPolicyData;
 import org.apache.ws.security.WSSConfig;
 import org.apache.ws.security.conversation.ConversationConstants;
@@ -30,19 +33,24 @@
 public class RampartMessageData {
     
     /**
+     * Axis2 parameter name to be used in the client's axis2 xml
+     */
+    public final static String KEY_RAMPART_POLICY = "rampartPolicy";
+    
+    /**
      * Key to hold the address of the issuer in the msg ctx.
      */
     public final static String KEY_ISSUER_ADDRESS = "issuerAddress";
     
     /**
-     * Key to hold the issuer policy
+     * Key to hold the WS-Trust version
      */
-    public final static String KEY_ISSUER_POLICY = "issuerPolicy";
+    public final static String KEY_WST_VERSION = "wstVersion";
 
     /**
-     * Key to hold the service policy
+     * Key to hold the WS-SecConv version
      */
-    public static final String KEY_SERVICE_POLICY = "servicePolicy";
+    public final static String KEY_WSSC_VERSION = "wscVersion";
 
     private MessageContext msgContext = null;
 
@@ -87,10 +95,36 @@
     private String secConvTokenId;
     
     
-    
-    public RampartMessageData(MessageContext msgCtx, Document doc) {
+    /**
+     * The service policy extracted from the message context.
+     * If policy is specified in the RampartConfig <b>this</b> will take precedence
+     */
+    private Policy servicePolicy;
+
+
+    public RampartMessageData(MessageContext msgCtx, Document doc) throws RampartException {
         this.msgContext = msgCtx;
         this.document = doc;
+        
+        try {
+            //Extract known properties from the msgCtx
+            
+            if(msgCtx.getProperty(KEY_WST_VERSION) != null) {
+                this.wstVersion = TrustUtil.getWSTVersion((String)msgCtx.getProperty(KEY_WST_VERSION));
+            }
+            
+            if(msgCtx.getProperty(KEY_WSSC_VERSION) != null) {
+                this.secConvVersion = TrustUtil.getWSTVersion((String)msgCtx.getProperty(KEY_WSSC_VERSION));
+            }
+            
+            if(msgCtx.getProperty(KEY_RAMPART_POLICY) != null) {
+                this.servicePolicy = (Policy)msgCtx.getProperty(KEY_RAMPART_POLICY);
+            }
+            
+        } catch (TrustException e) {
+            throw new RampartException("errorInExtractingMsgProps", e);
+        }
+        
     }
     
     /**
@@ -298,6 +332,13 @@
      */
     public int getSecConvVersion() {
         return secConvVersion;
+    }
+
+    /**
+     * @return Returns the servicePolicy.
+     */
+    public Policy getServicePolicy() {
+        return servicePolicy;
     }
 
 }

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/errors.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/errors.properties?view=diff&rev=441343&r1=441342&r2=441343
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/errors.properties (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/errors.properties Thu Sep  7 19:20:32 2006
@@ -11,4 +11,5 @@
 missingSignatureCrypto=Signature crypto information not available
 missingEncryptionCrypto=Encryption crypto information not available
 missingCallbackHandler=Password callback handler cannot be located
-errorInObtainingSct=Error in obtaining SCT from \"{0}\"
\ No newline at end of file
+errorInObtainingSct=Error in obtaining SCT from \"{0}\"
+errorInExtractingMsgProps = Error in extracting message properties
\ No newline at end of file

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/policy/RampartPolicyBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/policy/RampartPolicyBuilder.java?view=diff&rev=441343&r1=441342&r2=441343
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/policy/RampartPolicyBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/policy/RampartPolicyBuilder.java Thu Sep  7 19:20:32 2006
@@ -38,9 +38,10 @@
 import org.apache.ws.secpolicy.model.Wss11;
 
 import java.util.Iterator;
+import java.util.List;
 
 public class RampartPolicyBuilder {
-
+    
     /**
      * Compile the parsed security data into one Policy data block.
      * 
@@ -59,11 +60,13 @@
      * @return The compile Poilcy data block.
      * @throws WSSPolicyException
      */
-    public static RampartPolicyData build(Iterator topLevelAssertions)
+    public static RampartPolicyData build(List topLevelAssertions)
             throws WSSPolicyException {
+        
         RampartPolicyData rpd = new RampartPolicyData();
-        while (topLevelAssertions.hasNext()) {
-            Assertion assertion = (Assertion) topLevelAssertions.next();
+        
+        for (Iterator iter = topLevelAssertions.iterator(); iter.hasNext();) {
+            Assertion assertion = (Assertion) iter.next();
             if (assertion instanceof Binding) {
                 if (assertion instanceof SymmetricBinding) {
                     processSymmetricPolicyBinding((SymmetricBinding) assertion, rpd);
@@ -97,6 +100,7 @@
                         + assertion.getClass().getName());
             }
         }
+        
         return rpd;
     }
 

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/policy/model/RampartConfig.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/policy/model/RampartConfig.java?view=diff&rev=441343&r1=441342&r2=441343
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/policy/model/RampartConfig.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/policy/model/RampartConfig.java Thu Sep  7 19:20:32 2006
@@ -36,21 +36,22 @@
         <ramp:timestampTTL>300</ramp:timestampTTL>
         <ramp:tokenStoreClass>org.apache.rahas.StorageImpl</ramp:tokenStoreClass>
         
-        <ramp:signatureCryto>
+        <ramp:signatureCrypto>
             <ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin">
                 <ramp:property name="keystoreType">JKS</ramp:property>
                 <ramp:property name="keystoreFile">/path/to/file.jks</ramp:property>
                 <ramp:property name="keystorePassword">password</ramp:property>
             </ramp:crypto>
-        </ramp:signatureCryto>
-    </ramp:RampartConfig>
-    
-    <ramp:tokenIssuerPolicy>
-        <wsp:Policy>
+        </ramp:signatureCrypto>
+        
+        <ramp:tokenIssuerPolicy>
+            <wsp:Policy>
             ....
             ....
-        </wsp:Policy>
-    </ramp:tokenIssuerPolicy>
+            </wsp:Policy>
+        </ramp:tokenIssuerPolicy>
+    </ramp:RampartConfig>
+
 </pre>
  * 
  */
@@ -206,5 +207,6 @@
     public void setTokenIssuerPolicy(Policy tokenIssuerPolicy) {
         this.tokenIssuerPolicy = tokenIssuerPolicy;
     }
+
 
 }

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/util/RampartUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/util/RampartUtil.java?view=diff&rev=441343&r1=441342&r2=441343
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/util/RampartUtil.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/util/RampartUtil.java Thu Sep  7 19:20:32 2006
@@ -22,7 +22,6 @@
 import org.apache.axiom.om.OMNamespace;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.rahas.RahasConstants;
 import org.apache.rahas.TrustException;
 import org.apache.rahas.TrustUtil;
 import org.apache.rampart.RampartException;
@@ -35,6 +34,8 @@
 import org.apache.ws.security.WSPasswordCallback;
 import org.apache.ws.security.components.crypto.Crypto;
 import org.apache.ws.security.components.crypto.CryptoFactory;
+import org.apache.ws.security.conversation.ConversationConstants;
+import org.apache.ws.security.conversation.ConversationException;
 import org.apache.ws.security.handler.WSHandlerConstants;
 import org.apache.ws.security.util.Loader;
 
@@ -258,15 +259,16 @@
             //Create TokenType element and set the value
             OMElement tokenTypeElem = TrustUtil.createTokenTypeElement(
                     wstVersion, rstTempl);
-            tokenTypeElem.setText(getConversationNs(conversationVersion) + "/sct");
+            String tokenType = ConversationConstants.getWSCNs(conversationVersion) + ConversationConstants.TOKEN_TYPE_SECURITY_CONTEXT_TOKEN;
+            tokenTypeElem.setText(tokenType);
             
             return rstTempl;
         } catch (TrustException e) {
             throw new RampartException(e.getMessage(), e);
+        } catch (ConversationException e) {
+            throw new RampartException(e.getMessage(), e);
         }
     }
     
-    public static String getConversationNs(int version) {
-        return null;
-    }
+
 }



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