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/24 10:45:21 UTC

svn commit: r449378 - in /webservices/axis2/trunk/java/modules: integration/test-resources/security/sc/ rahas/src/org/apache/rahas/client/ security/src/org/apache/rampart/ security/src/org/apache/rampart/builder/ security/src/org/apache/rampart/util/

Author: ruchithf
Date: Sun Sep 24 01:45:20 2006
New Revision: 449378

URL: http://svn.apache.org/viewvc?view=rev&rev=449378
Log:
Updated the STS key used by the sec conv tests
Some refactoring in Rampart to assist Sandesha integration


Modified:
    webservices/axis2/trunk/java/modules/integration/test-resources/security/sc/sec.jks
    webservices/axis2/trunk/java/modules/integration/test-resources/security/sc/sts.jks
    webservices/axis2/trunk/java/modules/rahas/src/org/apache/rahas/client/STSClient.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartMessageData.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/SymmetricBindingBuilder.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/util/RampartUtil.java

Modified: webservices/axis2/trunk/java/modules/integration/test-resources/security/sc/sec.jks
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test-resources/security/sc/sec.jks?view=diff&rev=449378&r1=449377&r2=449378
==============================================================================
Binary files - no diff available.

Modified: webservices/axis2/trunk/java/modules/integration/test-resources/security/sc/sts.jks
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test-resources/security/sc/sts.jks?view=diff&rev=449378&r1=449377&r2=449378
==============================================================================
Binary files - no diff available.

