How to display proper error message using JAAS with JBOSS


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



    Here is the loginerror.jsp page:

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

    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!!!

  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 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 ]

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