No it will not as the authentication is associated with the established connection, if a client wishes to connect as a different user that user needs to establish a new connection to re-authenticate as a new user.

User is logging in application. After a while he wants a break. He pushes a logout button that doesn't make exit the application entirely, only the login screen will be displayed so the connection is the same.

After that when he relogin he can login with any password. The logout was never called.

Looks like this piece of code calls the logout method, but also calls the login with same credentials, so it's not helping me.

I'm not sure which disconnect you are talking about. The code snippets you have posted so far all deal with MBeanServerConnection and don't see how that relates to this thread. Could you create a separate thread explaining your usecase?

My main issue is to use a logout button that will invoke the logout from my JAAS login module. How can I do that from a swing application? It seems that it's possible to invoke that logout method from a web application when http session is invalidated.

Thank you Jaikiran Pai! I finally got around to testing this, and you were right. I tested both suggestions, but as you expected, the JAAS clearing had no effect, whereas your EJBClientContext based solution worked like a breeze. Thank you again for helping me out with this.