NIHVIVO-1207 Make LoginProcessBean.Message a simple class instead of an enum, so LoginShibboleth can create additional instances.

This commit is contained in:
jeb228 2010-11-10 20:13:00 +00:00
parent 8dc645cfb6
commit f2cf6093e6

View file

@ -97,54 +97,56 @@ public class LoginProcessBean {
NOWHERE, LOGGING_IN, FORCED_PASSWORD_CHANGE, LOGGED_IN NOWHERE, LOGGING_IN, FORCED_PASSWORD_CHANGE, LOGGED_IN
} }
private enum MLevel { public enum MLevel {
NONE, INFO, ERROR NONE, INFO, ERROR
} }
public enum Message { public static class Message {
NO_MESSAGE("", MLevel.NONE), public static final Message NO_MESSAGE = new Message("", MLevel.NONE);
PASSWORD_CHANGE_SAVED("Your password has been saved.<br/>" public static final Message PASSWORD_CHANGE_SAVED = new Message(
+ "Please log in.", MLevel.INFO), "Your password has been saved.<br/>" + "Please log in.",
MLevel.INFO);
NO_USERNAME("Please enter your email address.", MLevel.ERROR), public static final Message NO_USERNAME = new Message(
"Please enter your email address.", MLevel.ERROR);
NO_PASSWORD("Please enter your password.", MLevel.ERROR), public static final Message NO_PASSWORD = new Message(
"Please enter your password.", MLevel.ERROR);
UNKNOWN_USERNAME("The email or password you entered is incorrect.", public static final Message UNKNOWN_USERNAME = new Message(
MLevel.ERROR), "The email or password you entered is incorrect.", MLevel.ERROR);
INCORRECT_PASSWORD("The email or password you entered is incorrect.", public static final Message INCORRECT_PASSWORD = new Message(
MLevel.ERROR), "The email or password you entered is incorrect.", MLevel.ERROR);
NO_NEW_PASSWORD("Please enter your new password.", MLevel.ERROR), public static final Message NO_NEW_PASSWORD = new Message(
"Please enter your new password.", MLevel.ERROR);
MISMATCH_PASSWORD("The passwords entered do not match.", MLevel.ERROR), public static final Message MISMATCH_PASSWORD = new Message(
"The passwords entered do not match.", MLevel.ERROR);
PASSWORD_LENGTH( public static final Message PASSWORD_LENGTH = new Message(
"Please enter a password between {0} and {1} characters in length.", "Please enter a password between {0} and {1} characters in length.",
MLevel.ERROR), MLevel.ERROR);
USING_OLD_PASSWORD("Please choose a different password from the " public static final Message USING_OLD_PASSWORD = new Message(
+ "temporary one provided initially.", MLevel.ERROR); "Please choose a different password from the "
+ "temporary one provided initially.", MLevel.ERROR);
private final String format; private final String format;
private final MLevel messageLevel; private final MLevel messageLevel;
Message(String format, MLevel messageLevel) { public Message(String format, MLevel messageLevel) {
this.format = format; this.format = format;
this.messageLevel = messageLevel; this.messageLevel = messageLevel;
} }
String getFormat() { public MLevel getMessageLevel() {
return this.format;
}
MLevel getMessageLevel() {
return this.messageLevel; return this.messageLevel;
} }
String formatMessage(Object[] args) { public String formatMessage(Object[] args) {
return new MessageFormat(this.format).format(args); return new MessageFormat(this.format).format(args);
} }
} }