GUACAMOLE-1479: Implement the disabled methods for User and UserGroup in REST API.

This commit is contained in:
Virtually Nick
2023-03-12 20:49:50 -04:00
parent beacffbfc7
commit 75250148b0
6 changed files with 95 additions and 5 deletions

View File

@@ -43,6 +43,11 @@ public class APIUser {
*/
private String password;
/**
* Boolean value indicating whether or not this user account is disabled.
*/
private boolean disabled;
/**
* Map of all associated attributes by attribute identifier.
*/
@@ -61,7 +66,9 @@ public class APIUser {
/**
* Construct a new APIUser from the provided User.
* @param user The User to construct the APIUser from.
*
* @param user
* The User to construct the APIUser from.
*/
public APIUser(User user) {
@@ -69,6 +76,7 @@ public class APIUser {
this.username = user.getIdentifier();
this.password = user.getPassword();
this.lastActive = user.getLastActive();
this.disabled = user.isDisabled();
// Associate any attributes
this.attributes = user.getAttributes();
@@ -77,7 +85,9 @@ public class APIUser {
/**
* Returns the username for this user.
* @return The username for this user.
*
* @return
* The username for this user.
*/
public String getUsername() {
return username;
@@ -85,7 +95,9 @@ public class APIUser {
/**
* Set the username for this user.
* @param username The username for this user.
*
* @param username
* The username for this user.
*/
public void setUsername(String username) {
this.username = username;
@@ -93,7 +105,9 @@ public class APIUser {
/**
* Returns the password for this user.
* @return The password for this user.
*
* @return
* The password for this user.
*/
public String getPassword() {
return password;
@@ -101,11 +115,34 @@ public class APIUser {
/**
* Set the password for this user.
* @param password The password for this user.
*
* @param password
* The password for this user.
*/
public void setPassword(String password) {
this.password = password;
}
/**
* Returns true if this user account is disabled, otherwise false.
*
* @return
* True if this user account is disabled, otherwise false.
*/
public boolean isDisabled() {
return disabled;
}
/**
* Sets the disabled status of this user account, disabling the account
* if set to true.
*
* @param disabled
* True if this user account should be disabled.
*/
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}
/**
* Returns a map of all attributes associated with this user. Each entry

View File

@@ -69,6 +69,16 @@ public class APIUserWrapper implements User {
public void setPassword(String password) {
apiUser.setPassword(password);
}
@Override
public boolean isDisabled() {
return apiUser.isDisabled();
}
@Override
public void setDisabled(boolean disabled) {
apiUser.setDisabled(disabled);
}
@Override
public Map<String, String> getAttributes() {

View File

@@ -49,6 +49,9 @@ public class UserObjectTranslator
// Do not update the user password if no password was provided
if (object.getPassword() != null)
existingObject.setPassword(object.getPassword());
// Update disabled status
existingObject.setDisabled(object.isDisabled());
// Update user attributes
existingObject.setAttributes(object.getAttributes());

View File

@@ -36,6 +36,11 @@ public class APIUserGroup {
* The identifier of this user group.
*/
private String identifier;
/**
* Boolean value indicating if this UserGroup is disabled.
*/
private boolean disabled;
/**
* Map of all associated attributes by attribute identifier.
@@ -55,6 +60,7 @@ public class APIUserGroup {
*/
public APIUserGroup(UserGroup group) {
this.identifier = group.getIdentifier();
this.disabled = group.isDisabled();
this.attributes = group.getAttributes();
}
@@ -79,6 +85,27 @@ public class APIUserGroup {
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
/**
* Return true if this user group is disabled, otherwise false.
*
* @return
* True if this user group is disabled, otherwise false.
*/
public boolean isDisabled() {
return disabled;
}
/**
* Sets whether or not this user group is disabled to the parameter
* provided.
*
* @param disabled
* True if the user group should be disabled, otherwise false.
*/
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}
/**
* Returns a map of all attributes associated with this user group. Each

View File

@@ -61,6 +61,16 @@ public class APIUserGroupWrapper implements UserGroup {
public void setIdentifier(String identifier) {
apiUserGroup.setIdentifier(identifier);
}
@Override
public boolean isDisabled() {
return apiUserGroup.isDisabled();
}
@Override
public void setDisabled(boolean disabled) {
apiUserGroup.setDisabled(disabled);
}
@Override
public Map<String, String> getAttributes() {

View File

@@ -47,6 +47,9 @@ public class UserGroupObjectTranslator
public void applyExternalChanges(UserGroup existingObject,
APIUserGroup object) throws GuacamoleException {
// Update disabled status
existingObject.setDisabled(object.isDisabled());
// Update user attributes
existingObject.setAttributes(object.getAttributes());