Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Customized LoginUserAuth - How pass the error message back to the login page.

192 views
Skip to first unread message

mkhi...@us.ibm.com

unread,
Mar 7, 2006, 4:52:43 PM3/7/06
to
Hi,

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

Bill

unread,
Mar 8, 2006, 11:11:22 AM3/8/06
to
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

prasad...@g4soft.com

unread,
Mar 8, 2006, 11:54:19 AM3/8/06
to

I guess you are using Login portlet, in that case login portlet has got a login.jar in lib directory. That contains LoginMessages class which stores the login error messages.

mkhi...@us.ibm.com

unread,
Mar 8, 2006, 11:48:27 AM3/8/06
to
I found out that I need to modify the problem properties file in the shared/app/wp.ui.jar but there is only problem_en.properties and not problem.properties. I changed the problem_en.properties but it is still not working.

Anyone got the problem properties working in WPS 5.1.0.1?

Thanks,
Manoj

Bill

unread,
Mar 8, 2006, 1:12:56 PM3/8/06
to
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

mkhi...@us.ibm.com

unread,
Mar 8, 2006, 12:57:20 PM3/8/06
to
But thats a class file. I decompiled the class files and I saw the code. Basically this is how the message is send back to the portlet login jsp

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

mrosenthalchicago

unread,
Mar 8, 2006, 2:54:36 PM3/8/06
to
If you are using the login jsp and not the login portlet you may need to "touch" the default.jsp of the theme that is in place to get the jsp to recompile.

mkhi...@us.ibm.com

unread,
Mar 8, 2006, 3:45:45 PM3/8/06
to
Thanks for the response.

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

mkhi...@us.ibm.com

unread,
Mar 8, 2006, 5:08:00 PM3/8/06
to
I got it working.

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.

smpadm...@gmail.com

unread,
Mar 9, 2006, 10:15:34 PM3/9/06
to
Hi,

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

mrosenthalchicago

unread,
Mar 10, 2006, 9:00:28 AM3/10/06
to

mkhi...@us.ibm.com

unread,
Mar 10, 2006, 10:24:00 AM3/10/06
to
Hi,

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.


mkhi...@us.ibm.com

unread,
Mar 10, 2006, 10:18:13 AM3/10/06
to
Thanks a lot. Thats the link I followed.

David Tomlinson

unread,
Jan 10, 2007, 5:27:27 PM1/10/07
to

Wow, anything else? Reading glasses, a pillow, a clue?


er_Bin...@rediffmail.com

unread,
Jan 25, 2007, 5:44:23 AM1/25/07
to
Hi,

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

lix...@yahoo.com

unread,
Mar 16, 2009, 3:28:03 PM3/16/09
to
Will you share the code how to pass the error message from login command to login portlet? Thanks!
0 new messages