Skip to content

Commit 5778b70

Browse files
committed
GUACAMOLE-1479: Move disabled methods up to new Disableable interface.
1 parent 6145768 commit 5778b70

File tree

6 files changed

+50
-104
lines changed

6 files changed

+50
-104
lines changed

extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharing/user/SharedUser.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -78,28 +78,6 @@ public String getIdentifier() {
7878
public void setIdentifier(String identifier) {
7979
throw new UnsupportedOperationException("Users authenticated via share keys are immutable.");
8080
}
81-
82-
/**
83-
* {@inheritDoc}
84-
*
85-
* <p>SharedUser accounts are always enabled, as access is controlled via
86-
* the shared token.
87-
*/
88-
@Override
89-
public boolean isDisabled() {
90-
return false;
91-
}
92-
93-
/**
94-
* {@inheritDoc}
95-
*
96-
* <p>This method silently ignores the value passed in the disabled parameter,
97-
* as disabling the account is done by invalidating the sharing token.
98-
*/
99-
@Override
100-
public void setDisabled(boolean disabled) {
101-
// Silently ignore the parameter
102-
}
10381

10482
@Override
10583
public Map<String, String> getAttributes() {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.guacamole.net.auth;
21+
22+
/**
23+
* An interface that defines items that can be enabled or disabled.
24+
*/
25+
public interface Disableable {
26+
27+
/**
28+
* Returns true if this object is disabled, otherwise false.
29+
*
30+
* @return
31+
* True if this user account is disabled, otherwise false.
32+
*/
33+
default public boolean isDisabled() {
34+
return false;
35+
}
36+
37+
/**
38+
* Set the disabled status of this object to the boolean value provided,
39+
* true if the object should be disabled, otherwise false.
40+
*
41+
* @param disabled
42+
* True if the object should be disabled, otherwise false.
43+
*/
44+
default public void setDisabled(boolean disabled) {
45+
// Default implementation takes no action.
46+
}
47+
48+
}

guacamole-ext/src/main/java/org/apache/guacamole/net/auth/User.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
/**
3030
* A user of the Guacamole web application.
3131
*/
32-
public interface User extends Identifiable, Attributes, Permissions {
32+
public interface User extends Disableable, Identifiable, Attributes, Permissions {
3333

3434
/**
3535
* All standard attribute names with semantics defined by the Guacamole web
@@ -79,23 +79,6 @@ public static class Attribute {
7979
* @param password The password to set.
8080
*/
8181
public void setPassword(String password);
82-
83-
/**
84-
* Returns true if this user account is disabled, otherwise false.
85-
*
86-
* @return
87-
* True if this user account is disabled, otherwise false.
88-
*/
89-
public boolean isDisabled();
90-
91-
/**
92-
* Set the disabled status of this account to the boolean parameter as
93-
* provided, true if the account should be disabled, otherwise false.
94-
*
95-
* @param disabled
96-
* True if the account should be disabled, otherwise false.
97-
*/
98-
public void setDisabled(boolean disabled);
9982

10083
/**
10184
* Returns the date and time that this user was last active. If the user

guacamole-ext/src/main/java/org/apache/guacamole/net/auth/UserGroup.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,8 @@
2626
* any number of Guacamole users and other user groups, and defines the
2727
* permissions implicitly granted to its members.
2828
*/
29-
public interface UserGroup extends Identifiable, Attributes, Permissions {
29+
public interface UserGroup extends Disableable, Identifiable, Attributes, Permissions {
3030

31-
/**
32-
* Returns true if the user group is disabled, making membership in the group
33-
* ineffective, meaning that any permissions or other group membership
34-
* assigned to this group will not apply to member groups and users.
35-
*
36-
* @return
37-
* True if the group is disabled, otherwise false.
38-
*/
39-
public boolean isDisabled();
40-
41-
/**
42-
* Set the disabled status of the user group, passing a boolean true value
43-
* if the user group should be disabled, otherwise false.
44-
*
45-
* @param disabled
46-
* True if the user group should be disabled, otherwise false.
47-
*/
48-
public void setDisabled(boolean disabled);
49-
5031
/**
5132
* Returns a set of all readable user groups of which this user group is a
5233
* member. If permission is granted for the current user to modify the

guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUser.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,28 +64,6 @@ public SimpleUser() {
6464
public SimpleUser(String username) {
6565
super.setIdentifier(username);
6666
}
67-
68-
/**
69-
* {@inheritDoc}
70-
*
71-
* <p>This User implementation is always enabled, so this method will
72-
* always return false.
73-
*/
74-
@Override
75-
public boolean isDisabled() {
76-
return false;
77-
}
78-
79-
/**
80-
* {@inheritDoc}
81-
*
82-
* <p>This User implementation is always enabled, so this method will
83-
* silently ignore the value passed in under the disabled parameter.
84-
*/
85-
@Override
86-
public void setDisabled(boolean disabled) {
87-
// Silently ignore disabled value
88-
}
8967

9068
/**
9169
* Adds a new READ permission to the given set of permissions for each of

guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUserGroup.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,5 @@ public SimpleUserGroup() {
4343
public SimpleUserGroup(String identifier) {
4444
super.setIdentifier(identifier);
4545
}
46-
47-
/**
48-
* {@inheritDoc}
49-
*
50-
* <p>This implementation of UserGroup is always enabled, so this will
51-
* always return false.
52-
*/
53-
@Override
54-
public boolean isDisabled() {
55-
return false;
56-
}
57-
58-
/**
59-
* {@inheritDoc}
60-
*
61-
* <p>This implementation of UserGroup is always enabled, so this method
62-
* will silently ignore the value passed in the disabled parameter.
63-
*/
64-
@Override
65-
public void setDisabled(boolean disabled) {
66-
// Silently ignore as the UserGroup implementation is always enabled.
67-
}
6846

6947
}

0 commit comments

Comments
 (0)