Bug #1556: Use an enum to express the value of UserAuthenticationType field.

Using an enum instead of a simple String will make easier for us to change the
value of this field.

FEA: ItEr77S04BugFixing
This commit is contained in:
Jacobo Aragunde Pérez 2012-11-08 17:25:55 +01:00 committed by Manuel Rego Casasnovas
parent 724237e2ad
commit a9591cecd6

View file

@ -447,12 +447,28 @@ public class UserCRUDController extends BaseCRUDController<User> implements
return isLdapUser() || isUserDefaultAdmin(); return isLdapUser() || isUserDefaultAdmin();
} }
public String getAuthenticationType() { public enum UserAuthenticationType {
EMPTY(""), DATABASE(_("Database")), LDAP(_("LDAP"));
private String name;
private UserAuthenticationType(String name) {
this.name = name;
}
public String toString() {
return name;
}
}
public UserAuthenticationType getAuthenticationType() {
User user = getUser(); User user = getUser();
if (user != null) { if (user != null) {
return _(user.getUserType()); return user.isLibrePlanUser() ? UserAuthenticationType.DATABASE
: UserAuthenticationType.LDAP;
} }
return ""; return UserAuthenticationType.EMPTY;
} }
} }