GUAC-1176: Add password expiration attribute.

This commit is contained in:
Michael Jumper
2015-05-27 13:08:26 -07:00
parent 368ceea080
commit 10aea5d0a3
9 changed files with 88 additions and 15 deletions

View File

@@ -58,12 +58,19 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
*/
public static final String DISABLED_ATTRIBUTE_NAME = "disabled";
/**
* The name of the attribute which controls whether a user's password is
* expired and must be reset upon login.
*/
public static final String EXPIRED_ATTRIBUTE_NAME = "expired";
/**
* All attributes related to restricting user accounts, within a logical
* form.
*/
public static final Form ACCOUNT_RESTRICTIONS = new Form("restrictions", "Account Restrictions", Arrays.asList(
new Field(DISABLED_ATTRIBUTE_NAME, "Disabled", "true")
new Field(DISABLED_ATTRIBUTE_NAME, "Disabled", "true"),
new Field(EXPIRED_ATTRIBUTE_NAME, "Password expired", "true")
));
/**
@@ -214,7 +221,10 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
Map<String, String> attributes = new HashMap<String, String>();
// Set disabled attribute
attributes.put("disabled", getModel().isDisabled() ? "true" : null);
attributes.put(DISABLED_ATTRIBUTE_NAME, getModel().isDisabled() ? "true" : null);
// Set password expired attribute
attributes.put(EXPIRED_ATTRIBUTE_NAME, getModel().isExpired() ? "true" : null);
return attributes;
}
@@ -223,7 +233,10 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
public void setAttributes(Map<String, String> attributes) {
// Translate disabled attribute
getModel().setDisabled("true".equals(attributes.get("disabled")));
getModel().setDisabled("true".equals(attributes.get(DISABLED_ATTRIBUTE_NAME)));
// Translate password expired attribute
getModel().setExpired("true".equals(attributes.get(EXPIRED_ATTRIBUTE_NAME)));
}

View File

@@ -48,6 +48,13 @@ public class UserModel extends ObjectModel {
*/
private boolean disabled;
/**
* Whether the user's password is expired. If a user's password is expired,
* it must be changed immediately upon login, and the account cannot be
* used until this occurs.
*/
private boolean expired;
/**
* Creates a new, empty user.
*/
@@ -127,4 +134,28 @@ public class UserModel extends ObjectModel {
this.disabled = disabled;
}
/**
* Returns whether the user's password has expired. If a user's password is
* expired, it must be immediately changed upon login. A user account with
* an expired password cannot be used until the password has been changed.
*
* @return
* true if the user's password has expired, false otherwise.
*/
public boolean isExpired() {
return expired;
}
/**
* Sets whether the user's password is expired. If a user's password is
* expired, it must be immediately changed upon login. A user account with
* an expired password cannot be used until the password has been changed.
*
* @param expired
* true to expire the user's password, false otherwise.
*/
public void setExpired(boolean expired) {
this.expired = expired;
}
}

View File

@@ -2,6 +2,7 @@
"USER_ATTRIBUTES" : {
"FIELD_HEADER_DISABLED" : "Login disabled:",
"FIELD_HEADER_EXPIRED" : "Password expired:",
"SECTION_HEADER_RESTRICTIONS" : "Account Restrictions"