You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2018/04/13 18:36:16 UTC

[1/4] guacamole-client git commit: GUACAMOLE-542: Migrate to simpler AbstractAuthenticationProvider / AbstractUserContext base classes.

Repository: guacamole-client
Updated Branches:
  refs/heads/master 8fb62d128 -> aac9d8795


GUACAMOLE-542: Migrate to simpler AbstractAuthenticationProvider / AbstractUserContext base classes.


Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/9b7ef0df
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/9b7ef0df
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/9b7ef0df

Branch: refs/heads/master
Commit: 9b7ef0dfcf62626857f54a704e7e28acb574d92b
Parents: 18136d5
Author: Michael Jumper <mj...@apache.org>
Authored: Wed Apr 11 17:03:39 2018 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Wed Apr 11 21:29:15 2018 -0700

----------------------------------------------------------------------
 .../auth/cas/CASAuthenticationProvider.java     |  58 +------
 .../auth/duo/DuoAuthenticationProvider.java     |  48 +-----
 .../HTTPHeaderAuthenticationProvider.java       |  58 +------
 .../jdbc/InjectedAuthenticationProvider.java    |  37 +----
 .../jdbc/sharing/user/SharedUserContext.java    |  95 +----------
 .../auth/ldap/LDAPAuthenticationProvider.java   |  42 +----
 .../guacamole/auth/ldap/user/UserContext.java   |  85 +---------
 .../openid/OpenIDAuthenticationProvider.java    |  58 +------
 .../radius/RadiusAuthenticationProvider.java    |  51 +-----
 .../auth/totp/TOTPAuthenticationProvider.java   |  34 +---
 .../auth/AbstractAuthenticationProvider.java    |  81 +++++++++
 .../guacamole/net/auth/AbstractUserContext.java | 126 ++++++++++++++
 .../simple/SimpleAuthenticationProvider.java    |  49 +-----
 .../net/auth/simple/SimpleDirectory.java        |  29 +++-
 .../net/auth/simple/SimpleUserContext.java      | 166 ++++---------------
 15 files changed, 291 insertions(+), 726 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/9b7ef0df/extensions/guacamole-auth-cas/src/main/java/org/apache/guacamole/auth/cas/CASAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-cas/src/main/java/org/apache/guacamole/auth/cas/CASAuthenticationProvider.java b/extensions/guacamole-auth-cas/src/main/java/org/apache/guacamole/auth/cas/CASAuthenticationProvider.java
index 5c80bca..ed51a31 100644
--- a/extensions/guacamole-auth-cas/src/main/java/org/apache/guacamole/auth/cas/CASAuthenticationProvider.java
+++ b/extensions/guacamole-auth-cas/src/main/java/org/apache/guacamole/auth/cas/CASAuthenticationProvider.java
@@ -22,10 +22,9 @@ package org.apache.guacamole.auth.cas;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import org.apache.guacamole.GuacamoleException;
+import org.apache.guacamole.net.auth.AbstractAuthenticationProvider;
 import org.apache.guacamole.net.auth.AuthenticatedUser;
-import org.apache.guacamole.net.auth.AuthenticationProvider;
 import org.apache.guacamole.net.auth.Credentials;
-import org.apache.guacamole.net.auth.UserContext;
 
 /**
  * Guacamole authentication backend which authenticates users using an
@@ -33,7 +32,7 @@ import org.apache.guacamole.net.auth.UserContext;
  * provided - only authentication. Storage must be provided by some other
  * extension.
  */
