GUACAMOLE-1479: Move disabled methods up to new Disableable interface.

This commit is contained in:
Virtually Nick
2023-12-03 08:42:56 -05:00
parent 61457686e3
commit 732a4c5762
6 changed files with 50 additions and 104 deletions

View File

@@ -0,0 +1,48 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.guacamole.net.auth;
/**
* An interface that defines items that can be enabled or disabled.
*/
public interface Disableable {
/**
* Returns true if this object is disabled, otherwise false.
*
* @return
* True if this object is disabled, otherwise false.
*/
default public boolean isDisabled() {
return false;
}
/**
* Set the disabled status of this object to the boolean value provided,
* true if the object should be disabled, otherwise false.
*
* @param disabled
* True if the object should be disabled, otherwise false.
*/
default public void setDisabled(boolean disabled) {
// Default implementation takes no action.
}
}

View File

@@ -29,7 +29,7 @@ import org.apache.guacamole.GuacamoleUnsupportedException;
/**
* A user of the Guacamole web application.
*/
public interface User extends Identifiable, Attributes, Permissions {
public interface User extends Disableable, Identifiable, Attributes, Permissions {
/**
* All standard attribute names with semantics defined by the Guacamole web
@@ -79,23 +79,6 @@ public interface User extends Identifiable, Attributes, Permissions {
* @param password The password to set.
*/
public void setPassword(String password);
/**
* Returns true if this user account is disabled, otherwise false.
*
* @return
* True if this user account is disabled, otherwise false.
*/
public boolean isDisabled();
/**
* Set the disabled status of this account to the boolean parameter as
* provided, true if the account should be disabled, otherwise false.
*
* @param disabled
* True if the account should be disabled, otherwise false.
*/
public void setDisabled(boolean disabled);
/**
* Returns the date and time that this user was last active. If the user

View File

@@ -26,27 +26,8 @@ import org.apache.guacamole.GuacamoleException;
* any number of Guacamole users and other user groups, and defines the
* permissions implicitly granted to its members.
*/
public interface UserGroup extends Identifiable, Attributes, Permissions {
public interface UserGroup extends Disableable, Identifiable, Attributes, Permissions {
/**
* Returns true if the user group is disabled, making membership in the group
* ineffective, meaning that any permissions or other group membership
* assigned to this group will not apply to member groups and users.
*
* @return
* True if the group is disabled, otherwise false.
*/
public boolean isDisabled();
/**
* Set the disabled status of the user group, passing a boolean true value
* if the user group should be disabled, otherwise false.
*
* @param disabled
* True if the user group should be disabled, otherwise false.
*/
public void setDisabled(boolean disabled);
/**
* Returns a set of all readable user groups of which this user group is a
* member. If permission is granted for the current user to modify the

View File

@@ -64,28 +64,6 @@ public class SimpleUser extends AbstractUser {
public SimpleUser(String username) {
super.setIdentifier(username);
}
/**
* {@inheritDoc}
*
* <p>This User implementation is always enabled, so this method will
* always return false.
*/
@Override
public boolean isDisabled() {
return false;
}
/**
* {@inheritDoc}
*
* <p>This User implementation is always enabled, so this method will
* silently ignore the value passed in under the disabled parameter.
*/
@Override
public void setDisabled(boolean disabled) {
// Silently ignore disabled value
}
/**
* Adds a new READ permission to the given set of permissions for each of

View File

@@ -43,27 +43,5 @@ public class SimpleUserGroup extends AbstractUserGroup {
public SimpleUserGroup(String identifier) {
super.setIdentifier(identifier);
}
/**
* {@inheritDoc}
*
* <p>This implementation of UserGroup is always enabled, so this will
* always return false.
*/
@Override
public boolean isDisabled() {
return false;
}
/**
* {@inheritDoc}
*
* <p>This implementation of UserGroup is always enabled, so this method
* will silently ignore the value passed in the disabled parameter.
*/
@Override
public void setDisabled(boolean disabled) {
// Silently ignore as the UserGroup implementation is always enabled.
}
}