NIHVIVO-2279 Add externalAuthId to the UserAccount.
This commit is contained in:
parent
c6ed488e64
commit
eac9e5dca1
6 changed files with 52 additions and 35 deletions
|
@ -11,6 +11,10 @@ import java.util.Set;
|
|||
* Information about the account of a user. URI, email, password, etc.
|
||||
*/
|
||||
public class UserAccount {
|
||||
|
||||
public final static int MIN_PASSWORD_LENGTH = 6;
|
||||
public final static int MAX_PASSWORD_LENGTH = 12;
|
||||
|
||||
public enum Status {
|
||||
ACTIVE, INACTIVE;
|
||||
|
||||
|
@ -30,36 +34,20 @@ public class UserAccount {
|
|||
|
||||
}
|
||||
|
||||
/** Should never be null. */
|
||||
private String uri = "";
|
||||
private String uri = ""; // Never null.
|
||||
|
||||
private String emailAddress = ""; // Never null.
|
||||
private String firstName = ""; // Never null.
|
||||
private String lastName = ""; // Never null.
|
||||
|
||||
/** Should never be null. */
|
||||
private String emailAddress = "";
|
||||
|
||||
/** Should never be null. */
|
||||
private String firstName = "";
|
||||
|
||||
/** Should never be null. */
|
||||
private String lastName = "";
|
||||
|
||||
|
||||
/** Should never be null. */
|
||||
private String md5Password = "";
|
||||
|
||||
/** Should never be null. */
|
||||
private String oldPassword = "";
|
||||
|
||||
/** Should never be negative. */
|
||||
private long passwordLinkExpires = 0L;
|
||||
|
||||
private String md5Password = ""; // Never null.
|
||||
private String oldPassword = ""; // Never null.
|
||||
private long passwordLinkExpires = 0L; // Never negative.
|
||||
private boolean passwordChangeRequired = false;
|
||||
|
||||
/** Should never be negative. */
|
||||
private int loginCount = 0;
|
||||
|
||||
/** Might be null. */
|
||||
private Status status = Status.INACTIVE;
|
||||
private int loginCount = 0; // Never negative.
|
||||
private Status status = Status.INACTIVE; // Might be null.
|
||||
private String externalAuthId = ""; // Never null.
|
||||
|
||||
/** This may be empty, but should never be null. */
|
||||
private Set<String> permissionSetUris = Collections.emptySet();
|
||||
|
@ -128,7 +116,8 @@ public class UserAccount {
|
|||
}
|
||||
|
||||
public void setPasswordChangeRequired(Boolean passwordChangeRequired) {
|
||||
this.passwordChangeRequired = nonNull(passwordChangeRequired, Boolean.FALSE);
|
||||
this.passwordChangeRequired = nonNull(passwordChangeRequired,
|
||||
Boolean.FALSE);
|
||||
}
|
||||
|
||||
public int getLoginCount() {
|
||||
|
@ -151,6 +140,14 @@ public class UserAccount {
|
|||
this.status = Status.fromString(statusString);
|
||||
}
|
||||
|
||||
public String getExternalAuthId() {
|
||||
return externalAuthId;
|
||||
}
|
||||
|
||||
public void setExternalAuthId(String externalAuthId) {
|
||||
this.externalAuthId = nonNull(externalAuthId, "");
|
||||
}
|
||||
|
||||
public Set<String> getPermissionSetUris() {
|
||||
return new HashSet<String>(permissionSetUris);
|
||||
}
|
||||
|
@ -161,19 +158,21 @@ public class UserAccount {
|
|||
}
|
||||
this.permissionSetUris = new HashSet<String>(permissionSetUris);
|
||||
}
|
||||
|
||||
|
||||
private <T> T nonNull(T value, T defaultValue) {
|
||||
return (value == null) ? defaultValue : value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserAccount[uri=" + uri + ", emailAddress=" + emailAddress
|
||||
+ ", firstName=" + firstName + ", lastName=" + lastName
|
||||
+ ", md5password=" + md5Password + ", passwordChangeExpires="
|
||||
+ passwordLinkExpires + ", loginCount=" + loginCount
|
||||
+ ", status=" + status + ", permissionSetUris="
|
||||
+ permissionSetUris + "]";
|
||||
return "UserAccount[uri=" + uri + (", emailAddress=" + emailAddress)
|
||||
+ (", firstName=" + firstName) + (", lastName=" + lastName)
|
||||
+ (", md5password=" + md5Password)
|
||||
+ (", oldPassword=" + oldPassword)
|
||||
+ (", passwordLinkExpires=" + passwordLinkExpires)
|
||||
+ (", passwordChangeRequired=" + passwordChangeRequired)
|
||||
+ (", loginCount=" + loginCount) + (", status=" + status)
|
||||
+ (", externalAuthId=" + externalAuthId)
|
||||
+ (", permissionSetUris=" + permissionSetUris) + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -193,6 +193,7 @@ public class VitroVocabulary {
|
|||
public static final String USERACCOUNT_STATUS = VITRO_AUTH + "status";
|
||||
public static final String USERACCOUNT_PASSWORD_LINK_EXPIRES = VITRO_AUTH + "passwordLinkExpires";
|
||||
public static final String USERACCOUNT_PASSWORD_CHANGE_REQUIRED = VITRO_AUTH + "passwordChangeRequired";
|
||||
public static final String USERACCOUNT_EXTERNAL_AUTH_ID = VITRO_AUTH + "externalAuthId";
|
||||
public static final String USERACCOUNT_HAS_PERMISSION_SET = VITRO_AUTH + "hasPermissionSet";
|
||||
|
||||
public static final String PERMISSIONSET = VITRO_AUTH + "PermissionSet";
|
||||
|
|
|
@ -167,6 +167,7 @@ public class JenaBaseDaoCon {
|
|||
protected DatatypeProperty USERACCOUNT_STATUS = _constModel.createDatatypeProperty(VitroVocabulary.USERACCOUNT_STATUS);
|
||||
protected DatatypeProperty USERACCOUNT_PASSWORD_LINK_EXPIRES = _constModel.createDatatypeProperty(VitroVocabulary.USERACCOUNT_PASSWORD_LINK_EXPIRES);
|
||||
protected DatatypeProperty USERACCOUNT_PASSWORD_CHANGE_REQUIRED = _constModel.createDatatypeProperty(VitroVocabulary.USERACCOUNT_PASSWORD_CHANGE_REQUIRED);
|
||||
protected DatatypeProperty USERACCOUNT_EXTERNAL_AUTH_ID = _constModel.createDatatypeProperty(VitroVocabulary.USERACCOUNT_EXTERNAL_AUTH_ID);
|
||||
protected ObjectProperty USERACCOUNT_HAS_PERMISSION_SET = _constModel.createObjectProperty(VitroVocabulary.USERACCOUNT_HAS_PERMISSION_SET);
|
||||
|
||||
protected OntClass PERMISSIONSET = _constModel.createClass(VitroVocabulary.PERMISSIONSET);
|
||||
|
|
|
@ -61,6 +61,8 @@ public class UserAccountsDaoJena extends JenaBaseDao implements UserAccountsDao
|
|||
USERACCOUNT_PASSWORD_CHANGE_REQUIRED));
|
||||
u.setLoginCount(getPropertyIntValue(r, USERACCOUNT_LOGIN_COUNT));
|
||||
u.setStatusFromString(getPropertyStringValue(r, USERACCOUNT_STATUS));
|
||||
u.setExternalAuthId(getPropertyStringValue(r,
|
||||
USERACCOUNT_EXTERNAL_AUTH_ID));
|
||||
u.setPermissionSetUris(getPropertyResourceURIValues(r,
|
||||
USERACCOUNT_HAS_PERMISSION_SET));
|
||||
return u;
|
||||
|
@ -105,6 +107,8 @@ public class UserAccountsDaoJena extends JenaBaseDao implements UserAccountsDao
|
|||
addPropertyStringValue(res, USERACCOUNT_STATUS, userAccount
|
||||
.getStatus().toString(), model);
|
||||
}
|
||||
addPropertyStringValue(res, USERACCOUNT_EXTERNAL_AUTH_ID,
|
||||
userAccount.getExternalAuthId(), model);
|
||||
updatePropertyResourceURIValues(res,
|
||||
USERACCOUNT_HAS_PERMISSION_SET,
|
||||
userAccount.getPermissionSetUris(), model);
|
||||
|
@ -158,6 +162,8 @@ public class UserAccountsDaoJena extends JenaBaseDao implements UserAccountsDao
|
|||
updatePropertyStringValue(res, USERACCOUNT_STATUS, userAccount
|
||||
.getStatus().toString(), model);
|
||||
}
|
||||
updatePropertyStringValue(res, USERACCOUNT_EXTERNAL_AUTH_ID,
|
||||
userAccount.getExternalAuthId(), model);
|
||||
updatePropertyResourceURIValues(res,
|
||||
USERACCOUNT_HAS_PERMISSION_SET,
|
||||
userAccount.getPermissionSetUris(), model);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue