Discussions

General J2EE: How to display proper error message using JAAS with JBOSS

  1. Hello,

    We are using JAAS with JBOSS for our web application. We want to display proper error message for different scenarios when access is denied, for example:
    1) User ID or password is wrong
    2) LDAP server is down, etc
    But I don't know how to pass the proper error message from LoginModule to loginerror.jsp, there is something missing between loginModule and loginerror.jsp ( but I don't know what it is? With JAAS, it doesn't seem that we have a lot of control, all the page flow is controlled by web.xml)

    Here is the login-config section for my web.xml

    <login-config>
    <auth-method>FORM</auth-method>

    <form-login-config>
    <form-login-page>/login/login.jsp</form-login-page>
    <form-error-page>/login/loginerror.jsp</form-error-page>
    </form-login-config>
    </login-config>

    Here is the loginerror.jsp page:

    <html>
    <head>
    <title>eQuation 2.0</title>
    <link href="/styles/equation.css" rel="stylesheet">
    </head>
    <body>
    <table width="850" border="0" cellspacing="0" cellpadding="1" bgcolor="DDDDDD" align="center">
    <!-- Place header tag here -->
    <jsp:include page="/common/header.jsp" />
    <tr>
    <td>
    <TABLE width="100%" cellpadding="5" cellspacing="0" id="bodycontent">
    <tr>
    <td valign="top" width="80%">
    <table bgcolor="DDDDDD" width="75%" align="center">
    <tr>
    <td>
    &nbsp;
    <span class="parahead1">
    Invalid username or password, please try again
    </span>
    </td>
    </tr>
    <tr>
    <td>
    <form action="j_security_check" method="post">
    <table bgcolor="white" width="100%" cellpadding="3" cellspacing="3">
    <tr>
    <td id="smLabel">ONDex ID:</td>
    <td id="dataText"><input type="text" name="j_username"></td>
    </tr>
    <tr>
    <td id="smLabel">Password:</td>
    <td id="dataText"><input type="password" name="j_password"></td>
    </tr>
    </table>
    <br>
    <center>
    <input type="submit" value="Login">
    <input type="reset">
    </center>
    </form>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </td>
    </tr>
        <!-- Place footer tag here -->
    <jsp:include page="/common/footer.jsp" />
    </table>
    </body>
    </html>

    We have a customized loginModule class and its corresponding login-config.xml file. Here I don't know how to make the "Invalid username or password, please try again" a dynamic error message based on different scenarios happened in logModule, could some one give me some hints?

    Thanks a lot and have a good night!!!

    Jiao
  2. Jiao, I've been struggling with the same problem... did you happen to find a solution? Thanks, Julie
  3. any one got a solution for this ?[ Go to top ]

    i wanted to know how to get the error message in the error.jsp, which we provide in the login module. also how do we know in the error.jsp, that the exception thrown is loginexception or credentialexception or passwordexpired exception ?
  4. Hello All, Has any body got a solution for this issue.If so, please.. please share with me. Many Thanks Srini
  5. The short answer is here http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3837765 HTH, Vijay
  6. One solution is... You can create a thread local variable and assign it from the LoginModule and access from your login jsp.. public static ThreadLocal loginException = new ThreadLocal(); public LoginExceptionsList() { loginException.set("Error from consutrctor"); } public static ThreadLocal getLoginExceptionText(){ return loginException; } public static void setLoginExceptionText(String msg){ loginException.set(msg); }
  7. JBboss LdapLoginModule[ Go to top ]

    Sharan,
    I am using JBboss LdapLoginModule. How does your solution fit in this. Are you using your own login module?