Modified: webservices/axis2/trunk/java/modules/rahas/src/org/apache/rahas/client/STSClient.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rahas/src/org/apache/rahas/client/STSClient.java?view=diff&rev=449378&r1=449377&r2=449378
==============================================================================
--- webservices/axis2/trunk/java/modules/rahas/src/org/apache/rahas/client/STSClient.java (original)
+++ webservices/axis2/trunk/java/modules/rahas/src/org/apache/rahas/client/STSClient.java Sun Sep 24 01:45:20 2006
@@ -103,7 +103,7 @@
 
     public Token requestSecurityToken(Policy servicePolicy,
                                       String issuerAddress,
-                                      Policy IssuerPolicy,
+                                      Policy issuerPolicy,
                                       String appliesTo) throws TrustException {
         try {
             QName rstQn = new QName("requestSecurityToken");
@@ -115,7 +115,7 @@
             //such as rampart
 
             //Process the STS and service policy policy
-            this.processPolicy(IssuerPolicy, servicePolicy);
+            this.processPolicy(issuerPolicy, servicePolicy);
             OMElement response = client.sendReceive(rstQn,
                                                     createIssueRequest(requestType, appliesTo));
 

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=449378&r1=449377&r2=449378
==============================================================================
--- 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 Sun Sep 24 01:45:20 2006
@@ -34,6 +34,7 @@
 import org.apache.rampart.policy.RampartPolicyBuilder;
 import org.apache.rampart.policy.RampartPolicyData;
 import org.apache.rampart.util.Axis2Util;
+import org.apache.rampart.util.RampartUtil;
 import org.apache.ws.secpolicy.WSSPolicyException;
 import org.apache.ws.security.WSSConfig;
 import org.apache.ws.security.WSSecurityException;
@@ -360,47 +361,21 @@
      * @return Returns the secConvTokenId.
      */
     public String getSecConvTokenId() {
-        return (String)this.getContextMap().get(this.getContextIdentifierKey());
+        String contextIdentifierKey = RampartUtil.getContextIdentifierKey(this.msgContext);
+        return (String) RampartUtil.getContextMap(this.msgContext).get(contextIdentifierKey);
     }
 
     /**
      * @param secConvTokenId The secConvTokenId to set.
      */
     public void setSecConvTokenId(String secConvTokenId) {
-        this.getContextMap().put(this.getContextIdentifierKey(), secConvTokenId);
+        String contextIdentifierKey = RampartUtil.getContextIdentifierKey(this.msgContext);
+        RampartUtil.getContextMap(this.msgContext).put(
+                                                    contextIdentifierKey,
+                                                    secConvTokenId);
     }
 
-    /**
-     * Returns the map of security context token identifiers
-     * @return
-     */
-    private Hashtable getContextMap() {
-        //Fist check whether its there
-        Object map = this.msgContext.getConfigurationContext().getProperty(
-                KEY_CONTEXT_MAP);
-        
-        if(map == null) {
-            //If not create a new one
-            map = new Hashtable();
-            //Set the map globally
-            this.msgContext.getConfigurationContext().setProperty(
-                    KEY_CONTEXT_MAP, map);
-        }
-        
-        return (Hashtable)map;
-    }
-    
-    /**
-     * Creates the unique (reproducible) id for to hold the context identifier
-     * of the message exchange.
-     * @return
-     */
-    private String getContextIdentifierKey() {
-        String service = this.msgContext.getTo().getAddress();
-        String action = this.msgContext.getOptions().getAction();
-        
-        return service + ":" + action;
-    }
+
     
     /**
      * @return Returns the tokenStorage.

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/SymmetricBindingBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/SymmetricBindingBuilder.java?view=diff&rev=449378&r1=449377&r2=449378
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/SymmetricBindingBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/SymmetricBindingBuilder.java Sun Sep 24 01:45:20 2006
@@ -137,6 +137,8 @@
                     dkEncr.setExternalKey(tok.getSecret(), (Element) doc
                             .importNode((Element) tok.getUnattachedReference(),
                                     true));
+                } else {
+                    dkEncr.setExternalKey(tok.getSecret(), tok.getId());
                 }
                 try {
                     dkEncr.prepare(doc);
@@ -391,6 +393,8 @@
                     dkEncr.setExternalKey(encrTok.getSecret(), (Element) doc
                             .importNode((Element) encrTok.getUnattachedReference(),
                                     true));
+                } else {
+                    dkEncr.setExternalKey(encrTok.getSecret(), encrTok.getId());
                 }
                 
                 Element encrDKTokenElem = null;

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=449378&r1=449377&r2=449378
==============================================================================
--- 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 Sun Sep 24 01:45:20 2006
@@ -22,6 +22,7 @@
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.Parameter;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -57,6 +58,7 @@
 import javax.security.auth.callback.CallbackHandler;
 import javax.xml.namespace.QName;
 import java.security.NoSuchAlgorithmException;
+import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Properties;
 import java.util.Vector;
@@ -68,8 +70,21 @@
 
     public static CallbackHandler getPasswordCB(RampartMessageData rmd) throws RampartException {
 
-        ClassLoader classLoader = rmd.getMsgContext().getAxisService().getClassLoader();
-        String cbHandlerClass = rmd.getPolicyData().getRampartConfig().getPwCbClass();
+        MessageContext msgContext = rmd.getMsgContext();
+        RampartPolicyData rpd = rmd.getPolicyData();
+        
+        return getPasswordCB(msgContext, rpd);
+    }
+
+    /**
+     * @param msgContext
+     * @param rpd
+     * @return
+     * @throws RampartException
+     */
+    public static CallbackHandler getPasswordCB(MessageContext msgContext, RampartPolicyData rpd) throws RampartException {
+        ClassLoader classLoader = msgContext.getAxisService().getClassLoader();
+        String cbHandlerClass = rpd.getRampartConfig().getPwCbClass();
         
         log.debug("loading class : " + cbHandlerClass);
         
@@ -89,10 +104,10 @@
                         new String[]{cbHandlerClass}, e);
             }
         } else {
-            cbHandler = (CallbackHandler) rmd.getMsgContext().getProperty(
+            cbHandler = (CallbackHandler) msgContext.getProperty(
                     WSHandlerConstants.PW_CALLBACK_REF);
             if(cbHandler == null) {
-                Parameter param = rmd.getMsgContext().getParameter(
+                Parameter param = msgContext.getParameter(
                         WSHandlerConstants.PW_CALLBACK_REF);
                 cbHandler = (CallbackHandler)param.getValue();
             }
@@ -548,4 +563,38 @@
         }
         return keyGen;
     }
+    
+    /**
+     * Creates the unique (reproducible) id for to hold the context identifier
+     * of the message exchange.
+     * @return
+     */
+    public static String getContextIdentifierKey(MessageContext msgContext) {
+        String service = msgContext.getTo().getAddress();
+        String action = msgContext.getOptions().getAction();
+        
+        return service + ":" + action;
+    }
+    
+    
+    /**
+     * Returns the map of security context token identifiers
+     * @return
+     */
+    public static Hashtable getContextMap(MessageContext msgContext) {
+        //Fist check whether its there
+        Object map = msgContext.getConfigurationContext().getProperty(
+                RampartMessageData.KEY_CONTEXT_MAP);
+        
+        if(map == null) {
+            //If not create a new one
+            map = new Hashtable();
+            //Set the map globally
+            msgContext.getConfigurationContext().setProperty(
+                    RampartMessageData.KEY_CONTEXT_MAP, map);
+        }
+        
+        return (Hashtable)map;
+    }
+    
 }



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