You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Blaine <ht...@idmsinc.net> on 2004/01/29 00:14:58 UTC

setCredentials Fails in Applet

Howdy,

 

I have the example MultipartFileUploadApp working as an application.

 

When I try and do the same thing with an applet I can get everything to work
except setCredentials.  (For testing I have allowed all in the java.policy
file)

 

If I put my user:pw in the url it works.  That is until I use
EasySSLProtocolSocketFactory to accept self signed certs then the url trick
fails.

 

But either way even when connecting to a non SSL server the setCredentials
does not work from an applet.  The exact same piece of code works from an
application.

 

I've tried

           client.getState().setCredentials(null

                                                        ,null

                                                        ,new
UsernamePasswordCredentials("user", "password")

                                                        );

 

And I've also tried populating the first 2 arguments with the correct
values.

 

The error I get is

 

java.net.SocketException: Software caused connection abort: socket write
error

            at java.net.SocketOutputStream.socketWrite0(Native Method)

            at java.net.SocketOutputStream.socketWrite(Unknown Source)

            at java.net.SocketOutputStream.write(Unknown Source)

            at com.sun.net.ssl.internal.ssl.OutputRecord.a(Unknown Source)

            at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(Unknown Source)

            at com.sun.net.ssl.internal.ssl.AppOutputStream.write(Unknown
Source)

            at
org.apache.commons.httpclient.HttpConnection$WrappedOutputStream.write(HttpC
onnection.java:1368)

            at java.io.BufferedOutputStream.flushBuffer(Unknown Source)

            at java.io.BufferedOutputStream.write(Unknown Source)

            at
org.apache.commons.httpclient.methods.multipart.FilePart.sendData(FilePart.j
ava:259)

            at
org.apache.commons.httpclient.methods.multipart.Part.send(Part.java:293)

            at
org.apache.commons.httpclient.methods.multipart.Part.sendParts(Part.java:342
)

            at
org.apache.commons.httpclient.methods.MultipartPostMethod.writeRequestBody(M
ultipartPostMethod.java:288)

            at
org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.jav
a:2322)

            at
org.apache.commons.httpclient.HttpMethodBase.processRequest(HttpMethodBase.j
ava:2657)

            at
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:109
3)

            at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:674)

            at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:529)

            at EnvmxScanner.testUploadFile(EnvmxScanner.java:367)

            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)

            at java.lang.reflect.Method.invoke(Unknown Source)

            at sun.plugin.com.MethodDispatcher.invoke(Unknown Source)

            at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)

            at sun.plugin.com.DispatchImpl$2.run(Unknown Source)

            at java.security.AccessController.doPrivileged(Native Method)

            at sun.plugin.com.DispatchImpl.invoke(Unknown Source)

This is the same error I get in the application if I pass an invalid
user/pw.

 

Any help would be greatly appreciated.  I need to be able to use an applet
against a server that requires basic auth and has a self signed cert.

 

Thanks

Blaine