Quantcast

How to clear java.net Authenticator cache?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to clear java.net Authenticator cache?

metro-3
Hi All,

I use custom authenticator to provide user / passwords to connect to .NET Web Services. I overloaded function getPasswordAuthentication() that returns right user / password combination for the requested URL. It all works perfectly for many kinds of HTTP connections: basic, ntlm, through proxy, ssl, etc.

My problem is that JVM caches somewhere my returned PasswordAuthentication. It causes several problems. First, if user types wrong password when trying to access Web Service for the first time this wrong password gets cached, getPasswordAuthentication() never gets called again. The only way to resolve it is to restart the application (with JVM) and try again.  So it looks like you try, you miss and there is no other chance. I think that there should be a fix for this that I miss because it looks like typical case for login.

My second case is less typical but I need to use it too. User logs in, performs some operation and then the other user logs in to the very same place. It is like you log in as administrator, pick something and then re-login as the regular user and create something based on what you picked.

Is it possible to clear authentication cache somehow in JVM? Or set time-to-live for some PasswordAuthentication objects? I found AuthCache object in sun.* packages but I do not know how to access or clear it.

I need to use Authenticator way and make Sun JVM to perform connect since I need to connect to many different authentication schemes that include ntlm, kerberos, ssl, proxies, basic, etc and Sun does very good job in this respect.

I would appreciate you suggestions.
Thank you,
Igor
[Message sent by forum member 'mklinchin' (mklinchin)]

http://forums.java.net/jive/thread.jspa?messageID=323236

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to clear java.net Authenticator cache?

metro-3
Hi again,

I figured out that the issue with wrong first login preventing other attempts to login is on the server side - server disabled user account after first unsuccessful login. It was not the problem of java.net Authenticator. I tried it with different server and everything works just as expected - in case of wrong login Authenticator does not cache user credentials and triggers call to the Authenticator again.

But I still cannot find out how to force java.net to re-login (re-authenticate with different user) to the same server (URL) after previous successful login by other user. Maye there is some trick that forces Authenticator cache to be cleared? For my case it would be fine to clear it completely for all URLs, not only for the one I am trying to re-authenticate.

I appreciate any help, thank you,
Igor
[Message sent by forum member 'mklinchin' (mklinchin)]

http://forums.java.net/jive/thread.jspa?messageID=323342

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to clear java.net Authenticator cache?

metro-3
I have the exact same issue.  Has there been any progress with a solution?  Thanks!
[Message sent by forum member 'brentwoodkris' (brentwoodkris)]

http://forums.java.net/jive/thread.jspa?messageID=324063

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to clear java.net Authenticator cache?

Benothmen Jacem
This post has NOT been accepted by the mailing list yet.
In reply to this post by metro-3
You need to reset the cache implementation before calling Authenticator.setDefault()

AuthCacheValue.setAuthCache(new AuthCacheImpl());
Loading...