tags:

views:

398

answers:

2

Okay this is the problem

I have a Java application running on top of Apache Tomcat & I have this other application too with its own war file running on the same server.

Now I want to authenticate user once & pass that session to the other application.

We can say cross domain session sharing on same Apache Tomcat .. how should I go about it ....?

Thank you

+1  A: 

Create a unique token for the session and put in in a db table that both apps access.
Store the token in the users's cookie.
This avoids the session sharing issue and is also more scalable.

thethinman
And how are you going to authenticate with the second application using this approach - by faking a request to `j_security_check`? That doesn't exactly seem clean. Please do elaborate on "more scalable" as well.
ChssPly76
Both apps use the token from the cookie to look up the user's session in the shared database. Synchronizing state between servers isn't as scalable as stateless servers. Session state should be in the cookie and database.
thethinman
I'm not talking about session state. How are you going to **authenticate** your user? Who's going to set the principal, what'll happen to declarative security, etc.
ChssPly76
+1  A: 

Tomcat provides Single Sign On functionality via a valve specified within Host element in Tomcat's configuration:

<Host name="localhost" ...>
  <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
</Host>

There are certain restrictions applied, take a look at the above link (scroll to Single Sign On section) for details.

ChssPly76