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 na...@apache.org on 2008/07/18 11:39:42 UTC

svn commit: r677866 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: deployment/util/Utils.java engine/DispatchPhase.java i18n/resource.properties

Author: nandana
Date: Fri Jul 18 02:39:41 2008
New Revision: 677866

URL: http://svn.apache.org/viewvc?rev=677866&view=rev
Log:
AXIS2-3920 Check the whether the binding is disabled when service is dispatched and fault if the binding is disabled 

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/i18n/resource.properties

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java?rev=677866&r1=677865&r2=677866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java Fri Jul 18 02:39:41 2008
@@ -37,6 +37,7 @@
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.Handler;
 import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.util.Loader;
 import org.apache.axis2.util.PolicyUtil;
 import org.apache.axis2.wsdl.WSDLConstants;
@@ -998,6 +999,9 @@
 				String protocol = transportName.substring(0, 1).toUpperCase()
 						+ transportName.substring(1, transportName.length())
 								.toLowerCase();
+				
+				//TODO do we use this method , we need to disable Http, SOAP11,SOAP12
+				// Bindings according to parameters if we are using this
 				/*
 				 * populates soap11 endpoint
 				 */
@@ -1071,42 +1075,75 @@
 				String protocol = transportName.substring(0, 1).toUpperCase()
 						+ transportName.substring(1, transportName.length())
 								.toLowerCase();
+				
+				
+		                // axis2.xml indicated no HTTP binding?
+		                boolean disableREST = false;
+		                Parameter disableRESTParameter = axisService
+		                                .getParameter(org.apache.axis2.Constants.Configuration.DISABLE_REST);
+		                if (disableRESTParameter != null
+		                                && JavaUtils.isTrueExplicitly(disableRESTParameter.getValue())) {
+		                        disableREST = true;
+		                }
+
+		                boolean disableSOAP11 = false;
+		                Parameter disableSOAP11Parameter = axisService
+		                                .getParameter(org.apache.axis2.Constants.Configuration.DISABLE_SOAP11);
+		                if (disableSOAP11Parameter != null
+		                                && JavaUtils.isTrueExplicitly(disableSOAP11Parameter.getValue())) {
+		                        disableSOAP11 = true;
+		                }
+
+		                boolean disableSOAP12 = false;
+		                Parameter disableSOAP12Parameter = axisService
+		                                .getParameter(org.apache.axis2.Constants.Configuration.DISABLE_SOAP12);
+		                if (disableSOAP12Parameter != null
+		                                && JavaUtils
+		                                                .isTrueExplicitly(disableSOAP12Parameter.getValue())) {
+		                        disableSOAP12 = true;
+		                }
+				
+				
 				/*
 				 * populates soap11 endpoint
 				 */
-				String soap11EndpointName = serviceName + protocol
-						+ "Soap11Endpoint";
-
-				AxisEndpoint httpSoap11Endpoint = new AxisEndpoint();
-				httpSoap11Endpoint.setName(soap11EndpointName);
-				httpSoap11Endpoint.setParent(axisService);
-				httpSoap11Endpoint.setTransportInDescription(transportName);
-				populateSoap11Endpoint(axisService, httpSoap11Endpoint,
-						bindingCache);
-				axisService.addEndpoint(httpSoap11Endpoint.getName(),
-						httpSoap11Endpoint);
-				// setting soap11 endpoint as the default endpoint
-				axisService.setEndpointName(soap11EndpointName);
+		                if (!disableSOAP11) {
+        			    String soap11EndpointName = serviceName + protocol
+        			    		+ "Soap11Endpoint";
+        
+        			    AxisEndpoint httpSoap11Endpoint = new AxisEndpoint();
+        			    httpSoap11Endpoint.setName(soap11EndpointName);
+        			    httpSoap11Endpoint.setParent(axisService);
+        			    httpSoap11Endpoint.setTransportInDescription(transportName);
+        			    populateSoap11Endpoint(axisService, httpSoap11Endpoint,
+        			    		bindingCache);
+        			    axisService.addEndpoint(httpSoap11Endpoint.getName(),
+        			    		httpSoap11Endpoint);
+        			    // setting soap11 endpoint as the default endpoint
+        			    axisService.setEndpointName(soap11EndpointName);
+		                }
 
 				/*
 				 * generating Soap12 endpoint
 				 */
