Author: keith Date: Wed Jun 25 21:14:17 2008 New Revision: 18642 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=18642
Log: Fixing Mashup-884 Modified: trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java 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=18642&r1=18641&r2=18642&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 Wed Jun 25 21:14:17 2008 @@ -1328,16 +1328,7 @@ // If the feed is on https then we have to make sure we set the users keystore // details into httpClient when making the call so that all sslHandshake stuff // will go amoothly - MessageContext currentMessageContext = - MessageContext.getCurrentMessageContext(); - - // In order to get the users keystore details we need his username. We stick the - // username as a parameter into the service at deployment time - String username = - (String) currentMessageContext.getAxisService().getParameterValue( - MashupConstants.MASHUP_AUTHOR_NAME); - ProtocolSocketFactory psf = new CustomProtocolSocketFactory( - MashupUtils.getUserKeystoreResource(username)); + ProtocolSocketFactory psf = getCustomProtocolSocketFactory(); // Check weather the url has a port stated explicitly. If its not present // default to 443 @@ -1355,4 +1346,18 @@ } return httpClient.executeMethod(config, method); } + + public static ProtocolSocketFactory getCustomProtocolSocketFactory() { + MessageContext currentMessageContext = + MessageContext.getCurrentMessageContext(); + + // In order to get the users keystore details we need his username. We stick the + // username as a parameter into the service at deployment time + String username = + (String) currentMessageContext.getAxisService().getParameterValue( + MashupConstants.MASHUP_AUTHOR_NAME); + ProtocolSocketFactory psf = new CustomProtocolSocketFactory( + MashupUtils.getUserKeystoreResource(username)); + return psf; + } } \ No newline at end of file Modified: trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java?rev=18642&r1=18641&r2=18642&view=diff ============================================================================== --- trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java (original) +++ trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java Wed Jun 25 21:14:17 2008 @@ -39,6 +39,8 @@ import org.apache.axis2.util.XMLUtils; import org.apache.axis2.wsdl.WSDLConstants; import org.apache.commons.httpclient.cookie.CookiePolicy; +import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; +import org.apache.commons.httpclient.protocol.Protocol; import org.apache.neethi.Policy; import org.apache.neethi.PolicyEngine; import org.apache.rampart.RampartMessageData; @@ -59,7 +61,10 @@ import org.wso2.javascript.xmlimpl.XML; import org.wso2.mashup.MashupConstants; import org.wso2.mashup.MashupFault; +import org.wso2.mashup.utils.CustomProtocolSocketFactory; +import org.wso2.mashup.utils.MashupUtils; import org.wso2.wsas.ServerManager; +import org.wso2.wsas.ServerConstants; import javax.wsdl.Definition; import javax.wsdl.Port; @@ -655,8 +660,10 @@ if (wsRequest.async) { // asynchronous call to send() AxisCallback callback = new WSRequestCallBack(Context.getCurrentContext(), wsRequest); if (wsRequest.wsdlMode) { + setSSLProperties(wsRequest); wsRequest.sender.sendReceiveNonBlocking(operationName, payloadElement, callback); } else { + setSSLProperties(wsRequest); wsRequest.sender.sendReceiveNonBlocking(payloadElement, callback); } wsRequest.readyState = 2; @@ -705,8 +712,10 @@ wsRequest.sender.engageModule(MashupConstants.RAMPART); wsRequest.sender.engageModule(MashupConstants.ADDRESSING); } + setSSLProperties(wsRequest); wsRequest.responseXML = wsRequest.sender.sendReceive(operationName, payloadElement); } else { + setSSLProperties(wsRequest); wsRequest.responseXML = wsRequest.sender.sendReceive(payloadElement); } wsRequest.readyState = 4; @@ -1023,4 +1032,20 @@ } return (WSRequestHostImpl) obj; } + + private static void setSSLProperties(WSRequestHostImpl wsRequest) throws AxisFault { + Options options = wsRequest.sender.getOptions(); + String toAddress = options.getTo().getAddress(); + URL url = null; + try { + url = new URL(toAddress); + } catch (MalformedURLException e) { + throw AxisFault.makeFault(e); + } + if (ServerConstants.HTTPS_TRANSPORT.equals(url.getProtocol())) { + ProtocolSocketFactory psf = MashupUtils.getCustomProtocolSocketFactory(); + Protocol protocol = new Protocol("custom-https", psf, 443); + options.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER, protocol); + } + } } \ No newline at end of file _______________________________________________ Mashup-dev mailing list [email protected] http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev
