axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hemap...@apache.org
Subject svn commit: r384112 - in /webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security: SecurityModule.java util/HandlerParameterDecoder.java
Date Wed, 08 Mar 2006 04:01:33 GMT
Author: hemapani
Date: Tue Mar  7 20:01:31 2006
New Revision: 384112

URL: http://svn.apache.org/viewcvs?rev=384112&view=rev
Log:
add support to load the configuration from Module parameters

Modified:
    webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/SecurityModule.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/util/HandlerParameterDecoder.java

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/SecurityModule.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/SecurityModule.java?rev=384112&r1=384111&r2=384112&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/SecurityModule.java
(original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/SecurityModule.java
Tue Mar  7 20:01:31 2006
@@ -34,12 +34,17 @@
 import org.apache.ws.security.policy.parser.WSSPolicyProcessor;
 
 public class SecurityModule implements Module {
-
+	private AxisModule module;
+	
+	
+	public void init(ConfigurationContext configContext, AxisModule module) throws AxisFault
{
+        this.module = module;
+    }
+	
+	
     public void engageNotify(AxisDescription axisDescription) throws AxisFault {
         Policy policy = axisDescription.getPolicyInclude().getEffectivePolicy();
         if(axisDescription instanceof AxisOperation && policy != null) {
-//            PolicyWriter writer = PolicyFactory.getPolicyWriter(PolicyFactory.StAX_POLICY_WRITER);
-//            writer.writePolicy(policy, System.out);
             try {
                 WSSPolicyProcessor wssPolicyProcessor = new WSSPolicyProcessor();
                 wssPolicyProcessor.setup();
@@ -50,26 +55,7 @@
                 InflowConfiguration policyInflowConfig = config.getInflowConfiguration();
                 OutflowConfiguration policyOutflowConfig = config.getOutflowConfiguration();
                 
-                Parameter inflowSecParam = axisDescription.getParameter(WSSHandlerConstants.INFLOW_SECURITY);
-                Parameter outflowSecParam = axisDescription.getParameter(WSSHandlerConstants.OUTFLOW_SECURITY);
-                
-                InflowConfiguration staticInflowConfig = HandlerParameterDecoder.getInflowConfiguration(inflowSecParam);
-                OutflowConfiguration staticOutflowConfig = HandlerParameterDecoder.getOutflowConfiguration(outflowSecParam);
-
-//                if(staticInflowConfig == null || staticOutflowConfig == null) {
-//                    throw new Exception("Static configuration not available!!!");
-//                }
-                if(staticOutflowConfig != null) {
-                    OutflowConfiguration mergedOutflowConfig = this
-                            .mergeStaticAndPolicyOutflowConfiguration(
-                                    staticOutflowConfig, policyOutflowConfig);
-                    axisDescription.addParameter(mergedOutflowConfig.getProperty());
-                }
-                
-                if(staticInflowConfig != null) {
-                    InflowConfiguration mergedInflowConfig = this.mergeStaticAndPolicyInflowConfiguration(staticInflowConfig,
policyInflowConfig);
-                    axisDescription.addParameter(mergedInflowConfig.getProperty());
-                }
+                calcuateCurrentConfiguration(policyInflowConfig,policyOutflowConfig,axisDescription);
             } catch (Exception e) {
                 throw new AxisFault(e.getMessage(),e);
             }
@@ -80,26 +66,69 @@
         //Do nothing
     }
 
-    public void init(ConfigurationContext configContext, AxisModule module) throws AxisFault
{
-        //DO nothing 
-    }
+    
 
-    private OutflowConfiguration mergeStaticAndPolicyOutflowConfiguration(
-            OutflowConfiguration staticConfig, OutflowConfiguration policyConfig) {
-        policyConfig.setPasswordCallbackClass(staticConfig.getPasswordCallbackClass());
-        policyConfig.setSignaturePropFile(staticConfig.getSignaturePropFile());
-        policyConfig.setEncryptionPropFile(staticConfig.getEncryptionPropFile());
-        policyConfig.setEmbeddedKeyCallbackClass(staticConfig.getEmbeddedKeyCallbackClass());
-        policyConfig.setUser(staticConfig.getUser());
-        policyConfig.setEncryptionUser(staticConfig.getEncryptionUser());
-        return policyConfig;
+    private void calcuateCurrentConfiguration(InflowConfiguration policyInflowConfig,
+    		OutflowConfiguration policyOutflowConfig,AxisDescription axisDescription) throws AxisFault{
+    	//merge inflow configuration
+    	Parameter inflowModuleParam = axisDescription.getParameter(WSSHandlerConstants.INFLOW_SECURITY);
+    	InflowConfiguration moduleInflowConfig = HandlerParameterDecoder.getInflowConfiguration(inflowModuleParam);
+    	
+    	Parameter inflowSecParam = axisDescription.getParameter(WSSHandlerConstants.INFLOW_SECURITY);
+    	InflowConfiguration staticInflowConfig = HandlerParameterDecoder.getInflowConfiguration(inflowSecParam);
+    	
+    	InflowConfiguration mergedInConf = mergeInflowConfiguration(staticInflowConfig,moduleInflowConfig);
+    	InflowConfiguration finalInConf = mergeInflowConfiguration(policyInflowConfig,mergedInConf);
+    	axisDescription.addParameter(finalInConf.getProperty());
+    	
+    	
+    	
+    	//merge outflow configuration
+    	Parameter outfloModuleParam = axisDescription.getParameter(WSSHandlerConstants.OUTFLOW_SECURITY);
+    	OutflowConfiguration moduleOutflowConfig = HandlerParameterDecoder.getOutflowConfiguration(outfloModuleParam);
+        Parameter outflowSecParam = axisDescription.getParameter(WSSHandlerConstants.OUTFLOW_SECURITY);
+        OutflowConfiguration staticOutflowConfig = HandlerParameterDecoder.getOutflowConfiguration(outflowSecParam);
+        
+        OutflowConfiguration mergedOutFlowConf = mergeOutflowConfiguration(staticOutflowConfig,moduleOutflowConfig);
+        OutflowConfiguration finalOutFlowConf = mergeOutflowConfiguration(policyOutflowConfig,mergedOutFlowConf);
+        axisDescription.addParameter(finalOutFlowConf.getProperty());
+    }
+    
+    
+    //overide secondry configuration with primry configuration
+    private OutflowConfiguration mergeOutflowConfiguration(
+    		OutflowConfiguration primaryConfig,OutflowConfiguration secondryConf) {
+    	if(secondryConf == null && primaryConfig != null){
+    		return primaryConfig;
+    	}else if(primaryConfig == null && secondryConf != null){
+    		return secondryConf;
+    	}else if(primaryConfig == null && secondryConf == null){
+    		return null;
+    	}
+    	
+    	secondryConf.setPasswordCallbackClass(primaryConfig.getPasswordCallbackClass());
+    	secondryConf.setSignaturePropFile(primaryConfig.getSignaturePropFile());
+    	secondryConf.setEncryptionPropFile(primaryConfig.getEncryptionPropFile());
+    	secondryConf.setEmbeddedKeyCallbackClass(primaryConfig.getEmbeddedKeyCallbackClass());
+    	secondryConf.setUser(primaryConfig.getUser());
+    	secondryConf.setEncryptionUser(primaryConfig.getEncryptionUser());
+        return secondryConf;
     }
     
-    private InflowConfiguration mergeStaticAndPolicyInflowConfiguration(
-            InflowConfiguration staticConfig, InflowConfiguration policyConfig) {
-        policyConfig.setPasswordCallbackClass(staticConfig.getPasswordCallbackClass());
-        policyConfig.setDecryptionPropFile(staticConfig.getDecryptionPropFile());
-        policyConfig.setSignaturePropFile(staticConfig.getSignaturePropFile());
-        return policyConfig;
+    //overide secondry configuration with primry configuration
+    private InflowConfiguration mergeInflowConfiguration(
+    		InflowConfiguration primaryConfig,InflowConfiguration secondryConf) {
+    	if(secondryConf == null && primaryConfig != null){
+    		return primaryConfig;
+    	}else if(primaryConfig == null && secondryConf != null){
+    		return secondryConf;
+    	}else if(primaryConfig == null && secondryConf == null){
+    		return null;
+    	}
+    	
+    	secondryConf.setPasswordCallbackClass(primaryConfig.getPasswordCallbackClass());
+    	secondryConf.setDecryptionPropFile(primaryConfig.getDecryptionPropFile());
+    	secondryConf.setSignaturePropFile(primaryConfig.getSignaturePropFile());
+        return secondryConf;
     }
 }

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/util/HandlerParameterDecoder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/util/HandlerParameterDecoder.java?rev=384112&r1=384111&r2=384112&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/util/HandlerParameterDecoder.java
(original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/util/HandlerParameterDecoder.java
Tue Mar  7 20:01:31 2006
@@ -15,6 +15,7 @@
  */
 package org.apache.axis2.security.util;
 
+import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.security.handler.WSSHandlerConstants;
@@ -138,14 +139,14 @@
 		}
 	}
     
-    public static OutflowConfiguration getOutflowConfiguration(Parameter outflowConfigParam)
throws Exception {
+    public static OutflowConfiguration getOutflowConfiguration(Parameter outflowConfigParam)
throws AxisFault {
         if (outflowConfigParam != null) {
             OMElement outflowParamElem = outflowConfigParam.getParameterElement();
 
             OMElement actionElem = outflowParamElem
                     .getFirstChildWithName(new QName(WSSHandlerConstants.ACTION));
             if (actionElem == null) {
-                throw new Exception(
+                throw new AxisFault(
                         "Inflow configurtion must contain an 'action' "
                                 + "elementas the child of 'InflowSecurity' element");
             }
@@ -176,7 +177,7 @@
         return null;
     }
     
-    public static InflowConfiguration getInflowConfiguration(Parameter inflowConfigParam)
throws Exception {
+    public static InflowConfiguration getInflowConfiguration(Parameter inflowConfigParam)
throws AxisFault {
 
         if (inflowConfigParam != null) {
             OMElement inFlowParamElem = inflowConfigParam.getParameterElement();
@@ -184,7 +185,7 @@
             OMElement actionElem = inFlowParamElem
                     .getFirstChildWithName(new QName(WSSHandlerConstants.ACTION));
             if (actionElem == null) {
-                throw new Exception(
+                throw new AxisFault(
                         "Inflow configurtion must contain an 'action' "
                                 + "elementas the child of 'InflowSecurity' element");
             }



Mime
View raw message