diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharing/user/SharedUser.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharing/user/SharedUser.java index 5dcd8740d..80d22198c 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharing/user/SharedUser.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharing/user/SharedUser.java @@ -78,28 +78,6 @@ public class SharedUser implements User { public void setIdentifier(String identifier) { throw new UnsupportedOperationException("Users authenticated via share keys are immutable."); } - - /** - * {@inheritDoc} - * - *

SharedUser accounts are always enabled, as access is controlled via - * the shared token. - */ - @Override - public boolean isDisabled() { - return false; - } - - /** - * {@inheritDoc} - * - *

This method silently ignores the value passed in the disabled parameter, - * as disabling the account is done by invalidating the sharing token. - */ - @Override - public void setDisabled(boolean disabled) { - // Silently ignore the parameter - } @Override public Map getAttributes() { diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/Disableable.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/Disableable.java new file mode 100644 index 000000000..e515bc8ca --- /dev/null +++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/Disableable.java @@ -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. + } + +} diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/User.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/User.java index 9cdec2a07..d658bb08c 100644 --- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/User.java +++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/User.java @@ -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 diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/UserGroup.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/UserGroup.java index cbb26a9e8..840c386f3 100644 --- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/UserGroup.java +++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/UserGroup.java @@ -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 diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUser.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUser.java index 9274ea23f..8e349e27c 100644 --- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUser.java +++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUser.java @@ -64,28 +64,6 @@ public class SimpleUser extends AbstractUser { public SimpleUser(String username) { super.setIdentifier(username); } - - /** - * {@inheritDoc} - * - *

This User implementation is always enabled, so this method will - * always return false. - */ - @Override - public boolean isDisabled() { - return false; - } - - /** - * {@inheritDoc} - * - *

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 diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUserGroup.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUserGroup.java index f06eabfe1..be52d1642 100644 --- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUserGroup.java +++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUserGroup.java @@ -43,27 +43,5 @@ public class SimpleUserGroup extends AbstractUserGroup { public SimpleUserGroup(String identifier) { super.setIdentifier(identifier); } - - /** - * {@inheritDoc} - * - *

This implementation of UserGroup is always enabled, so this will - * always return false. - */ - @Override - public boolean isDisabled() { - return false; - } - - /** - * {@inheritDoc} - * - *

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. - } }