-				String soap12EndpointName = serviceName + protocol
-						+ "Soap12Endpoint";
-				AxisEndpoint httpSoap12Endpoint = new AxisEndpoint();
-				httpSoap12Endpoint.setName(soap12EndpointName);
-				httpSoap12Endpoint.setParent(axisService);
-				httpSoap12Endpoint.setTransportInDescription(transportName);
-				populateSoap12Endpoint(axisService, httpSoap12Endpoint,
-						bindingCache);
-				axisService.addEndpoint(httpSoap12Endpoint.getName(),
-						httpSoap12Endpoint);
+		                if (!disableSOAP12) {
+		                    String soap12EndpointName = serviceName + protocol
+				            + "Soap12Endpoint";
+				    AxisEndpoint httpSoap12Endpoint = new AxisEndpoint();
+				    httpSoap12Endpoint.setName(soap12EndpointName);
+				    httpSoap12Endpoint.setParent(axisService);
+				    httpSoap12Endpoint.setTransportInDescription(transportName);
+				    populateSoap12Endpoint(axisService, httpSoap12Endpoint,
+				            bindingCache);
+				    axisService.addEndpoint(httpSoap12Endpoint.getName(),
+					    httpSoap12Endpoint);
+		                }
 
 				/*
 				 * generating Http endpoint
 				 */
-				if ("http".equals(transportName)
-						|| "https".equals(transportName)) {
+				if (("http".equals(transportName)
+						|| "https".equals(transportName)) && !disableREST) {
 					String httpEndpointName = serviceName + protocol
 							+ "Endpoint";
 					AxisEndpoint httpEndpoint = new AxisEndpoint();

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java?rev=677866&r1=677865&r2=677866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java Fri Jul 18 02:39:41 2008
@@ -34,6 +34,7 @@
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.axis2.description.Parameter;
 import org.apache.axis2.description.WSDL2Constants;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.transport.RequestResponseTransport;
@@ -93,6 +94,8 @@
         }
 
         validateTransport(msgContext);
+        
+        validateBindings(msgContext);
 
         loadContexts(service, msgContext);
 
@@ -223,6 +226,60 @@
         throw new AxisFault(Messages.getMessage("servicenotfoundforepr",
                                                 ((toEPR != null) ? toEPR.getAddress() : "")));
     }
+    
+    /**
+     * To check whether the incoming request has come in valid binding , we check whether service
+     * author has disabled any binding using parameters
+     * <code>org.apache.axis2.Constants.Configuration.DISABLE_SOAP12</code>
+     * <code>org.apache.axis2.Constants.Configuration.DISABLE_SOAP11</code>
+     * <code>org.apache.axis2.Constants.Configuration.DISABLE_REST</code>
+     * @param service msgctx the current MessageContext
+     * @throws AxisFault in case of error
+     */
+    private void validateBindings(MessageContext msgctx) throws AxisFault {
+        
+        AxisService service = msgctx.getAxisService();
+        
+        boolean disableREST = false;
+        Parameter disableRESTParameter = service
+                        .getParameter(org.apache.axis2.Constants.Configuration.DISABLE_REST);
+        if (disableRESTParameter != null
+                        && JavaUtils.isTrueExplicitly(disableRESTParameter.getValue())) {
+                disableREST = true;
+        }
+        
+        boolean disableSOAP11 = false;
+        Parameter disableSOAP11Parameter = service
+                        .getParameter(org.apache.axis2.Constants.Configuration.DISABLE_SOAP11);
+        if (disableSOAP11Parameter != null
+                        && JavaUtils.isTrueExplicitly(disableSOAP11Parameter.getValue())) {
+                disableSOAP11 = true;
+        }
+
+        boolean disableSOAP12 = false;
+        Parameter disableSOAP12Parameter = service
+                        .getParameter(org.apache.axis2.Constants.Configuration.DISABLE_SOAP12);
+        if (disableSOAP12Parameter != null
+                        && JavaUtils
+                                        .isTrueExplicitly(disableSOAP12Parameter.getValue())) {
+                disableSOAP12 = true;
+        }
+        
+        if (msgctx.isDoingREST()) {
+            if (disableREST) {
+                throw new AxisFault(Messages.getMessage("bindingDisabled","Http"));
+            }
+        } else if (msgctx.isSOAP11()) {
+            if (disableSOAP11) {
+                throw new AxisFault(Messages.getMessage("bindingDisabled","SOAP11"));
+            }
+        } else {
+            if(disableSOAP12) {
+                throw new AxisFault(Messages.getMessage("bindingDisabled","SOAP12"));  
+            }
+        }
+        
+    }
 
     private void fillContextsFromSessionContext(MessageContext msgContext) throws AxisFault {
         AxisService service = msgContext.getAxisService();

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/i18n/resource.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/i18n/resource.properties?rev=677866&r1=677865&r2=677866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/i18n/resource.properties (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/i18n/resource.properties Fri Jul 18 02:39:41 2008
@@ -266,6 +266,7 @@
 mustunderstandfailed2=Must Understand check failed for headers: {0}
 receivederrormessage=The system received an error message with the {0} ID. 
 servicenotfoundforepr=The service cannot be found for the endpoint reference (EPR) {0}
+bindingDisabled={0} binding is disabled for this service.
 operationnotfoundforepr=The endpoint reference (EPR) for the Operation not found is {0} and the WSA Action = {1}
 unabletofindservice=The requested service could not be found -- the operation has been stopped.
 invalidservicegrouoid=The {0} Service Group ID is not valid.