Redirecting user on login

One of the reader posted a comment, asking how do i redirect user as soon as they login based on some condition, so i changed my SampleExplicitLoginFilter like this


public class SampleExplicitLoginFilter implements ExplicitLoginFilter{

public void login(HttpServletRequest request, HttpServletResponse response,
String userId, char[] password, FilterChainContext portalLoginContext, Subject subject,
String realm, ExplicitLoginFilterChain chain) throws LoginException,
WSSecurityException, PasswordInvalidException,
UserIDInvalidException, AuthenticationFailedException,
AuthenticationException, SystemLoginException,
com.ibm.portal.auth.exceptions.LoginException {
System.out.println("Entering SamplExplicitLoginFilter.login()");

System.out.println("User Id " + userId);
System.out.println("Password " + String.valueOf(password));
System.out.println("Realm" + realm);

chain.login(request, response, userId, password, portalLoginContext, subject, realm);
if(request.getRemoteUser().equals("wasadmin"))
portalLoginContext.setRedirectURL("/wps/myportal/Administration");
System.out.println("Exiting SamplExplicitLoginFilter.login()");
}
public void destroy() {
}
public void init(SecurityFilterConfig arg0)
throws SecurityFilterInitException {
}

}


I am checking if the remote user is wasdmin if yes i am redirecting him to /wps/myportal/Administration page.

4 comments:

Anonymous said...

Good example. I appreciate your effort. I am following you.

Anonymous said...

Your website is good. I have an issue. I describe it as follows: I see you redirect to Administration page by passing "/wps/myportal/Administration" as a string parameter. Now, I assume that under Home, I have label page named "My Information" and its unique name is "myinformation" and its friendly url is defined as "myinformation". What I want the regular user can see this page when login. By following your hint, I pass "wps/myportal/Home/myinformation" as a parameter. It did not work because portal returns user to Home only instead to My Information page. Am I right when passing the string "wps/myportal/Home/myinformation"?

Thanks in advance for your helps.

Apollo Web Design said...

The blog was absolutely fantastic! Lot of great information which can be helpful in some or the other way. Keep updating the blog, looking forward for more contents...Great job, keep it up.. Web Design Company Bangalore | Ecommerce web development company

Abhi said...

Thanks for info....
SEO Company in Bangalore