users@glassfish.java.net

Re: Pass username from custom realm to error page

From: Kumar Jayanti <Vbkumar.Jayanti_at_Sun.COM>
Date: Fri, 05 Jun 2009 14:13:01 +0530

JasDA_at_web.de wrote:
> Hi,
>
> at the moment we are trying to get our old Tomcat 5 applications to work in Glassfish v2. I've implemented a custom realm for authentication and it works fine. But I have the following problem:
> If a user enters a wrong password the user will be redirected to an error page:
>
> <login-config>
> <auth-method>FORM</auth-method>
> <realm-name>iods9Realm</realm-name>
> <form-login-config>
> <form-login-page>/login.jsp</form-login-page>
> <form-error-page>/loginError.do</form-error-page>
> </form-login-config>
> </login-config>
>
> As you can see we're using Struts (I guess it's V1.x). My action looks like this:
>
> public void doExecute(ActionContext ctx) throws Exception
> {
> String text = "";
> if (ctx.request().getParameter("loginTimeout") != null)
> {
> .......
> }
> else
> {
> String userName = ctx.request().getParameter("j_username");
> .....
> }
> ctx.forwardByName("loginPage");
> }
>
> In our tomcat environment all parameters (j_username, ...) were available in this action. Now in our glassfish environment the parameters map is empty so I can't get the username. Is there any chance to geht the username? Perhaps it is possible to access the request from my custom realm that extends the IASRealm?
>
You can access username inside your Login Module, if your JAAS
LoginModule extends

com.sun.appserv.security.AppservPasswordLoginModule

then this class has protected members :

    protected String _username;
    protected String _password;
    protected Realm _currentRealm;

Does that help you in any way.

Thanks

> Regards,
> Jason
> __________________________________________________________
> WEB.DE FreeDSL mit DSL 6.000 Flatrate und Telefonanschluss
> für 17,95 Euro/mtl.!* http://produkte.web.de/go/02/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
>