I need to modify the username on the login form before it is passed on to LDAP for authentication.
Application is struts-based. I need to remove some characters from the j_username
before it is passed on to LDAP. Whats is the best way of doing it, javascript or writing a filter or interceptors in Struts? Can we make a login request to come to filter before it goes to j_security_check
?
Here are the details:
login.jsp
:
<form name="loginForm" method="POST" action='<%= response.encodeURL("j_security_check") %>'>
<table>
<tr><td>User Name</td><td><input type="text" name="j_username" size="10" maxlength="30"></td></tr>
<tr><td>Password</td><td><input type="password" name="j_password" size="10" maxlength="30"></td></tr>
<tr><td> </td><td><input type="submit" value="Login" name="j_security_check"></td></td></tr>
</table>
</form>
web.xml
:
<login-config>
<auth-method>FORM</auth-method>
<realm-name>Form-Based Authentication Area</realm-name>
<form-login-config>
<!-- form-login-page>/login.jsp</form-login-page -->
<form-login-page>/WEB-INF/login.jsp</form-login-page>
<form-error-page>/WEB-INF/login.jsp?result=false</form-error-page>
</form-login-config>
</login-config>
context.xml
:
<Realm className="org.apache.catalina.realm.JNDIRealm"
allRolesMode="authOnly"
connectionURL="ldap://localhost:9002"
connectionName="CN..."
connectionPassword=""
userPattern="--"/>