Author: keith Date: Tue Jun 3 03:44:02 2008 New Revision: 17843 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=17843
Log: Adding a configuration parameter to disallow http traffic to the mashup serevr. Setting this will make all links on the mashup.jsp use https links also the httpTransport Binding will be unavailable in all mashups Modified: trunk/mashup/java/modules/core/conf/server.xml trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java Modified: trunk/mashup/java/modules/core/conf/server.xml URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/core/conf/server.xml?rev=17843&r1=17842&r2=17843&view=diff ============================================================================== --- trunk/mashup/java/modules/core/conf/server.xml (original) +++ trunk/mashup/java/modules/core/conf/server.xml Tue Jun 3 03:44:02 2008 @@ -196,6 +196,8 @@ Enable the Management Console, true/false --> <EnableConsole>true</EnableConsole> + + <AllowHTTPAccess>true</AllowHTTPAccess> </Management> <!-- Modified: trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java?rev=17843&r1=17842&r2=17843&view=diff ============================================================================== --- trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java (original) +++ trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java Tue Jun 3 03:44:02 2008 @@ -30,11 +30,13 @@ import org.apache.axis2.deployment.repository.util.DeploymentFileData; import org.apache.axis2.description.AxisService; import org.apache.axis2.description.Parameter; +import org.apache.axis2.description.TransportInDescription; import org.apache.axis2.engine.AxisConfiguration; import org.apache.axis2.rpc.client.RPCServiceClient; import org.apache.axis2.transport.http.HTTPConstants; import org.apache.axis2.transport.http.util.URIEncoderDecoder; import org.apache.axis2.util.XMLChar; +import org.apache.axis2.util.JavaUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.neethi.Policy; @@ -990,6 +992,42 @@ .getService(serviceName).isExposedTransport(transportName); } + public static String getServerURL(String serverName) { + ServerManager serverManager = ServerManager.getInstance(); + ConfigurationContext configContext = serverManager.configContext; + AxisConfiguration configuration = configContext.getAxisConfiguration(); + ServerConfiguration serverConfig = ServerConfiguration.getInstance(); + String allowHttpAccess = serverConfig.getFirstProperty("Management.AllowHTTPAccess"); + + if (JavaUtils.isFalseExplicitly(allowHttpAccess)) { + TransportInDescription httpsTransport = configuration.getTransportIn("https"); + Parameter parameter = httpsTransport.getParameter("proxyPort"); + String port = ""; + if (parameter != null) { + String value = (String) parameter.getValue(); + if (!"443".equals(value)) { + port = ":" + value; + } + } else { + port = ":" + serverManager.getHttpsPort(); + } + return "https://" + serverName + port; + } + + TransportInDescription httpTransport = configuration.getTransportIn("http"); + Parameter parameter = httpTransport.getParameter("proxyPort"); + String port = ""; + if (parameter != null) { + String value = (String) parameter.getValue(); + if (!"80".equals(value)) { + port = ":" + value; + } + } else { + port = ":" + serverManager.getHttpPort(); + } + return "http://" + serverName + port; + } + /** * Locates the service Javascript file associated with ServiceJS parameter and returns * a Reader for it. Modified: trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java?rev=17843&r1=17842&r2=17843&view=diff ============================================================================== --- trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java (original) +++ trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java Tue Jun 3 03:44:02 2008 @@ -19,6 +19,7 @@ import org.apache.axiom.soap.SOAP11Constants; import org.apache.axiom.soap.SOAP12Constants; import org.apache.axis2.AxisFault; +import org.apache.axis2.util.JavaUtils; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.deployment.Deployer; import org.apache.axis2.deployment.DeploymentEngine; @@ -68,6 +69,7 @@ import org.wso2.registry.users.UserRealm; import org.wso2.wsas.ServerConstants; import org.wso2.wsas.ServerManager; +import org.wso2.utils.ServerConfiguration; import javax.xml.namespace.QName; import java.io.BufferedReader; @@ -586,6 +588,21 @@ axisService.addParameter(MashupConstants.UNDISPATCHED_OPERATION, undispatched); } + ServerConfiguration serverConfig = ServerConfiguration.getInstance(); + String allowHttpAccess = serverConfig.getFirstProperty("Management.AllowHTTPAccess"); + if (JavaUtils.isFalseExplicitly(allowHttpAccess)) { + axisService.setEnableAllTransports(false); + HashMap map = axisConfig.getTransportsIn(); + Iterator iterator = map.values().iterator(); + while (iterator.hasNext()) { + TransportInDescription transportIn = (TransportInDescription) iterator.next(); + String transportName = transportIn.getName(); + if (!HTTP_TRANSPORT.equals(transportName)) { + axisService.addExposedTransport(transportName); + } + } + } + ArrayList serviceList = new ArrayList(); serviceList.add(axisService); return serviceList; _______________________________________________ Mashup-dev mailing list [email protected] http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev
