I have customized LoginUserAuth to capture the number of login failures. I need to send the correct error message back to the user. For ex. "Incorrect password: You have 3 more attempts left." or "Your account is locked please contact the administrator".
Can anyone please let me know how to send the error message or code back to the login jsp.
Thanks,
Manoj
Here are the imports:
...
import com.ibm.wps.engine.Problem;
import com.ibm.wps.auth.ErrorBean;
import com.ibm.wps.engine.RunData;
...
Create an object that will hold the problem:
private static final Problem ACCOUNT_LOCKED = new
Problem("account.locked");
Also define an integer that will hold the error code:
private final static int LOCKEDOUT = USER_DEFINED_ERROR + 1;
In your doAuthenticate when the condition occurs do this:
protected ErrorBean doAuthenticate(RunData aRunData, String aUserID,
String aPassword) {
...
errorBean = new ErrorBean(LOCKEDOUT, new CustomWpsException("Your ID is
is locked out. Please contact administrator."));
errorBean.setCause("accountLocked");
errorBean.setErrorCode(LOCKEDOUT);
aRunData.setProblem(ACCOUNT_LOCKED);
return errorBean;
...
Then in <WP_ROOT>/shared/app/wp.ui.jar extract problem_en.properties
into <WP_ROOT>/shared/app/nls
Add the following to the end of the property file:
account.locked=Your ID is is locked out. Please contact administrator.
You must restart WPS after that change. Also remember to add the jar
this class is packaged in into the WPSLib shared library and also
modify the LoaderService.properties file (the command.path value) so it
picks up your class.
Bill Crowell
Perficient
Anyone got the problem properties working in WPS 5.1.0.1?
Thanks,
Manoj
Are you sure it's hitting the LoginUserAuth class? If you do not have
security enabled then you must be using LoginUserNoAuth. Certain the
method signature matches what you are overriding?
Also, you can modify the login.jar as Prasad has said but it is against
IBM's support policy. Just FYI.
Bill Crowell
Perficient
Portlet Code:
WpsException statusMsg = new WpsException(LoginMessages.LOGIN_FAILED_0);
aRes.setRenderParameter("wps.portlets.login.status_message", statusMsg.getMessage(requestLocale));
JSP Code:
String message = (String) renderRequest.getParameter(Login.STATUS_MESSAGE);
This is what I have done so far
I have my own LoginUserAuth. In the authenticate method I check whether the user id disabled and I set my own error code in the ErrorBean. In the authenticate error method I have the below code
if (aErrorBean.getErrorCode() >= USER_DEFINED_ERROR)
{
Problem disabledProblem = new Problem("userid.disabled");
aRunData.setProblem(disabledProblem);
}
I have the userid.disabled in the problem_en.properties. But nothing happens in the login page. It still gives me the same message "EJPAK0004W: Login failed. Please enter a valid user ID and password."
I don't have the access to the renderRequest to set my own error code.
Not sure what I am missing. I would really appreciate if you can give me more details.
Manoj
I am using login portlet and I am able to change the jsp.
My problem is passing the error message from the customized LoginUserAuth class back to the login portlet jsp.
In the LoginUserAuth, I have access to RunData and ErrorBean. I tried to set the request attribute in the rundata but that does not work. So how to send the error message back to the jsp?
// onAuthenticationError method of LoginUserAuth
// All the below options does not work.
Problem disabledProblem = new Problem("nces.userid.disabled");
aRunData.setProblem(disabledProblem);
aRunData.getRequest().setAttribute("nceserror1","User is disabled");
aRunData.getSession().setAttribute("nceserror1","User is disabled");
Any suggestions?
Manoj
LoginUserAuth
aRunData.setProblem(new Problem ("Error Message"))
JSP
com.ibm.wps.engine.RunData rd = com.ibm.wps.engine.RunData.from(request);
String errormessage = rd.getProblem().getCause();
Thanks.
As I am beginner to WPS 5.1, could you please send me the code for customizing the portal login. And instruction to setup. If possible send us the URL for learning portal login.
Thanks & Regs
Anantha
This is the document I followed
http://www-1.ibm.com/support/docview.wss?rs=688&context=SSHRKX&q1=login&uid=swg21104482&loc=en_US&cs=utf-8%E2%8C%A9=en+en
Below are the steps
1) Follow the above doc to create your own LoginUserAuth
2) Copy your package in the WebSphere/PortalServer/shared/app directory
3) I have my own LDAP code inside the LoginUserAuth to check for the retries and lock the user.
4) The way I pass the error message is by setting the problem in the rundata in the LoginUserAuth and in the jsp you can get the rundata from request and then get the problem. Not sure whether this is the correct way.
Manoj.
Wow, anything else? Reading glasses, a pillow, a clue?
In my case, my WebSphere Portal Server 5.1.0.2 is configured with Novell eDirectory and I am using the IBM's standard authetication.
My requirement is that on authentication failure, i want to show customized error messages to the end user like Your account is expired, your account is locked etc.
But as I am using the standard authetication, how can i retrieve the LDAP error codes to show the customized error messages.
From ErrorBean class, I am only getting error code 5 irrespective of the reason of authentication failure.
So, please suggest how can i achieve this
Thanks and Regards,
Bindiya