GUACAMOLE-96: Add protected convenience method for retrieving delegate object.

This commit is contained in:
Michael Jumper
2018-10-04 20:02:00 -07:00
parent 7fcb506711
commit 11c1d8c97e
8 changed files with 74 additions and 7 deletions

View File

@@ -41,11 +41,6 @@ public class TOTPUser extends DelegatingUser {
*/
public static final String TOTP_KEY_CONFIRMED_ATTRIBUTE_NAME = "guac-totp-key-confirmed";
/**
* The User object wrapped by this TOTPUser.
*/
private final User undecorated;
/**
* Wraps the given User object, hiding and blocking access to the core
* attributes used by TOTP.
@@ -55,7 +50,6 @@ public class TOTPUser extends DelegatingUser {
*/
public TOTPUser(User user) {
super(user);
this.undecorated = user;
}
/**
@@ -65,7 +59,7 @@ public class TOTPUser extends DelegatingUser {
* The wrapped User object.
*/
public User getUndecorated() {
return undecorated;
return getDelegateUser();
}
@Override

View File

@@ -50,6 +50,16 @@ public class DelegatingConnection implements Connection {
this.connection = connection;
}
/**
* Returns the underlying Connection wrapped by this DelegatingConnection.
*
* @return
* The Connection wrapped by this DelegatingConnection.
*/
protected Connection getDelegateConnection() {
return connection;
}
@Override
public String getIdentifier() {
return connection.getIdentifier();

View File

@@ -47,6 +47,17 @@ public class DelegatingConnectionGroup implements ConnectionGroup {
this.connectionGroup = connectionGroup;
}
/**
* Returns the underlying ConnectionGroup wrapped by this
* DelegatingConnectionGroup.
*
* @return
* The ConnectionGroup wrapped by this DelegatingConnectionGroup.
*/
protected ConnectionGroup getDelegateConnectionGroup() {
return connectionGroup;
}
@Override
public String getIdentifier() {
return connectionGroup.getIdentifier();

View File

@@ -49,6 +49,16 @@ public class DelegatingDirectory<ObjectType extends Identifiable>
this.directory = directory;
}
/**
* Returns the underlying Directory wrapped by this DelegatingDirectory.
*
* @return
* The Directory wrapped by this DelegatingDirectory.
*/
protected Directory<ObjectType> getDelegateDirectory() {
return directory;
}
@Override
public ObjectType get(String identifier) throws GuacamoleException {
return directory.get(identifier);

View File

@@ -43,6 +43,17 @@ public class DelegatingSharingProfile implements SharingProfile {
this.sharingProfile = sharingProfile;
}
/**
* Returns the underlying SharingProfile wrapped by this
* DelegatingSharingProfile.
*
* @return
* The SharingProfile wrapped by this DelegatingSharingProfile.
*/
protected SharingProfile getDelegateSharingProfile() {
return sharingProfile;
}
@Override
public String getIdentifier() {
return sharingProfile.getIdentifier();

View File

@@ -48,6 +48,16 @@ public class DelegatingUser implements User {
this.user = user;
}
/**
* Returns the underlying User wrapped by this DelegatingUser.
*
* @return
* The User wrapped by this DelegatingUser.
*/
protected User getDelegateUser() {
return user;
}
@Override
public String getIdentifier() {
return user.getIdentifier();

View File

@@ -45,6 +45,17 @@ public class DelegatingUserContext implements UserContext {
this.userContext = userContext;
}
/**
* Returns the underlying UserContext wrapped by this
* DelegatingUserContext.
*
* @return
* The UserContext wrapped by this DelegatingUserContext.
*/
protected UserContext getDelegateUserContext() {
return userContext;
}
@Override
public User self() {
return userContext.self();

View File

@@ -46,6 +46,16 @@ public class DelegatingUserGroup implements UserGroup {
this.userGroup = userGroup;
}
/**
* Returns the underlying UserGroup wrapped by this DelegatingUserGroup.
*
* @return
* The UserGroup wrapped by this DelegatingUserGroup.
*/
protected UserGroup getDelegateUserGroupGroup() {
return userGroup;
}
@Override
public String getIdentifier() {
return userGroup.getIdentifier();