[
http://issues.apache.org/jira/browse/XMLRPC-101?page=comments#action_12424598 ]
Julio Francisco Veronelli commented on XMLRPC-101:
--------------------------------------------------
I copy the method i'm trying to overwrite as an example. I think it would be a
nice improvement to be able to create a customized connection by overwriting a
method in XmlRpcSunHttpTransport.
public Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException {
XmlRpcHttpClientConfig config =
(XmlRpcHttpClientConfig)pRequest.getConfig();
URLConnection result = null;
try {
//TIP set trusted certificates
if ((_sslFactory == null) && (_keystore != null)) {
TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
tmf.init(_keystore);
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null,tmf.getTrustManagers(),null);
_sslFactory = sslContext.getSocketFactory();
}
//TIP create connection
URL url = config.getServerURL();
if (_proxy != null) result = url.openConnection(_proxy);
else result = url.openConnection();
if ((_sslFactory != null) && (result instanceof HttpsURLConnection))
((HttpsURLConnection)result).setSSLSocketFactory(_sslFactory);
result.setUseCaches(false);
result.setDoInput(true);
result.setDoOutput(true);
}
catch (GeneralSecurityException ex) {
throw new XmlRpcException("Failed to set certificate trust chain",ex);
}
catch (Exception ex) {
throw new XmlRpcException("Failed to create URLConnection: " +
ex.getMessage(),ex);
}
return super.sendRequest(pRequest);
}
> Possibility to subclass XmlRpcSunHttpTransport for added functionality
> ----------------------------------------------------------------------
>
> Key: XMLRPC-101
> URL: http://issues.apache.org/jira/browse/XMLRPC-101
> Project: XML-RPC
> Issue Type: Improvement
> Components: Source
> Affects Versions: 3.0rc1
> Reporter: Julio Francisco Veronelli
> Priority: Trivial
>
> Could it be possible to make the URLConnection in class
> org.apache.xmlrpc.client.XmlRpcSunHttpTransport protected instead of private?
> That is:
> protected URLConnection conn;
> REASON:
> That way is much easier to subclass for added functionality. In particular,
> i'm subclassing it to set a java.net.Proxy or a java.security.KeyStore used
> for setting a SSL connection.
> In XML-RPC 3.0a1 it was easy to do, all that was needed was to subclass
> method newConnection(). In 3.0RC1 that method is gone, and overwriting
> sendRequest(XmlRpcRequest) is not possible, since conn is private.
> I tried also extending XmlRpcHttpTransport, but it is not possible, because
> org.apache.xmlrpc.client.XmlRpcStreamTransport.RequestWriter is protected and
> cannot be accessed.
> Thanks in advance.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]