Sumit Jain
Sumit Jain

Reputation: 1528

Spring Security with Struts 2 - redirect to different page based on User Role

I am able to authenticate the user from the database but there are different users in my app so I want to redirect them to their different homepages based on their Role.

The best way I guess would be by checking the user role in a struts action and then redirecting to appropriate page. But how do I do that. Does spring security set session variables storing authentication information.

If yes, then how do I access them in a struts action. Also how do I access the username and password after login

Upvotes: 0

Views: 1386

Answers (2)

user497087
user497087

Reputation: 1591

The alternative would be to do your routing within Spring Security itself by implementing your own AuthenticationSuccessHandler and wiring it into your Spring config.

Upvotes: 1

axtavt
axtavt

Reputation: 242686

You can access Authentication of the current user in any place during request processing as follows:

SecurityContextHolder.getSecuirtyContext().getAuthentication()

Upvotes: 1

Related Questions