[jboss-user] [JBoss Portal] - Re: How to get error messages on Login Failed
matallen
do-not-reply at jboss.com
Tue May 26 04:53:04 EDT 2009
I realise this is a late reply, but hopefully someone will find this answer useful.
Step 1) override the getUserStatus method in your custom loginModule
ie.
| @Override
| protected UserStatus getUserStatus(String inputPassword){
| MyUserVO user=getUserService().getUserByName(getUsernameAndPassword()[0]);
| if (!myLoginCheck(user)){
| return MyUserStatus.MY_ERROR_MESSAGE_1;
| }
| return super.getUserStatus(inputPassword);
| }
|
Step 2) pseudo extend UserStatus (the constructor is actually private so you need to reflect it). note: getUserStatus is called in the Login method if the login is successful - so remember to put any logic for a failure is the Abort method and successful login code in the Commit method
ie.
| public class MyUserStatus {
| public static UserStatus MY_ERROR_MESSAGE_1=naughtyCallOfPrivateConstructor(33945);
| private static UserStatus naughtyCallOfPrivateConstructor(int i){
| try{
| Class<?> c = Class.forName(UserStatus.class.getCanonicalName());
| Constructor[] allConstructors = c.getDeclaredConstructors();
| for (Constructor ctor : allConstructors) {
| ctor.setAccessible(true);
| UserStatus res=(UserStatus)ctor.newInstance(i);
| ctor.setAccessible(false); //return it just in case this causes an issue elsewhere
| return res;
| }
| }catch(IllegalAccessException e){
| e.printStackTrace();
| }catch(Exception e){
| e.printStackTrace();
| }
| return null;
| }
| }
|
Step 3) change your portal-server.war/login.jsp to use the new MyUserStatus - ie.
| else if (MyUserStatus.MY_ERROR_MESSAGE_1.equals(request.getAttribute("org.jboss.portal.userStatus"))){
| out.println(rb.getString("ACCOUNT_MY_ERROR_MESSAGE_1"));
| }
|
and don't forget to put the error message text in the resources file (Resource.properties in conf/bundles/)
hope this helps,
M
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4233208#4233208
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4233208
More information about the jboss-user
mailing list