1 18 19 package cowsultants.itracker.ejb.client.exceptions; 20 21 37 public class AuthenticatorException extends Exception { 38 public static final int INVALID_DATA = -1; 39 public static final int UNKNOWN_USER = -2; 40 public static final int INVALID_PASSWORD = -3; 41 public static final int INACTIVE_ACCOUNT = -4; 42 public static final int SYSTEM_ERROR = -5; 43 public static final int INVALID_AUTHENTICATION_TYPE = -6; 44 public static final int CUSTOM_ERROR = -7; 45 46 public static final int ERRORPAGE_TYPE_UNDEFINED = -1; 47 public static final int ERRORPAGE_TYPE_FORWARD = 1; 48 public static final int ERRORPAGE_TYPE_URL = 2; 49 50 private int type = 0; 51 private String messageKey = "itracker.web.error.login.system"; 52 private int errorPageType = ERRORPAGE_TYPE_UNDEFINED; 53 private String errorPageValue = null; 54 55 public AuthenticatorException() { 56 } 57 58 public AuthenticatorException(int type) { 59 this.type = type; 60 } 61 62 public AuthenticatorException(int type, String messageKey) { 63 this(type); 64 this.messageKey = messageKey; 65 } 66 67 public AuthenticatorException(String message, int type) { 68 super(message); 69 this.type = type; 70 } 71 72 public AuthenticatorException(String message, int type, String messageKey) { 73 this(message, type); 74 this.messageKey = messageKey; 75 } 76 77 public int getType() { 78 return type; 79 } 80 81 public void setType(int type) { 82 this.type = type; 83 } 84 85 public String getMessage() { 86 String message = super.getMessage(); 87 if(message == null || message.equals("")) { 88 message = "Empty message, type: " + getTypeString(); 89 } 90 91 return message; 92 } 93 94 99 public String getMessageKey() { 100 return messageKey; 101 } 102 103 108 public void setMessageKey(String messageKey) { 109 this.messageKey = messageKey; 110 } 111 112 119 public int getErrorPageType() { 120 return errorPageType; 121 } 122 123 130 public void setErrorPageType(int value) { 131 errorPageType = value; 132 } 133 134 141 public String getErrorPageValue() { 142 return errorPageValue; 143 } 144 145 152 public void setErrorPageValue(String value) { 153 errorPageValue = value; 154 } 155 156 private String getTypeString() { 157 if(type == INVALID_DATA) { 158 return "Invalid Data"; 159 } else if(type == UNKNOWN_USER) { 160 return "Unknown User"; 161 } else if(type == INVALID_PASSWORD) { 162 return "Invalid Password"; 163 } else if(type == INACTIVE_ACCOUNT) { 164 return "Inactive Account"; 165 } else if(type == SYSTEM_ERROR) { 166 return "System Error"; 167 } else if(type == INVALID_AUTHENTICATION_TYPE) { 168 return "Invalid Authentication Type"; 169 } else if(type == CUSTOM_ERROR ) { 170 return "Custom Error. Check message key."; 171 } 172 173 return "Unknown Type"; 174 } 175 } 176 177 | Popular Tags |