Hi All,

I am trying to implement certificate based authentication between HttpClient 
and Weblogic 8.1 server.

I have one webapplication in weblogic server,In this application we have 
defined authentication scheme is as "BASIC" with user name and password.

Now on the client side I am using AuthSSLProtocolSocketFactory as the socket 
factory.

In my client I have following code:

try
        {
            File keystoreFile = new File("mykeystore"); 
            org.apache.commons.httpclient.protocol.Protocol authhttps = new 
org.apache.commons.httpclient.protocol.Protocol("https",new 
AuthSSLProtocolSocketFactory(null, null,keystoreFile.toURL(), "password"), 
443); 
            
org.apache.commons.httpclient.protocol.Protocol.registerProtocol("https", 
authhttps);
        }
        catch(MalformedURLException mu)
        {
            throw new ProtocolException("Malformed URL Exception 
",mu.getCause());
            
        }
        HttpConnectionManagerParams connParams = new 
HttpConnectionManagerParams();
        connParams.setConnectionTimeout(timeOut);
        connParams.setDefaultMaxConnectionsPerHost(maxHostConnections);
        MultiThreadedHttpConnectionManager connManager = new 
MultiThreadedHttpConnectionManager();
        connManager.setParams(connParams);
        HostConfiguration hostConfig = new HostConfiguration();
        hostConfig.setHost(hostName, portNumber);
        httpClient = new HttpClient(connManager);
        httpClient.setHostConfiguration(hostConfig);
        httpClient.getParams().setAuthenticationPreemptive(true);

Then I am using following:

methodClass = new GetMethod(toSend.trim());
status = httpClient.executeMethod( methodClass );

But while executing the application  I am getting following error:

java.net.ConnectException: Connection refused: connect.

On further investigation I found that error is occuring at createSocket(
        final String host,
        final int port,
        final InetAddress localAddress,
        final int localPort,
        final HttpConnectionParams params

return socketfactory.createSocket(host, port, localAddress, localport);

Can anybody help me finding why this error?

Also is it required to use "SSL" for certificate based authentication

and 

what configuration do we need to do in our web application for this to work?

Regards,
Lalit

Reply via email to