Skip to content

Commit

Permalink
GUACAMOLE-1479: Merge change to styling of disabled users/groups.
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-jumper authored Jun 21, 2024
2 parents 31d14a2 + 732a4c5 commit 9a8a5f3
Show file tree
Hide file tree
Showing 45 changed files with 266 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ public class ModeledUser extends ModeledPermissions<UserModel> implements User {
*/
private static final Logger logger = LoggerFactory.getLogger(ModeledUser.class);

/**
* The name of the attribute which controls whether a user account is
* disabled.
*/
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.
Expand Down Expand Up @@ -121,7 +115,6 @@ public class ModeledUser extends ModeledPermissions<UserModel> implements User {
* form.
*/
public static final Form ACCOUNT_RESTRICTIONS = new Form("restrictions", Arrays.<Field>asList(
new BooleanField(DISABLED_ATTRIBUTE_NAME, "true"),
new BooleanField(EXPIRED_ATTRIBUTE_NAME, "true"),
new TimeField(ACCESS_WINDOW_START_ATTRIBUTE_NAME),
new TimeField(ACCESS_WINDOW_END_ATTRIBUTE_NAME),
Expand Down Expand Up @@ -149,7 +142,6 @@ public class ModeledUser extends ModeledPermissions<UserModel> implements User {
User.Attribute.EMAIL_ADDRESS,
User.Attribute.ORGANIZATION,
User.Attribute.ORGANIZATIONAL_ROLE,
DISABLED_ATTRIBUTE_NAME,
EXPIRED_ATTRIBUTE_NAME,
ACCESS_WINDOW_START_ATTRIBUTE_NAME,
ACCESS_WINDOW_END_ATTRIBUTE_NAME,
Expand Down Expand Up @@ -281,6 +273,16 @@ public void setPassword(String password) {
userModel.setPasswordDate(new Timestamp(System.currentTimeMillis()));

}

@Override
public boolean isDisabled() {
return getModel().isDisabled();
}

@Override
public void setDisabled(boolean disabled) {
getModel().setDisabled(disabled);
}

/**
* Returns the this user's current password record. If the user is new, this
Expand Down Expand Up @@ -309,9 +311,6 @@ public PasswordRecordModel getPasswordRecord() {
*/
private void putRestrictedAttributes(Map<String, String> attributes) {

// Set disabled attribute
attributes.put(DISABLED_ATTRIBUTE_NAME, getModel().isDisabled() ? "true" : null);

// Set password expired attribute
attributes.put(EXPIRED_ATTRIBUTE_NAME, getModel().isExpired() ? "true" : null);

Expand Down Expand Up @@ -424,10 +423,6 @@ private Time parseTime(String timeString)
*/
private void setRestrictedAttributes(Map<String, String> attributes) {

// Translate disabled attribute
if (attributes.containsKey(DISABLED_ATTRIBUTE_NAME))
getModel().setDisabled("true".equals(attributes.get(DISABLED_ATTRIBUTE_NAME)));

// Translate password expired attribute
if (attributes.containsKey(EXPIRED_ATTRIBUTE_NAME))
getModel().setExpired("true".equals(attributes.get(EXPIRED_ATTRIBUTE_NAME)));
Expand Down Expand Up @@ -737,19 +732,6 @@ public boolean isAccountAccessible() {
return isActive(getAccessWindowStart(), getAccessWindowEnd());
}

/**
* Returns whether this user account has been disabled. The credentials of
* disabled user accounts are treated as invalid, effectively disabling
* that user's access to data for which they would otherwise have
* permission.
*
* @return
* true if this user account has been disabled, false otherwise.
*/
public boolean isDisabled() {
return getModel().isDisabled();
}

/**
* Returns whether this user's password has expired. If a user's password
* is expired, it must be immediately changed upon login. A user account
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,36 +42,17 @@
public class ModeledUserGroup extends ModeledPermissions<UserGroupModel>
implements UserGroup {

/**
* The name of the attribute which controls whether a user group is
* disabled.
*/
public static final String DISABLED_ATTRIBUTE_NAME = "disabled";

/**
* All attributes related to restricting user groups, within a logical
* form.
*/
public static final Form ACCOUNT_RESTRICTIONS = new Form("restrictions", Arrays.<Field>asList(
new BooleanField(DISABLED_ATTRIBUTE_NAME, "true")
));

/**
* All possible attributes of user groups organized as individual,
* logical forms.
*/
public static final Collection<Form> ATTRIBUTES = Collections.unmodifiableCollection(Arrays.asList(
ACCOUNT_RESTRICTIONS
));

public static final Collection<Form> ATTRIBUTES = Collections.emptyList();

/**
* The names of all attributes which are explicitly supported by this
* extension's UserGroup objects.
*/
public static final Set<String> ATTRIBUTE_NAMES =
Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(
DISABLED_ATTRIBUTE_NAME
)));
public static final Set<String> ATTRIBUTE_NAMES = Collections.emptySet();

/**
* Provider for RelatedObjectSets containing the user groups of which this
Expand Down Expand Up @@ -121,6 +102,16 @@ public void init(ModeledAuthenticatedUser currentUser, UserGroupModel model,
super.init(currentUser, model);
this.exposeRestrictedAttributes = exposeRestrictedAttributes;
}

@Override
public boolean isDisabled() {
return getModel().isDisabled();
}

@Override
public void setDisabled(boolean disabled) {
getModel().setDisabled(disabled);
}

/**
* Stores all restricted (privileged) attributes within the given Map,
Expand All @@ -133,9 +124,6 @@ public void init(ModeledAuthenticatedUser currentUser, UserGroupModel model,
*/
private void putRestrictedAttributes(Map<String, String> attributes) {

// Set disabled attribute
attributes.put(DISABLED_ATTRIBUTE_NAME, getModel().isDisabled() ? "true" : null);

}

/**
Expand All @@ -147,9 +135,6 @@ private void putRestrictedAttributes(Map<String, String> attributes) {
*/
private void setRestrictedAttributes(Map<String, String> attributes) {

// Translate disabled attribute
getModel().setDisabled("true".equals(attributes.get(DISABLED_ATTRIBUTE_NAME)));

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@

"USER_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "Inici de sessió desactivat:",
"FIELD_HEADER_EXPIRED" : "Contrasenya caducada:",
"FIELD_HEADER_ACCESS_WINDOW_END" : "No permetre l'accés després:",
"FIELD_HEADER_ACCESS_WINDOW_START" : "Permet l'accés després:",
Expand All @@ -104,8 +103,6 @@

"USER_GROUP_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "Desactivat:",

"SECTION_HEADER_RESTRICTIONS" : "Restriccions de grup"

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@

"USER_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "Login deaktiviert:",
"FIELD_HEADER_EXPIRED" : "Passwort abgelaufen:",
"FIELD_HEADER_ACCESS_WINDOW_END" : "Zugriff nach dieser Uhrzeit nicht mehr erlauben:",
"FIELD_HEADER_ACCESS_WINDOW_START" : "Zugriff erst nach dieser Uhrzeit erlauben:",
Expand All @@ -102,9 +101,7 @@
},

"USER_GROUP_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "Deaktiviert:",


"SECTION_HEADER_RESTRICTIONS" : "Gruppeneinschränkung"

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@

"USER_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "Login disabled:",
"FIELD_HEADER_EXPIRED" : "Password expired:",
"FIELD_HEADER_ACCESS_WINDOW_END" : "Do not allow access after:",
"FIELD_HEADER_ACCESS_WINDOW_START" : "Allow access after:",
Expand All @@ -104,8 +103,6 @@

"USER_GROUP_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "Disabled:",

"SECTION_HEADER_RESTRICTIONS" : "Group Restrictions"

},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@

"USER_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "Inicio de sesión deshabilitado:",
"FIELD_HEADER_EXPIRED" : "Contraseña expirada:",
"FIELD_HEADER_ACCESS_WINDOW_END" : "No permitir acceso despues de:",
"FIELD_HEADER_ACCESS_WINDOW_START" : "Permitir acceso despues de:",
Expand All @@ -104,8 +103,6 @@

"USER_GROUP_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "Deshabilitado:",

"SECTION_HEADER_RESTRICTIONS" : "Restricciones de grupo"

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@

"USER_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "Connexion désactivée:",
"FIELD_HEADER_EXPIRED" : "Mot de passe expiré:",
"FIELD_HEADER_ACCESS_WINDOW_END" : "Ne pas autoriser l'accès après:",
"FIELD_HEADER_ACCESS_WINDOW_START" : "Autoriser l'accès après:",
Expand All @@ -104,8 +103,6 @@

"USER_GROUP_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "Désactivé:",

"SECTION_HEADER_RESTRICTIONS" : "Restrictions de groupe"

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@

"USER_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "ログインの無効化:",

"FIELD_HEADER_EXPIRED" : "パスワード変更の強制:",
"FIELD_HEADER_ACCESS_WINDOW_END" : "指定した時刻からアクセスを禁止する:",
"FIELD_HEADER_ACCESS_WINDOW_START" : "指定した時刻からアクセスを許可する:",
Expand All @@ -90,8 +90,6 @@

"USER_GROUP_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "グループの無効化:",

"SECTION_HEADER_RESTRICTIONS" : "グループ制限"

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@

"USER_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "로그인 비활성화:",
"FIELD_HEADER_EXPIRED" : "비밀번호 만료됨:",
"FIELD_HEADER_ACCESS_WINDOW_END" : "다음 이후에 액세스 허용 안함 :",
"FIELD_HEADER_ACCESS_WINDOW_START" : "다음 이후에 엑세스 허용:",
Expand All @@ -103,8 +102,6 @@

"USER_GROUP_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "비활성화:",

"SECTION_HEADER_RESTRICTIONS" : "그룹 제한"

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@

"USER_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "Logowanie zablokowane:",
"FIELD_HEADER_EXPIRED" : "Hasło wygasło:",
"FIELD_HEADER_ACCESS_WINDOW_END" : "Nie zezwalaj na dostęp po:",
"FIELD_HEADER_ACCESS_WINDOW_START" : "Zezwalaj na dostęp od:",
Expand All @@ -104,8 +103,6 @@

"USER_GROUP_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "Wyłączona:",

"SECTION_HEADER_RESTRICTIONS" : "Ograniczenia Grupy"

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@

"USER_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "Login desativado:",
"FIELD_HEADER_EXPIRED" : "Senha expirada:",
"FIELD_HEADER_ACCESS_WINDOW_END" : "Não permitir acesso após:",
"FIELD_HEADER_ACCESS_WINDOW_START" : "Permitir acesso após:",
Expand All @@ -105,8 +104,6 @@

"USER_GROUP_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "Desativado:",

"SECTION_HEADER_RESTRICTIONS" : "Restrições de Grupo"

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@

"USER_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "Аккаунт отключен:",
"FIELD_HEADER_EXPIRED" : "Пароль просрочен:",
"FIELD_HEADER_ACCESS_WINDOW_END" : "Запретить доступ после:",
"FIELD_HEADER_ACCESS_WINDOW_START" : "Разрешить доступ после:",
Expand All @@ -103,8 +102,6 @@

"USER_GROUP_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "Группа отключена:",

"SECTION_HEADER_RESTRICTIONS" : "Ограничения"

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@

"USER_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "已禁用登录:",
"FIELD_HEADER_EXPIRED" : "密码已过期:",
"FIELD_HEADER_ACCESS_WINDOW_END" : "之后不允许访问:",
"FIELD_HEADER_ACCESS_WINDOW_START" : "之后允许访问:",
Expand All @@ -104,8 +103,6 @@

"USER_GROUP_ATTRIBUTES" : {

"FIELD_HEADER_DISABLED" : "禁用:",

"SECTION_HEADER_RESTRICTIONS" : "组限制"

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* Base implementation of UserGroup which provides default implementations of
* most functions.
*/
public class AbstractUserGroup extends AbstractIdentifiable implements UserGroup {
public abstract class AbstractUserGroup extends AbstractIdentifiable implements UserGroup {

/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ public String getPassword() {
public void setPassword(String password) {
user.setPassword(password);
}

@Override
public boolean isDisabled() {
return user.isDisabled();
}

@Override
public void setDisabled(boolean disabled) {
user.setDisabled(disabled);
}

@Override
public Map<String, String> getAttributes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ public String getIdentifier() {
public void setIdentifier(String identifier) {
userGroup.setIdentifier(identifier);
}

@Override
public boolean isDisabled() {
return userGroup.isDisabled();
}

@Override
public void setDisabled(boolean disabled) {
userGroup.setDisabled(disabled);
}

@Override
public Map<String, String> getAttributes() {
Expand Down
Loading

0 comments on commit 9a8a5f3

Please sign in to comment.