-public class CASAuthenticationProvider implements AuthenticationProvider {
+public class CASAuthenticationProvider extends AbstractAuthenticationProvider {
 
     /**
      * Injector which will manage the object graph of this authentication
@@ -64,11 +63,6 @@ public class CASAuthenticationProvider implements AuthenticationProvider {
     }
 
     @Override
-    public Object getResource() throws GuacamoleException {
-        return null;
-    }
-
-    @Override
     public AuthenticatedUser authenticateUser(Credentials credentials)
             throws GuacamoleException {
 
@@ -78,52 +72,4 @@ public class CASAuthenticationProvider implements AuthenticationProvider {
 
     }
 
-    @Override
-    public AuthenticatedUser updateAuthenticatedUser(
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-
-        // No update necessary
-        return authenticatedUser;
-
-    }
-
-    @Override
-    public UserContext getUserContext(AuthenticatedUser authenticatedUser)
-            throws GuacamoleException {
-
-        // No associated data whatsoever
-        return null;
-
-    }
-
-    @Override
-    public UserContext updateUserContext(UserContext context,
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-
-        // No update necessary
-        return context;
-
-    }
-
-    @Override
-    public UserContext decorate(UserContext context,
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-        return context;
-    }
-
-    @Override
-    public UserContext redecorate(UserContext decorated, UserContext context,
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-        return context;
-    }
-
-    @Override
-    public void shutdown() {
-        // Do nothing
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/9b7ef0df/extensions/guacamole-auth-duo/src/main/java/org/apache/guacamole/auth/duo/DuoAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-duo/src/main/java/org/apache/guacamole/auth/duo/DuoAuthenticationProvider.java b/extensions/guacamole-auth-duo/src/main/java/org/apache/guacamole/auth/duo/DuoAuthenticationProvider.java
index 7d27a75..0b1a33d 100644
--- a/extensions/guacamole-auth-duo/src/main/java/org/apache/guacamole/auth/duo/DuoAuthenticationProvider.java
+++ b/extensions/guacamole-auth-duo/src/main/java/org/apache/guacamole/auth/duo/DuoAuthenticationProvider.java
@@ -22,9 +22,8 @@ package org.apache.guacamole.auth.duo;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import org.apache.guacamole.GuacamoleException;
+import org.apache.guacamole.net.auth.AbstractAuthenticationProvider;
 import org.apache.guacamole.net.auth.AuthenticatedUser;
-import org.apache.guacamole.net.auth.AuthenticationProvider;
-import org.apache.guacamole.net.auth.Credentials;
 import org.apache.guacamole.net.auth.UserContext;
 
 /**
@@ -32,7 +31,7 @@ import org.apache.guacamole.net.auth.UserContext;
  * authentication factor for users which have already been authenticated by
  * some other AuthenticationProvider.
  */
-public class DuoAuthenticationProvider implements AuthenticationProvider {
+public class DuoAuthenticationProvider extends AbstractAuthenticationProvider {
 
     /**
      * Injector which will manage the object graph of this authentication
@@ -63,23 +62,6 @@ public class DuoAuthenticationProvider implements AuthenticationProvider {
     }
 
     @Override
-    public Object getResource() {
-        return null;
-    }
-
-    @Override
-    public AuthenticatedUser authenticateUser(Credentials credentials)
-            throws GuacamoleException {
-        return null;
-    }
-
-    @Override
-    public AuthenticatedUser updateAuthenticatedUser(AuthenticatedUser authenticatedUser,
-            Credentials credentials) throws GuacamoleException {
-        return authenticatedUser;
-    }
-
-    @Override
     public UserContext getUserContext(AuthenticatedUser authenticatedUser)
             throws GuacamoleException {
 
@@ -95,30 +77,4 @@ public class DuoAuthenticationProvider implements AuthenticationProvider {
 
     }
 
-    @Override
-    public UserContext updateUserContext(UserContext context,
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-                throws GuacamoleException {
-        return context;
-    }
-
-    @Override
-    public UserContext decorate(UserContext context,
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-        return context;
-    }
-
-    @Override
-    public UserContext redecorate(UserContext decorated, UserContext context,
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-        return context;
-    }
-
-    @Override
-    public void shutdown() {
-        // Do nothing
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/9b7ef0df/extensions/guacamole-auth-header/src/main/java/org/apache/guacamole/auth/header/HTTPHeaderAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-header/src/main/java/org/apache/guacamole/auth/header/HTTPHeaderAuthenticationProvider.java b/extensions/guacamole-auth-header/src/main/java/org/apache/guacamole/auth/header/HTTPHeaderAuthenticationProvider.java
index ca19b39..5478ea5 100644
--- a/extensions/guacamole-auth-header/src/main/java/org/apache/guacamole/auth/header/HTTPHeaderAuthenticationProvider.java
+++ b/extensions/guacamole-auth-header/src/main/java/org/apache/guacamole/auth/header/HTTPHeaderAuthenticationProvider.java
@@ -22,10 +22,9 @@ package org.apache.guacamole.auth.header;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import org.apache.guacamole.GuacamoleException;
+import org.apache.guacamole.net.auth.AbstractAuthenticationProvider;
 import org.apache.guacamole.net.auth.AuthenticatedUser;
-import org.apache.guacamole.net.auth.AuthenticationProvider;
 import org.apache.guacamole.net.auth.Credentials;
-import org.apache.guacamole.net.auth.UserContext;
 
 /**
  * Guacamole authentication backend which authenticates users using an
@@ -33,7 +32,7 @@ import org.apache.guacamole.net.auth.UserContext;
  * provided - only authentication. Storage must be provided by some other
  * extension.
  */
-public class HTTPHeaderAuthenticationProvider implements AuthenticationProvider {
+public class HTTPHeaderAuthenticationProvider extends AbstractAuthenticationProvider {
 
     /**
      * Injector which will manage the object graph of this authentication
@@ -64,11 +63,6 @@ public class HTTPHeaderAuthenticationProvider implements AuthenticationProvider
     }
 
     @Override
-    public Object getResource() {
-        return null;
-    }
-
-    @Override
     public AuthenticatedUser authenticateUser(Credentials credentials)
             throws GuacamoleException {
 
@@ -78,52 +72,4 @@ public class HTTPHeaderAuthenticationProvider implements AuthenticationProvider
 
     }
 
-    @Override
-    public AuthenticatedUser updateAuthenticatedUser(
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-
-        // No update necessary
-        return authenticatedUser;
-
-    }
-
-    @Override
-    public UserContext getUserContext(AuthenticatedUser authenticatedUser)
-            throws GuacamoleException {
-
-        // No associated data whatsoever
-        return null;
-
-    }
-
-    @Override
-    public UserContext updateUserContext(UserContext context,
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-
-        // No update necessary
-        return context;
-
-    }
-
-    @Override
-    public UserContext decorate(UserContext context,
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-        return context;
-    }
-
-    @Override
-    public UserContext redecorate(UserContext decorated, UserContext context,
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-        return context;
-    }
-
-    @Override
-    public void shutdown() {
-        // Do nothing
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/9b7ef0df/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/InjectedAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/InjectedAuthenticationProvider.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/InjectedAuthenticationProvider.java
index 0e3e84b..fddb204 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/InjectedAuthenticationProvider.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/InjectedAuthenticationProvider.java
@@ -21,7 +21,7 @@ package org.apache.guacamole.auth.jdbc;
 
 import com.google.inject.Injector;
 import org.apache.guacamole.GuacamoleException;
-import org.apache.guacamole.net.auth.AuthenticationProvider;
+import org.apache.guacamole.net.auth.AbstractAuthenticationProvider;
 import org.apache.guacamole.net.auth.Credentials;
 import org.apache.guacamole.net.auth.UserContext;
 import org.apache.guacamole.net.auth.AuthenticatedUser;
@@ -34,7 +34,7 @@ import org.apache.guacamole.net.auth.AuthenticatedUser;
  * AuthenticationProvider, even though it is the AuthenticationProvider that
  * serves as the entry point.
  */
-public abstract class InjectedAuthenticationProvider implements AuthenticationProvider {
+public abstract class InjectedAuthenticationProvider extends AbstractAuthenticationProvider {
 
     /**
      * The AuthenticationProviderService to which all AuthenticationProvider
@@ -71,26 +71,12 @@ public abstract class InjectedAuthenticationProvider implements AuthenticationPr
     }
 
     @Override
-    public Object getResource() throws GuacamoleException {
-        return null;
-    }
-
-    @Override
     public AuthenticatedUser authenticateUser(Credentials credentials)
             throws GuacamoleException {
         return authProviderService.authenticateUser(this, credentials);
     }
 
     @Override
-    public AuthenticatedUser updateAuthenticatedUser(AuthenticatedUser authenticatedUser,
-            Credentials credentials) throws GuacamoleException {
-
-        // No need to update authenticated users
-        return authenticatedUser;
-
-    }
-
-    @Override
     public UserContext getUserContext(AuthenticatedUser authenticatedUser)
             throws GuacamoleException {
         return authProviderService.getUserContext(this, authenticatedUser);
@@ -104,23 +90,4 @@ public abstract class InjectedAuthenticationProvider implements AuthenticationPr
                 authenticatedUser, credentials);
     }
 
-    @Override
-    public UserContext decorate(UserContext context,
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-        return context;
-    }
-
-    @Override
-    public UserContext redecorate(UserContext decorated, UserContext context,
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-        return context;
-    }
-
-    @Override
-    public void shutdown() {
-        // Do nothing
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/9b7ef0df/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharing/user/SharedUserContext.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharing/user/SharedUserContext.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharing/user/SharedUserContext.java
index 4bc54b5..3950007 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharing/user/SharedUserContext.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharing/user/SharedUserContext.java
@@ -20,27 +20,16 @@
 package org.apache.guacamole.auth.jdbc.sharing.user;
 
 import com.google.inject.Inject;
-import java.util.Collection;
-import java.util.Collections;
 import org.apache.guacamole.GuacamoleException;
 import org.apache.guacamole.auth.jdbc.sharing.connection.SharedConnectionDirectory;
 import org.apache.guacamole.auth.jdbc.sharing.connectiongroup.SharedRootConnectionGroup;
 import org.apache.guacamole.auth.jdbc.user.RemoteAuthenticatedUser;
-import org.apache.guacamole.form.Form;
-import org.apache.guacamole.net.auth.ActiveConnection;
-import org.apache.guacamole.net.auth.ActivityRecord;
-import org.apache.guacamole.net.auth.ActivityRecordSet;
+import org.apache.guacamole.net.auth.AbstractUserContext;
 import org.apache.guacamole.net.auth.AuthenticationProvider;
 import org.apache.guacamole.net.auth.Connection;
 import org.apache.guacamole.net.auth.ConnectionGroup;
-import org.apache.guacamole.net.auth.ConnectionRecord;
 import org.apache.guacamole.net.auth.Directory;
-import org.apache.guacamole.net.auth.SharingProfile;
 import org.apache.guacamole.net.auth.User;
-import org.apache.guacamole.net.auth.UserContext;
-import org.apache.guacamole.net.auth.simple.SimpleActivityRecordSet;
-import org.apache.guacamole.net.auth.simple.SimpleConnectionGroupDirectory;
-import org.apache.guacamole.net.auth.simple.SimpleDirectory;
 
 /**
  * The user context of a SharedUser, providing access ONLY to the user
@@ -48,7 +37,7 @@ import org.apache.guacamole.net.auth.simple.SimpleDirectory;
  * keys, and an internal root connection group containing only those
  * connections.
  */
-public class SharedUserContext implements UserContext {
+public class SharedUserContext extends AbstractUserContext {
 
     /**
      * The AuthenticationProvider that created this SharedUserContext.
@@ -68,18 +57,6 @@ public class SharedUserContext implements UserContext {
     private SharedConnectionDirectory connectionDirectory;
 
     /**
-     * A directory of all connection groups visible to the user for whom this
-     * user context was created.
-     */
-    private Directory<ConnectionGroup> connectionGroupDirectory;
-
-    /**
-     * A directory of all users visible to the user for whom this user context
-     * was created.
-     */
-    private Directory<User> userDirectory;
-
-    /**
      * The root connection group of the hierarchy containing all connections
      * and connection groups visible to the user for whom this user context was
      * created.
@@ -110,15 +87,10 @@ public class SharedUserContext implements UserContext {
 
         // The connection group directory contains only the root group
         this.rootGroup = new SharedRootConnectionGroup(this);
-        this.connectionGroupDirectory = new SimpleConnectionGroupDirectory(
-                Collections.singletonList(this.rootGroup));
 
         // Create internal pseudo-account representing the authenticated user
         this.self = new SharedUser(user, this);
 
-        // Do not provide access to any user accounts via the directory
-        this.userDirectory = new SimpleDirectory<User>();
-
     }
 
     /**
@@ -139,82 +111,19 @@ public class SharedUserContext implements UserContext {
     }
 
     @Override
-    public Object getResource() throws GuacamoleException {
-        return null;
-    }
-
-    @Override
     public AuthenticationProvider getAuthenticationProvider() {
         return authProvider;
     }
 
     @Override
-    public Directory<User> getUserDirectory() {
-        return userDirectory;
-    }
-
-    @Override
     public Directory<Connection> getConnectionDirectory()
             throws GuacamoleException {
         return connectionDirectory;
     }
 
     @Override
-    public Directory<ConnectionGroup> getConnectionGroupDirectory() {
-        return connectionGroupDirectory;
-    }
-
-    @Override
-    public Directory<ActiveConnection> getActiveConnectionDirectory()
-            throws GuacamoleException {
-        return new SimpleDirectory<ActiveConnection>();
-    }
-
-    @Override
-    public Directory<SharingProfile> getSharingProfileDirectory()
-            throws GuacamoleException {
-        return new SimpleDirectory<SharingProfile>();
-    }
-
-    @Override
-    public ActivityRecordSet<ConnectionRecord> getConnectionHistory() {
-        return new SimpleActivityRecordSet<ConnectionRecord>();
-    }
-
-    @Override
-    public ActivityRecordSet<ActivityRecord> getUserHistory()
-            throws GuacamoleException {
-        return new SimpleActivityRecordSet<ActivityRecord>();
-    }
-
-    @Override
     public ConnectionGroup getRootConnectionGroup() {
         return rootGroup;
     }
 
-    @Override
-    public Collection<Form> getUserAttributes() {
-        return Collections.<Form>emptyList();
-    }
-
-    @Override
-    public Collection<Form> getConnectionAttributes() {
-        return Collections.<Form>emptyList();
-    }
-
-    @Override
-    public Collection<Form> getConnectionGroupAttributes() {
-        return Collections.<Form>emptyList();
-    }
-
-    @Override
-    public Collection<Form> getSharingProfileAttributes() {
-        return Collections.<Form>emptyList();
-    }
-
-    @Override
-    public void invalidate() {
-        // Nothing to invalidate
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/9b7ef0df/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/LDAPAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/LDAPAuthenticationProvider.java b/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/LDAPAuthenticationProvider.java
index 2d8dfd7..31aa4e2 100644
--- a/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/LDAPAuthenticationProvider.java
+++ b/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/LDAPAuthenticationProvider.java
@@ -23,8 +23,8 @@ package org.apache.guacamole.auth.ldap;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import org.apache.guacamole.GuacamoleException;
+import org.apache.guacamole.net.auth.AbstractAuthenticationProvider;
 import org.apache.guacamole.net.auth.AuthenticatedUser;
-import org.apache.guacamole.net.auth.AuthenticationProvider;
 import org.apache.guacamole.net.auth.Credentials;
 import org.apache.guacamole.net.auth.UserContext;
 
@@ -33,7 +33,7 @@ import org.apache.guacamole.net.auth.UserContext;
  * any number of authorized configurations. Authorized configurations may be
  * shared.
  */
-public class LDAPAuthenticationProvider implements AuthenticationProvider {
+public class LDAPAuthenticationProvider extends AbstractAuthenticationProvider {
 
     /**
      * The identifier reserved for the root connection group.
@@ -69,11 +69,6 @@ public class LDAPAuthenticationProvider implements AuthenticationProvider {
     }
 
     @Override
-    public String getResource() {
-        return null;
-    }
-
-    @Override
     public AuthenticatedUser authenticateUser(Credentials credentials) throws GuacamoleException {
 
         AuthenticationProviderService authProviderService = injector.getInstance(AuthenticationProviderService.class);
@@ -82,12 +77,6 @@ public class LDAPAuthenticationProvider implements AuthenticationProvider {
     }
 
     @Override
-    public AuthenticatedUser updateAuthenticatedUser(AuthenticatedUser authenticatedUser,
-            Credentials credentials) throws GuacamoleException {
-        return authenticatedUser;
-    }
-
-    @Override
     public UserContext getUserContext(AuthenticatedUser authenticatedUser)
             throws GuacamoleException {
 
@@ -96,31 +85,4 @@ public class LDAPAuthenticationProvider implements AuthenticationProvider {
 
     }
 
-    @Override
-    public UserContext updateUserContext(UserContext context,
-            AuthenticatedUser authenticatedUser,
-            Credentials credentials) throws GuacamoleException {
-        return context;
-    }
-
-    @Override
-    public UserContext decorate(UserContext context,
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-        return context;
-    }
-
-    @Override
-    public UserContext redecorate(UserContext decorated, UserContext context,
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-        return context;
-    }
-
-    @Override
-    public void shutdown() {
-        // Do nothing
-    }
-
 }
-

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/9b7ef0df/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/user/UserContext.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/user/UserContext.java b/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/user/UserContext.java
index 5e19dca..26ea6b3 100644
--- a/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/user/UserContext.java
+++ b/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/user/UserContext.java
@@ -21,26 +21,18 @@ package org.apache.guacamole.auth.ldap.user;
 
 import com.google.inject.Inject;
 import com.novell.ldap.LDAPConnection;
-import java.util.Collection;
 import java.util.Collections;
-import org.apache.guacamole.auth.ldap.LDAPAuthenticationProvider;
 import org.apache.guacamole.auth.ldap.connection.ConnectionService;
 import org.apache.guacamole.GuacamoleException;
-import org.apache.guacamole.form.Form;
-import org.apache.guacamole.net.auth.ActiveConnection;
-import org.apache.guacamole.net.auth.ActivityRecord;
-import org.apache.guacamole.net.auth.ActivityRecordSet;
+import org.apache.guacamole.auth.ldap.LDAPAuthenticationProvider;
+import org.apache.guacamole.net.auth.AbstractUserContext;
 import org.apache.guacamole.net.auth.AuthenticatedUser;
 import org.apache.guacamole.net.auth.AuthenticationProvider;
 import org.apache.guacamole.net.auth.Connection;
 import org.apache.guacamole.net.auth.ConnectionGroup;
-import org.apache.guacamole.net.auth.ConnectionRecord;
 import org.apache.guacamole.net.auth.Directory;
-import org.apache.guacamole.net.auth.SharingProfile;
 import org.apache.guacamole.net.auth.User;
-import org.apache.guacamole.net.auth.simple.SimpleActivityRecordSet;
 import org.apache.guacamole.net.auth.simple.SimpleConnectionGroup;
-import org.apache.guacamole.net.auth.simple.SimpleConnectionGroupDirectory;
 import org.apache.guacamole.net.auth.simple.SimpleDirectory;
 import org.apache.guacamole.net.auth.simple.SimpleUser;
 import org.slf4j.Logger;
@@ -50,7 +42,7 @@ import org.slf4j.LoggerFactory;
  * An LDAP-specific implementation of UserContext which queries all Guacamole
  * connections and users from the LDAP directory.
  */
-public class UserContext implements org.apache.guacamole.net.auth.UserContext {
+public class UserContext extends AbstractUserContext {
 
     /**
      * Logger for this class.
@@ -95,12 +87,6 @@ public class UserContext implements org.apache.guacamole.net.auth.UserContext {
     private Directory<Connection> connectionDirectory;
 
     /**
-     * Directory containing all ConnectionGroup objects accessible to the user
-     * associated with this UserContext.
-     */
-    private Directory<ConnectionGroup> connectionGroupDirectory;
-
-    /**
      * Reference to the root connection group.
      */
     private ConnectionGroup rootGroup;
@@ -143,15 +129,12 @@ public class UserContext implements org.apache.guacamole.net.auth.UserContext {
             Collections.<String>emptyList()
         );
 
-        // Expose only the root group in the connection group directory
-        connectionGroupDirectory = new SimpleConnectionGroupDirectory(Collections.singleton(rootGroup));
-
         // Init self with basic permissions
         self = new SimpleUser(
             user.getIdentifier(),
             userDirectory.getIdentifiers(),
             connectionDirectory.getIdentifiers(),
-            connectionGroupDirectory.getIdentifiers()
+            Collections.singleton(LDAPAuthenticationProvider.ROOT_CONNECTION_GROUP)
         );
 
     }
@@ -162,11 +145,6 @@ public class UserContext implements org.apache.guacamole.net.auth.UserContext {
     }
 
     @Override
-    public String getResource() {
-        return null;
-    }
-
-    @Override
     public AuthenticationProvider getAuthenticationProvider() {
         return authProvider;
     }
@@ -183,63 +161,8 @@ public class UserContext implements org.apache.guacamole.net.auth.UserContext {
     }
 
     @Override
-    public Directory<ConnectionGroup> getConnectionGroupDirectory()
-            throws GuacamoleException {
-        return connectionGroupDirectory;
-    }
-
-    @Override
     public ConnectionGroup getRootConnectionGroup() throws GuacamoleException {
         return rootGroup;
     }
 
-    @Override
-    public Directory<ActiveConnection> getActiveConnectionDirectory()
-            throws GuacamoleException {
-        return new SimpleDirectory<ActiveConnection>();
-    }
-
-    @Override
-    public Directory<SharingProfile> getSharingProfileDirectory()
-            throws GuacamoleException {
-        return new SimpleDirectory<SharingProfile>();
-    }
-
-    @Override
-    public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
-            throws GuacamoleException {
-        return new SimpleActivityRecordSet<ConnectionRecord>();
-    }
-
-    @Override
-    public ActivityRecordSet<ActivityRecord> getUserHistory()
-            throws GuacamoleException {
-        return new SimpleActivityRecordSet<ActivityRecord>();
-    }
-
-    @Override
-    public Collection<Form> getUserAttributes() {
-        return Collections.<Form>emptyList();
-    }
-
-    @Override
-    public Collection<Form> getConnectionAttributes() {
-        return Collections.<Form>emptyList();
-    }
-
-    @Override
-    public Collection<Form> getConnectionGroupAttributes() {
-        return Collections.<Form>emptyList();
-    }
-
-    @Override
-    public Collection<Form> getSharingProfileAttributes() {
-        return Collections.<Form>emptyList();
-    }
-
-    @Override
-    public void invalidate() {
-        // Nothing to invalidate
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/9b7ef0df/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/openid/OpenIDAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/openid/OpenIDAuthenticationProvider.java b/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/openid/OpenIDAuthenticationProvider.java
index cf0b96e..04a372e 100644
--- a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/openid/OpenIDAuthenticationProvider.java
+++ b/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/openid/OpenIDAuthenticationProvider.java
@@ -22,10 +22,9 @@ package org.apache.guacamole.auth.openid;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import org.apache.guacamole.GuacamoleException;
+import org.apache.guacamole.net.auth.AbstractAuthenticationProvider;
 import org.apache.guacamole.net.auth.AuthenticatedUser;
-import org.apache.guacamole.net.auth.AuthenticationProvider;
 import org.apache.guacamole.net.auth.Credentials;
-import org.apache.guacamole.net.auth.UserContext;
 
 /**
  * Guacamole authentication backend which authenticates users using an
@@ -33,7 +32,7 @@ import org.apache.guacamole.net.auth.UserContext;
  * provided - only authentication. Storage must be provided by some other
  * extension.
  */
-public class OpenIDAuthenticationProvider implements AuthenticationProvider {
+public class OpenIDAuthenticationProvider extends AbstractAuthenticationProvider {
 
     /**
      * Injector which will manage the object graph of this authentication
@@ -64,11 +63,6 @@ public class OpenIDAuthenticationProvider implements AuthenticationProvider {
     }
 
     @Override
-    public Object getResource() throws GuacamoleException {
-        return null;
-    }
-
-    @Override
     public AuthenticatedUser authenticateUser(Credentials credentials)
             throws GuacamoleException {
 
@@ -78,52 +72,4 @@ public class OpenIDAuthenticationProvider implements AuthenticationProvider {
 
     }
 
-    @Override
-    public AuthenticatedUser updateAuthenticatedUser(
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-
-        // No update necessary
-        return authenticatedUser;
-
-    }
-
-    @Override
-    public UserContext getUserContext(AuthenticatedUser authenticatedUser)
-            throws GuacamoleException {
-
-        // No associated data whatsoever
-        return null;
-
-    }
-
-    @Override
-    public UserContext updateUserContext(UserContext context,
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-
-        // No update necessary
-        return context;
-
-    }
-
-    @Override
-    public UserContext decorate(UserContext context,
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-        return context;
-    }
-
-    @Override
-    public UserContext redecorate(UserContext decorated, UserContext context,
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-        return context;
-    }
-
-    @Override
-    public void shutdown() {
-        // Do nothing
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/9b7ef0df/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/RadiusAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/RadiusAuthenticationProvider.java b/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/RadiusAuthenticationProvider.java
index 02c23de..49d84bb 100644
--- a/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/RadiusAuthenticationProvider.java
+++ b/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/RadiusAuthenticationProvider.java
@@ -23,17 +23,16 @@ package org.apache.guacamole.auth.radius;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import org.apache.guacamole.GuacamoleException;
+import org.apache.guacamole.net.auth.AbstractAuthenticationProvider;
 import org.apache.guacamole.net.auth.AuthenticatedUser;
-import org.apache.guacamole.net.auth.AuthenticationProvider;
 import org.apache.guacamole.net.auth.Credentials;
-import org.apache.guacamole.net.auth.UserContext;
 
 /**
  * Allows users to be authenticated against an RADIUS server. Each user may have
  * any number of authorized configurations. Authorized configurations may be
  * shared.
  */
-public class RadiusAuthenticationProvider implements AuthenticationProvider {
+public class RadiusAuthenticationProvider extends AbstractAuthenticationProvider {
 
     /**
      * Injector which will manage the object graph of this authentication
@@ -64,30 +63,6 @@ public class RadiusAuthenticationProvider implements AuthenticationProvider {
     }
 
     @Override
-    public Object getResource() throws GuacamoleException {
-        return null;
-    }
-
-    @Override
-    public UserContext decorate(UserContext context,
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-        return context;
-    }
-
-    @Override
-    public UserContext redecorate(UserContext decorated, UserContext context,
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-        return context;
-    }
-
-    @Override
-    public void shutdown() {
-        // Do nothing
-    }
-
-    @Override
     public AuthenticatedUser authenticateUser(Credentials credentials) throws GuacamoleException {
 
         AuthenticationProviderService authProviderService = injector.getInstance(AuthenticationProviderService.class);
@@ -95,26 +70,4 @@ public class RadiusAuthenticationProvider implements AuthenticationProvider {
 
     }
 
-    @Override
-    public AuthenticatedUser updateAuthenticatedUser(AuthenticatedUser authenticatedUser,
-            Credentials credentials) throws GuacamoleException {
-        return authenticatedUser;
-    }
-
-    @Override
-    public UserContext getUserContext(AuthenticatedUser authenticatedUser)
-            throws GuacamoleException {
-
-        return null;
-
-    }
-
-    @Override
-    public UserContext updateUserContext(UserContext context,
-            AuthenticatedUser authenticatedUser,
-            Credentials credentials) throws GuacamoleException {
-        return context;
-    }
-
 }
-

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/9b7ef0df/extensions/guacamole-auth-totp/src/main/java/org/apache/guacamole/auth/totp/TOTPAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-totp/src/main/java/org/apache/guacamole/auth/totp/TOTPAuthenticationProvider.java b/extensions/guacamole-auth-totp/src/main/java/org/apache/guacamole/auth/totp/TOTPAuthenticationProvider.java
index 4f18304..0b91558 100644
--- a/extensions/guacamole-auth-totp/src/main/java/org/apache/guacamole/auth/totp/TOTPAuthenticationProvider.java
+++ b/extensions/guacamole-auth-totp/src/main/java/org/apache/guacamole/auth/totp/TOTPAuthenticationProvider.java
@@ -25,8 +25,8 @@ import com.google.inject.Injector;
 import org.apache.guacamole.GuacamoleException;
 import org.apache.guacamole.auth.totp.user.CodeUsageTrackingService;
 import org.apache.guacamole.auth.totp.user.TOTPUserContext;
+import org.apache.guacamole.net.auth.AbstractAuthenticationProvider;
 import org.apache.guacamole.net.auth.AuthenticatedUser;
-import org.apache.guacamole.net.auth.AuthenticationProvider;
 import org.apache.guacamole.net.auth.Credentials;
 import org.apache.guacamole.net.auth.UserContext;
 
@@ -35,7 +35,7 @@ import org.apache.guacamole.net.auth.UserContext;
  * authentication factor for users which have already been authenticated by
  * some other AuthenticationProvider.
  */
-public class TOTPAuthenticationProvider implements AuthenticationProvider {
+public class TOTPAuthenticationProvider extends AbstractAuthenticationProvider {
 
     /**
      * Injector which will manage the object graph of this authentication
@@ -65,36 +65,6 @@ public class TOTPAuthenticationProvider implements AuthenticationProvider {
     }
 
     @Override
-    public Object getResource() {
-        return null;
-    }
-
-    @Override
-    public AuthenticatedUser authenticateUser(Credentials credentials)
-            throws GuacamoleException {
-        return null;
-    }
-
-    @Override
-    public AuthenticatedUser updateAuthenticatedUser(AuthenticatedUser authenticatedUser,
-            Credentials credentials) throws GuacamoleException {
-        return authenticatedUser;
-    }
-
-    @Override
-    public UserContext getUserContext(AuthenticatedUser authenticatedUser)
-            throws GuacamoleException {
-        return null;
-    }
-
-    @Override
-    public UserContext updateUserContext(UserContext context,
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-                throws GuacamoleException {
-        return context;
-    }
-
-    @Override
     public UserContext decorate(UserContext context,
             AuthenticatedUser authenticatedUser, Credentials credentials)
             throws GuacamoleException {

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/9b7ef0df/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AbstractAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AbstractAuthenticationProvider.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AbstractAuthenticationProvider.java
new file mode 100644
index 0000000..991f6a8
--- /dev/null
+++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AbstractAuthenticationProvider.java
@@ -0,0 +1,81 @@
+/*
+ * 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;
+
+import org.apache.guacamole.GuacamoleException;
+
+/**
+ * Base implementation of AuthenticationProvider which provides default
+ * implementations of most functions. Implementations must provide their
+ * own {@link getIdentifier()}, but otherwise need only override an implemented
+ * function if they wish to actually implement the functionality defined for
+ * that function by the AuthenticationProvider interface.
+ */
+public abstract class AbstractAuthenticationProvider implements AuthenticationProvider {
+
+    @Override
+    public Object getResource() throws GuacamoleException {
+        return null;
+    }
+
+    @Override
+    public AuthenticatedUser authenticateUser(Credentials credentials)
+            throws GuacamoleException {
+        return null;
+    }
+
+    @Override
+    public AuthenticatedUser updateAuthenticatedUser(AuthenticatedUser authenticatedUser,
+            Credentials credentials) throws GuacamoleException {
+        return authenticatedUser;
+    }
+
+    @Override
+    public UserContext getUserContext(AuthenticatedUser authenticatedUser)
+            throws GuacamoleException {
+        return null;
+    }
+
+    @Override
+    public UserContext updateUserContext(UserContext context,
+            AuthenticatedUser authenticatedUser,
+            Credentials credentials) throws GuacamoleException {
+        return context;
+    }
+
+    @Override
+    public UserContext decorate(UserContext context,
+            AuthenticatedUser authenticatedUser,
+            Credentials credentials) throws GuacamoleException {
+        return context;
+    }
+
+    @Override
+    public UserContext redecorate(UserContext decorated, UserContext context,
+            AuthenticatedUser authenticatedUser,
+            Credentials credentials) throws GuacamoleException {
+        return decorate(context, authenticatedUser, credentials);
+    }
+
+    @Override
+    public void shutdown() {
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/9b7ef0df/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AbstractUserContext.java
----------------------------------------------------------------------
diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AbstractUserContext.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AbstractUserContext.java
new file mode 100644
index 0000000..25db3d5
--- /dev/null
+++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AbstractUserContext.java
@@ -0,0 +1,126 @@
+/*
+ * 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;
+
+import java.util.Collection;
+import java.util.Collections;
+import org.apache.guacamole.GuacamoleException;
+import org.apache.guacamole.form.Form;
+import org.apache.guacamole.net.auth.simple.SimpleActivityRecordSet;
+import org.apache.guacamole.net.auth.simple.SimpleConnectionGroup;
+import org.apache.guacamole.net.auth.simple.SimpleDirectory;
+
+/**
+ * Base implementation of UserContext which provides default implementations of
+ * most functions. Implementations must provide their own {@link self()} and
+ * {@link getAuthenticationProvider()}, but otherwise need only override an
+ * implemented function if they wish to actually implement the functionality
+ * defined for that function by the UserContext interface.
+ */
+public abstract class AbstractUserContext implements UserContext {
+
+    /**
+     * The unique identifier that will be used for the root connection group if
+     * {@link #getRootConnectionGroup()} is not overridden.
+     */
+    protected static final String DEFAULT_ROOT_CONNECTION_GROUP = "ROOT";
+
+    @Override
+    public Object getResource() throws GuacamoleException {
+        return null;
+    }
+
+    @Override
+    public Directory<User> getUserDirectory() throws GuacamoleException {
+        return new SimpleDirectory<User>(self());
+    }
+
+    @Override
+    public Directory<Connection> getConnectionDirectory()
+            throws GuacamoleException {
+        return new SimpleDirectory<Connection>();
+    }
+
+    @Override
+    public Directory<ConnectionGroup> getConnectionGroupDirectory()
+            throws GuacamoleException {
+        return new SimpleDirectory<ConnectionGroup>(getRootConnectionGroup());
+    }
+
+    @Override
+    public Directory<ActiveConnection> getActiveConnectionDirectory()
+            throws GuacamoleException {
+        return new SimpleDirectory<ActiveConnection>();
+    }
+
+    @Override
+    public Directory<SharingProfile> getSharingProfileDirectory()
+            throws GuacamoleException {
+        return new SimpleDirectory<SharingProfile>();
+    }
+
+    @Override
+    public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
+            throws GuacamoleException {
+        return new SimpleActivityRecordSet<ConnectionRecord>();
+    }
+
+    @Override
+    public ActivityRecordSet<ActivityRecord> getUserHistory()
+            throws GuacamoleException {
+        return new SimpleActivityRecordSet<ActivityRecord>();
+    }
+
+    @Override
+    public ConnectionGroup getRootConnectionGroup()
+            throws GuacamoleException {
+        return new SimpleConnectionGroup(
+            DEFAULT_ROOT_CONNECTION_GROUP,
+            DEFAULT_ROOT_CONNECTION_GROUP,
+            getConnectionDirectory().getIdentifiers(),
+            Collections.<String>emptySet()
+        );
+    }
+
+    @Override
+    public Collection<Form> getUserAttributes() {
+        return Collections.<Form>emptyList();
+    }
+
+    @Override
+    public Collection<Form> getConnectionAttributes() {
+        return Collections.<Form>emptyList();
+    }
+
+    @Override
+    public Collection<Form> getConnectionGroupAttributes() {
+        return Collections.<Form>emptyList();
+    }
+
+    @Override
+    public Collection<Form> getSharingProfileAttributes() {
+        return Collections.<Form>emptyList();
+    }
+
+    @Override
+    public void invalidate() {
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/9b7ef0df/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleAuthenticationProvider.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleAuthenticationProvider.java
index b29c2d7..837f1d7 100644
--- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleAuthenticationProvider.java
+++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleAuthenticationProvider.java
@@ -23,6 +23,7 @@ import java.util.Map;
 import java.util.UUID;
 import org.apache.guacamole.GuacamoleException;
 import org.apache.guacamole.net.auth.AbstractAuthenticatedUser;
+import org.apache.guacamole.net.auth.AbstractAuthenticationProvider;
 import org.apache.guacamole.net.auth.AuthenticationProvider;
 import org.apache.guacamole.net.auth.AuthenticatedUser;
 import org.apache.guacamole.net.auth.Credentials;
@@ -42,7 +43,7 @@ import org.apache.guacamole.token.TokenFilter;
  * the AuthenticationProvider interface of older Guacamole releases.
  */
 public abstract class SimpleAuthenticationProvider
-    implements AuthenticationProvider {
+    extends AbstractAuthenticationProvider {
 
     /**
      * Given an arbitrary credentials object, returns a Map containing all
@@ -204,11 +205,6 @@ public abstract class SimpleAuthenticationProvider
     }
 
     @Override
-    public Object getResource() throws GuacamoleException {
-        return null;
-    }
-
-    @Override
     public AuthenticatedUser authenticateUser(final Credentials credentials)
             throws GuacamoleException {
 
@@ -241,45 +237,4 @@ public abstract class SimpleAuthenticationProvider
 
     }
 
-    @Override
-    public AuthenticatedUser updateAuthenticatedUser(AuthenticatedUser authenticatedUser,
-            Credentials credentials) throws GuacamoleException {
-
-        // Simply return the given user, updating nothing
-        return authenticatedUser;
-
-    }
-
-    @Override
-    public UserContext updateUserContext(UserContext context,
-        AuthenticatedUser authorizedUser, Credentials credentials)
-            throws GuacamoleException {
-
-        // Simply return the given context, updating nothing
-        return context;
-        
-    }
-
-    @Override
-    public UserContext decorate(UserContext context,
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-
-        // Simply return the given context, decorating nothing
-        return context;
-
-    }
-
-    @Override
-    public UserContext redecorate(UserContext decorated, UserContext context,
-            AuthenticatedUser authenticatedUser, Credentials credentials)
-            throws GuacamoleException {
-        return decorate(context, authenticatedUser, credentials);
-    }
-
-    @Override
-    public void shutdown() {
-        // Do nothing
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/9b7ef0df/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleDirectory.java
----------------------------------------------------------------------
diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleDirectory.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleDirectory.java
index 03a14d9..1e184c4 100644
--- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleDirectory.java
+++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleDirectory.java
@@ -20,10 +20,12 @@
 package org.apache.guacamole.net.auth.simple;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 import org.apache.guacamole.GuacamoleException;
 import org.apache.guacamole.GuacamoleSecurityException;
 import org.apache.guacamole.net.auth.Directory;
@@ -54,7 +56,8 @@ public class SimpleDirectory<ObjectType extends Identifiable>
 
     /**
      * Creates a new SimpleDirectory which provides access to the objects
-     * contained within the given Map.
+     * contained within the given Map. The given Map will be used to back all
+     * operations on the SimpleDirectory, and must be threadsafe.
      *
      * @param objects
      *     The Map of objects to provide access to.
@@ -63,6 +66,30 @@ public class SimpleDirectory<ObjectType extends Identifiable>
         this.objects = objects;
     }
 
+    public SimpleDirectory(ObjectType object) {
+        this(Collections.singletonMap(object.getIdentifier(), object));
+    }
+
+    public SimpleDirectory(ObjectType... objects) {
+        this(Arrays.asList(objects));
+    }
+
+    /**
+     * Creates a new SimpleDirectory which provides access to the
+     * objects contained within the Collection. Note that a new Map will be
+     * created to store the given objects. If the objects are already available
+     * in Map form, it is more efficient to use the
+     * {@link #SimpleDirectory(java.util.Map)} constructor.
+     *
+     * @param objects
+     *     A Collection of all objects that should be present in this directory.
+     */
+    public SimpleDirectory(Collection<ObjectType> objects) {
+        this.objects = new ConcurrentHashMap<String, ObjectType>(objects.size());
+        for (ObjectType object : objects)
+            this.objects.put(object.getIdentifier(), object);
+    }
+
     /**
      * Sets the Map which backs this SimpleDirectory. Future function calls
      * which retrieve objects from this SimpleDirectory will use the provided

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/9b7ef0df/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUserContext.java
----------------------------------------------------------------------
diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUserContext.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUserContext.java
index 1678d88..26978e9 100644
--- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUserContext.java
+++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUserContext.java
@@ -19,24 +19,16 @@
 
 package org.apache.guacamole.net.auth.simple;
 
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
-import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
 import org.apache.guacamole.GuacamoleException;
-import org.apache.guacamole.form.Form;
-import org.apache.guacamole.net.auth.ActiveConnection;
-import org.apache.guacamole.net.auth.ActivityRecord;
-import org.apache.guacamole.net.auth.ActivityRecordSet;
+import org.apache.guacamole.net.auth.AbstractUserContext;
+import org.apache.guacamole.net.auth.AuthenticatedUser;
 import org.apache.guacamole.net.auth.AuthenticationProvider;
 import org.apache.guacamole.net.auth.Connection;
-import org.apache.guacamole.net.auth.ConnectionGroup;
-import org.apache.guacamole.net.auth.ConnectionRecord;
 import org.apache.guacamole.net.auth.Directory;
-import org.apache.guacamole.net.auth.SharingProfile;
 import org.apache.guacamole.net.auth.User;
-import org.apache.guacamole.net.auth.UserContext;
 import org.apache.guacamole.protocol.GuacamoleConfiguration;
 
 /**
@@ -44,12 +36,7 @@ import org.apache.guacamole.protocol.GuacamoleConfiguration;
  * a defined and restricted set of GuacamoleConfigurations. Access to
  * querying or modifying either users or permissions is denied.
  */
-public class SimpleUserContext implements UserContext {
-
-    /**
-     * The unique identifier of the root connection group.
-     */
-    private static final String ROOT_IDENTIFIER = "ROOT";
+public class SimpleUserContext extends AbstractUserContext {
 
     /**
      * The AuthenticationProvider that created this UserContext.
@@ -57,22 +44,10 @@ public class SimpleUserContext implements UserContext {
     private final AuthenticationProvider authProvider;
 
     /**
-     * Reference to the user whose permissions dictate the configurations
-     * accessible within this UserContext.
-     */
-    private final User self;
-
-    /**
-     * The Directory with access only to the User associated with this
-     * UserContext.
+     * The unique identifier (username) of the user whose permissions dictate
+     * the configurations accessible within this UserContext.
      */
-    private final Directory<User> userDirectory;
-
-    /**
-     * The Directory with access only to the root group associated with this
-     * UserContext.
-     */
-    private final Directory<ConnectionGroup> connectionGroupDirectory;
+    private final String username;
 
     /**
      * The Directory with access to all connections within the root group
@@ -81,14 +56,10 @@ public class SimpleUserContext implements UserContext {
     private final Directory<Connection> connectionDirectory;
 
     /**
-     * The root connection group.
-     */
-    private final ConnectionGroup rootGroup;
-
-    /**
      * Creates a new SimpleUserContext which provides access to only those
-     * configurations within the given Map. The username is assigned
-     * arbitrarily.
+     * configurations within the given Map. The username is set to the
+     * ANONYMOUS_IDENTIFIER defined by AuthenticatedUser, effectively declaring
+     * the current user as anonymous.
      *
      * @param authProvider
      *     The AuthenticationProvider creating this UserContext.
@@ -99,7 +70,7 @@ public class SimpleUserContext implements UserContext {
      */
     public SimpleUserContext(AuthenticationProvider authProvider,
             Map<String, GuacamoleConfiguration> configs) {
-        this(authProvider, UUID.randomUUID().toString(), configs);
+        this(authProvider, AuthenticatedUser.ANONYMOUS_IDENTIFIER, configs);
     }
 
     /**
@@ -119,11 +90,8 @@ public class SimpleUserContext implements UserContext {
     public SimpleUserContext(AuthenticationProvider authProvider,
             String username, Map<String, GuacamoleConfiguration> configs) {
 
-        Collection<String> connectionIdentifiers = new ArrayList<String>(configs.size());
-        Collection<String> connectionGroupIdentifiers = Collections.singleton(ROOT_IDENTIFIER);
-        
-        // Produce collection of connections from given configs
-        Collection<Connection> connections = new ArrayList<Connection>(configs.size());
+        // Produce map of connections from given configs
+        Map<String, Connection> connections = new ConcurrentHashMap<String, Connection>(configs.size());
         for (Map.Entry<String, GuacamoleConfiguration> configEntry : configs.entrySet()) {
 
             // Get connection identifier and configuration
@@ -132,37 +100,33 @@ public class SimpleUserContext implements UserContext {
 
             // Add as simple connection
             Connection connection = new SimpleConnection(identifier, identifier, config);
-            connection.setParentIdentifier(ROOT_IDENTIFIER);
-            connections.add(connection);
+            connection.setParentIdentifier(DEFAULT_ROOT_CONNECTION_GROUP);
+            connections.put(identifier, connection);
 
-            // Add identifier to overall set of identifiers
-            connectionIdentifiers.add(identifier);
-            
         }
-        
-        // Add root group that contains only the given configurations
-        this.rootGroup = new SimpleConnectionGroup(
-            ROOT_IDENTIFIER, ROOT_IDENTIFIER,
-            connectionIdentifiers, Collections.<String>emptyList()
-        );
-
-        // Build new user from credentials
-        this.self = new SimpleUser(username, connectionIdentifiers,
-                connectionGroupIdentifiers);
-
-        // Create directories for new user
-        this.userDirectory = new SimpleUserDirectory(self);
-        this.connectionDirectory = new SimpleConnectionDirectory(connections);
-        this.connectionGroupDirectory = new SimpleConnectionGroupDirectory(Collections.singleton(this.rootGroup));
-
-        // Associate provided AuthenticationProvider
+
+        this.username = username;
         this.authProvider = authProvider;
+        this.connectionDirectory = new SimpleDirectory<Connection>(connections);
 
     }
 
     @Override
     public User self() {
-        return self;
+
+        try {
+            return new SimpleUser(username,
+                    getConnectionDirectory().getIdentifiers(),
+                    getConnectionGroupDirectory().getIdentifiers()
+            );
+        }
+
+        catch (GuacamoleException e) {
+            return new SimpleUser(username,
+                    Collections.<String>emptySet(),
+                    Collections.<String>emptySet());
+        }
+
     }
 
     @Override
@@ -176,75 +140,9 @@ public class SimpleUserContext implements UserContext {
     }
 
     @Override
-    public Directory<User> getUserDirectory()
-            throws GuacamoleException {
-        return userDirectory;
-    }
-
-    @Override
     public Directory<Connection> getConnectionDirectory()
             throws GuacamoleException {
         return connectionDirectory;
     }
 
-    @Override
-    public Directory<ConnectionGroup> getConnectionGroupDirectory()
-            throws GuacamoleException {
-        return connectionGroupDirectory;
-    }
-
-    @Override
-    public ConnectionGroup getRootConnectionGroup() throws GuacamoleException {
-        return rootGroup;
-    }
-
-    @Override
-    public Directory<SharingProfile> getSharingProfileDirectory()
-            throws GuacamoleException {
-        return new SimpleDirectory<SharingProfile>();
-    }
-
-    @Override
-    public Directory<ActiveConnection> getActiveConnectionDirectory()
-            throws GuacamoleException {
-        return new SimpleDirectory<ActiveConnection>();
-    }
-
-    @Override
-    public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
-            throws GuacamoleException {
-        return new SimpleActivityRecordSet<ConnectionRecord>();
-    }
-
-    @Override
-    public ActivityRecordSet<ActivityRecord> getUserHistory()
-            throws GuacamoleException {
-        return new SimpleActivityRecordSet<ActivityRecord>();
-    }
-
-    @Override
-    public Collection<Form> getUserAttributes() {
-        return Collections.<Form>emptyList();
-    }
-
-    @Override
-    public Collection<Form> getConnectionAttributes() {
-        return Collections.<Form>emptyList();
-    }
-
-    @Override
-    public Collection<Form> getConnectionGroupAttributes() {
-        return Collections.<Form>emptyList();
-    }
-
-    @Override
-    public Collection<Form> getSharingProfileAttributes() {
-        return Collections.<Form>emptyList();
-    }
-
-    @Override
-    public void invalidate() {
-        // Nothing to invalidate
-    }
-
 }


[4/4] guacamole-client git commit: GUACAMOLE-542: Merge implement AbstractUsreContext and AbstractAuthenticationProvider

Posted by vn...@apache.org.
GUACAMOLE-542: Merge implement AbstractUsreContext and AbstractAuthenticationProvider


Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/aac9d879
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/aac9d879
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/aac9d879

Branch: refs/heads/master
Commit: aac9d8795cb257b259259097fff8c540439d746b
Parents: 8fb62d1 fa100a8
Author: Nick Couchman <vn...@apache.org>
Authored: Fri Apr 13 14:35:04 2018 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Fri Apr 13 14:35:04 2018 -0400

----------------------------------------------------------------------
 .../auth/cas/CASAuthenticationProvider.java     |  58 +----
 .../auth/duo/DuoAuthenticationProvider.java     |  48 +---
 .../HTTPHeaderAuthenticationProvider.java       |  58 +----
 .../jdbc/InjectedAuthenticationProvider.java    |  37 +--
 .../jdbc/sharing/user/SharedUserContext.java    |  95 +-------
 .../auth/ldap/LDAPAuthenticationProvider.java   |  42 +---
 .../guacamole/auth/ldap/user/UserContext.java   |  85 +------
 .../openid/OpenIDAuthenticationProvider.java    |  58 +----
 .../radius/RadiusAuthenticationProvider.java    |  51 +---
 .../auth/totp/TOTPAuthenticationProvider.java   |  34 +--
 .../auth/AbstractAuthenticationProvider.java    | 157 +++++++++++++
 .../guacamole/net/auth/AbstractUserContext.java | 232 +++++++++++++++++++
 .../simple/SimpleAuthenticationProvider.java    |  49 +---
 .../auth/simple/SimpleConnectionDirectory.java  |   3 +
 .../simple/SimpleConnectionGroupDirectory.java  |   3 +
 .../net/auth/simple/SimpleDirectory.java        |  44 +++-
 .../net/auth/simple/SimpleUserContext.java      | 166 +++----------
 .../net/auth/simple/SimpleUserDirectory.java    |   3 +
 18 files changed, 497 insertions(+), 726 deletions(-)
----------------------------------------------------------------------



[3/4] guacamole-client git commit: GUACAMOLE-542: Explicitly document the behavior of the default implementations provided by AbstractUserContext and AbstractAuthenticationProvider.

Posted by vn...@apache.org.
GUACAMOLE-542: Explicitly document the behavior of the default implementations provided by AbstractUserContext and AbstractAuthenticationProvider.


Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/fa100a88
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/fa100a88
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/fa100a88

Branch: refs/heads/master
Commit: fa100a888ff28a4cbd0df81bba9102c3e1cf446b
Parents: 57ff8b8
Author: Michael Jumper <mj...@apache.org>
Authored: Wed Apr 11 17:55:39 2018 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Thu Apr 12 14:33:32 2018 -0700

----------------------------------------------------------------------
 .../auth/AbstractAuthenticationProvider.java    |  78 ++++++++++++-
 .../guacamole/net/auth/AbstractUserContext.java | 110 ++++++++++++++++++-
 2 files changed, 185 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/fa100a88/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AbstractAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AbstractAuthenticationProvider.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AbstractAuthenticationProvider.java
index 991f6a8..81a91d9 100644
--- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AbstractAuthenticationProvider.java
+++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AbstractAuthenticationProvider.java
@@ -24,35 +24,82 @@ import org.apache.guacamole.GuacamoleException;
 /**
  * Base implementation of AuthenticationProvider which provides default
  * implementations of most functions. Implementations must provide their
- * own {@link getIdentifier()}, but otherwise need only override an implemented
+ * own {@link #getIdentifier()}, but otherwise need only override an implemented
  * function if they wish to actually implement the functionality defined for
  * that function by the AuthenticationProvider interface.
  */
 public abstract class AbstractAuthenticationProvider implements AuthenticationProvider {
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation simply returns {@code null}. Implementations that
+     * wish to expose REST resources which are not specific to a user's session
+     * should override this function.
+     */
     @Override
     public Object getResource() throws GuacamoleException {
         return null;
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation performs no authentication whatsoever, ignoring
+     * the provided {@code credentials} and simply returning {@code null}. Any
+     * authentication attempt will thus fall through to other
+     * {@link AuthenticationProvider} implementations, perhaps within other
+     * installed extensions, with this {@code AuthenticationProvider} making no
+     * claim regarding the user's identity nor whether the user should be
+     * allowed or disallowed from accessing Guacamole. Implementations that wish
+     * to authenticate users should override this function.
+     */
     @Override
     public AuthenticatedUser authenticateUser(Credentials credentials)
             throws GuacamoleException {
         return null;
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation simply returns the provided
+     * {@code authenticatedUser} without modification. Implementations that
+     * wish to update a user's {@link AuthenticatedUser} object with respect to
+     * new {@link Credentials} received in requests which follow the initial,
+     * successful authentication attempt should override this function.
+     */
     @Override
     public AuthenticatedUser updateAuthenticatedUser(AuthenticatedUser authenticatedUser,
             Credentials credentials) throws GuacamoleException {
         return authenticatedUser;
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation simply returns {@code null}, effectively allowing
+     * authentication to continue but refusing to provide data for the given
+     * user. Implementations that wish to veto the authentication results of
+     * other {@link AuthenticationProvider} implementations or provide data for
+     * authenticated users should override this function.
+     */
     @Override
     public UserContext getUserContext(AuthenticatedUser authenticatedUser)
             throws GuacamoleException {
         return null;
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation simply returns the provided {@code context}
+     * without modification. Implementations that wish to update a user's
+     * {@link UserContext} object with respect to newly-updated
+     * {@link AuthenticatedUser} or {@link Credentials} (such as those received
+     * in requests which follow the initial, successful authentication attempt)
+     * should override this function.
+     */
     @Override
     public UserContext updateUserContext(UserContext context,
             AuthenticatedUser authenticatedUser,
@@ -60,6 +107,15 @@ public abstract class AbstractAuthenticationProvider implements AuthenticationPr
         return context;
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation simply returns the provided {@code context}
+     * without performing any decoration. Implementations that wish to augment
+     * the functionality or data provided by other
+     * {@link AuthenticationProvider} implementations should override this
+     * function.
+     */
     @Override
     public UserContext decorate(UserContext context,
             AuthenticatedUser authenticatedUser,
@@ -67,6 +123,19 @@ public abstract class AbstractAuthenticationProvider implements AuthenticationPr
         return context;
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation simply invokes
+     * {@link #decorate(UserContext,AuthenticatedUser,Credentials)} with the
+     * provided {@code context}, {@code authenticatedUser}, and
+     * {@code credentials}. Implementations which override
+     * {@link #decorate(UserContext,AuthenticatedUser,Credentials)} and which
+     * need to update their existing decorated object following possible
+     * updates to the {@link UserContext} or {@link AuthenticatedUser} (rather
+     * than generate an entirely new decorated object) should override this
+     * function.
+     */
     @Override
     public UserContext redecorate(UserContext decorated, UserContext context,
             AuthenticatedUser authenticatedUser,
@@ -74,6 +143,13 @@ public abstract class AbstractAuthenticationProvider implements AuthenticationPr
         return decorate(context, authenticatedUser, credentials);
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation does nothing. Implementations that wish to perform
+     * cleanup tasks when the {@link AuthenticationProvider} is being unloaded
+     * should override this function.
+     */
     @Override
     public void shutdown() {
     }

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/fa100a88/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AbstractUserContext.java
----------------------------------------------------------------------
diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AbstractUserContext.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AbstractUserContext.java
index 25db3d5..e2de612 100644
--- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AbstractUserContext.java
+++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AbstractUserContext.java
@@ -29,8 +29,8 @@ import org.apache.guacamole.net.auth.simple.SimpleDirectory;
 
 /**
  * Base implementation of UserContext which provides default implementations of
- * most functions. Implementations must provide their own {@link self()} and
- * {@link getAuthenticationProvider()}, but otherwise need only override an
+ * most functions. Implementations must provide their own {@link #self()} and
+ * {@link #getAuthenticationProvider()}, but otherwise need only override an
  * implemented function if they wish to actually implement the functionality
  * defined for that function by the UserContext interface.
  */
@@ -42,52 +42,122 @@ public abstract class AbstractUserContext implements UserContext {
      */
     protected static final String DEFAULT_ROOT_CONNECTION_GROUP = "ROOT";
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation simply returns {@code null}. Implementations that
+     * wish to expose REST resources specific to a user's session should
+     * override this function.
+     */
     @Override
     public Object getResource() throws GuacamoleException {
         return null;
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation returns a {@link Directory} which contains only
+     * the {@link User} returned by {@link #self()} (the current user
+     * associated with this {@link UserContext}. Implementations that wish to
+     * expose the existence of other users should override this function.
+     */
     @Override
     public Directory<User> getUserDirectory() throws GuacamoleException {
         return new SimpleDirectory<User>(self());
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation simply returns an empty {@link Directory}.
+     * Implementations that wish to expose connections should override this
+     * function.
+     */
     @Override
     public Directory<Connection> getConnectionDirectory()
             throws GuacamoleException {
         return new SimpleDirectory<Connection>();
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation returns a {@link Directory} which contains only
+     * the root connection group returned by {@link #getRootConnectionGroup()}.
+     * Implementations that wish to provide a structured connection hierarchy
+     * should override this function. If only a flat list of connections will
+     * be used, only {@link #getConnectionDirectory()} needs to be overridden.
+     */
     @Override
     public Directory<ConnectionGroup> getConnectionGroupDirectory()
             throws GuacamoleException {
         return new SimpleDirectory<ConnectionGroup>(getRootConnectionGroup());
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation simply returns an empty {@link Directory}.
+     * Implementations that wish to expose the status of active connections
+     * should override this function.
+     */
     @Override
     public Directory<ActiveConnection> getActiveConnectionDirectory()
             throws GuacamoleException {
         return new SimpleDirectory<ActiveConnection>();
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation simply returns an empty {@link Directory}.
+     * Implementations that wish to provide screen sharing functionality
+     * through the use of sharing profiles should override this function.
+     */
     @Override
     public Directory<SharingProfile> getSharingProfileDirectory()
             throws GuacamoleException {
         return new SimpleDirectory<SharingProfile>();
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation simply returns an empty {@link ActivityRecordSet}.
+     * Implementations that wish to expose connection usage history should
+     * override this function.
+     */
     @Override
     public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
             throws GuacamoleException {
         return new SimpleActivityRecordSet<ConnectionRecord>();
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation simply returns an empty {@link ActivityRecordSet}.
+     * Implementations that wish to expose user login/logout history should
+     * override this function.
+     */
     @Override
     public ActivityRecordSet<ActivityRecord> getUserHistory()
             throws GuacamoleException {
         return new SimpleActivityRecordSet<ActivityRecord>();
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation returns a new {@link ConnectionGroup} with the
+     * identifier defined by {@link #DEFAULT_ROOT_CONNECTION_GROUP} and
+     * containing all connections exposed by the {@link Directory} returned by
+     * {@link #getConnectionDirectory()}. Implementations that wish to provide
+     * a structured connection hierarchy should override this function. If only
+     * a flat list of connections will be used, only
+     * {@link #getConnectionDirectory()} needs to be overridden.
+     */
     @Override
     public ConnectionGroup getRootConnectionGroup()
             throws GuacamoleException {
@@ -99,26 +169,62 @@ public abstract class AbstractUserContext implements UserContext {
         );
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation simply returns an empty {@link Collection}.
+     * Implementations that wish to expose custom user attributes as fields
+     * within user edit screens should override this function.
+     */
     @Override
     public Collection<Form> getUserAttributes() {
         return Collections.<Form>emptyList();
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation simply returns an empty {@link Collection}.
+     * Implementations that wish to expose custom connection attributes as
+     * fields within connection edit screens should override this function.
+     */
     @Override
     public Collection<Form> getConnectionAttributes() {
         return Collections.<Form>emptyList();
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation simply returns an empty {@link Collection}.
+     * Implementations that wish to expose custom connection group attributes
+     * as fields within connection group edit screens should override this
+     * function.
+     */
     @Override
     public Collection<Form> getConnectionGroupAttributes() {
         return Collections.<Form>emptyList();
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation simply returns an empty {@link Collection}.
+     * Implementations that wish to expose custom sharing profile attributes as
+     * fields within sharing profile edit screens should override this function.
+     */
     @Override
     public Collection<Form> getSharingProfileAttributes() {
         return Collections.<Form>emptyList();
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This implementation does nothing. Implementations that wish to perform
+     * cleanup tasks when the user associated with this {@link UserContext} is
+     * being logged out should override this function.
+     */
     @Override
     public void invalidate() {
     }


[2/4] guacamole-client git commit: GUACAMOLE-542: Deprecate SimpleConnectionDirectory, etc., relying instead on SimpleDirectory.

Posted by vn...@apache.org.
GUACAMOLE-542: Deprecate SimpleConnectionDirectory, etc., relying instead on SimpleDirectory.


Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/57ff8b84
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/57ff8b84
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/57ff8b84

Branch: refs/heads/master
Commit: 57ff8b84e6bd7f02f70999b4a77853bdc5279e8a
Parents: 9b7ef0d
Author: Michael Jumper <mj...@apache.org>
Authored: Wed Apr 11 17:04:07 2018 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Wed Apr 11 21:29:23 2018 -0700

----------------------------------------------------------------------
 .../auth/simple/SimpleConnectionDirectory.java  |  3 +++
 .../simple/SimpleConnectionGroupDirectory.java  |  3 +++
 .../net/auth/simple/SimpleDirectory.java        | 21 +++++++++++++++++---
 .../net/auth/simple/SimpleUserDirectory.java    |  3 +++
 4 files changed, 27 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/57ff8b84/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleConnectionDirectory.java
----------------------------------------------------------------------
diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleConnectionDirectory.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleConnectionDirectory.java
index 3f9c4c8..77eaf98 100644
--- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleConnectionDirectory.java
+++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleConnectionDirectory.java
@@ -28,7 +28,10 @@ import org.apache.guacamole.net.auth.Connection;
  * An extremely simple read-only implementation of a Directory of
  * GuacamoleConfigurations which provides access to a pre-defined Map of
  * GuacamoleConfigurations.
+ *
+ * @deprecated Use {@link SimpleDirectory} instead.
  */
+@Deprecated
 public class SimpleConnectionDirectory extends SimpleDirectory<Connection> {
 
     /**

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/57ff8b84/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleConnectionGroupDirectory.java
----------------------------------------------------------------------
diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleConnectionGroupDirectory.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleConnectionGroupDirectory.java
index a2597d4..e087054 100644
--- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleConnectionGroupDirectory.java
+++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleConnectionGroupDirectory.java
@@ -28,7 +28,10 @@ import org.apache.guacamole.net.auth.ConnectionGroup;
  * An extremely simple read-only implementation of a Directory of
  * ConnectionGroup which provides which provides access to a pre-defined
  * Collection of ConnectionGroups.
+ *
+ * @deprecated Use {@link SimpleDirectory} instead.
  */
+@Deprecated
 public class SimpleConnectionGroupDirectory
     extends SimpleDirectory<ConnectionGroup> {
 

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/57ff8b84/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleDirectory.java
----------------------------------------------------------------------
diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleDirectory.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleDirectory.java
index 1e184c4..4f64ec8 100644
--- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleDirectory.java
+++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleDirectory.java
@@ -23,9 +23,9 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
 import org.apache.guacamole.GuacamoleException;
 import org.apache.guacamole.GuacamoleSecurityException;
 import org.apache.guacamole.net.auth.Directory;
@@ -57,7 +57,7 @@ public class SimpleDirectory<ObjectType extends Identifiable>
     /**
      * Creates a new SimpleDirectory which provides access to the objects
      * contained within the given Map. The given Map will be used to back all
-     * operations on the SimpleDirectory, and must be threadsafe.
+     * operations on the SimpleDirectory.
      *
      * @param objects
      *     The Map of objects to provide access to.
@@ -66,10 +66,25 @@ public class SimpleDirectory<ObjectType extends Identifiable>
         this.objects = objects;
     }
 
+    /**
+     * Creates a new SimpleDirectory which provides access to the given object.
+     *
+     * @param object
+     *     The object to provide access to.
+     */
     public SimpleDirectory(ObjectType object) {
         this(Collections.singletonMap(object.getIdentifier(), object));
     }
 
+    /**
+     * Creates a new SimpleDirectory which provides access to the given
+     * objects. Note that a new Map will be created to store the given objects.
+     * If the objects are already available in Map form, it is more efficient
+     * to use the {@link #SimpleDirectory(java.util.Map)} constructor.
+     *
+     * @param objects
+     *     The objects that should be present in this directory.
+     */
     public SimpleDirectory(ObjectType... objects) {
         this(Arrays.asList(objects));
     }
@@ -85,7 +100,7 @@ public class SimpleDirectory<ObjectType extends Identifiable>
      *     A Collection of all objects that should be present in this directory.
      */
     public SimpleDirectory(Collection<ObjectType> objects) {
-        this.objects = new ConcurrentHashMap<String, ObjectType>(objects.size());
+        this.objects = new HashMap<String, ObjectType>(objects.size());
         for (ObjectType object : objects)
             this.objects.put(object.getIdentifier(), object);
     }

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/57ff8b84/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUserDirectory.java
----------------------------------------------------------------------
diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUserDirectory.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUserDirectory.java
index f9068d4..bb5e37a 100644
--- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUserDirectory.java
+++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUserDirectory.java
@@ -25,7 +25,10 @@ import org.apache.guacamole.net.auth.User;
 /**
  * An extremely simple read-only implementation of a Directory of Users which
  * provides access to a single pre-defined User.
+ *
+ * @deprecated Use {@link SimpleDirectory} instead.
  */
+@Deprecated
 public class SimpleUserDirectory extends SimpleDirectory<User> {
 
     /**