GUACAMOLE-5: Provide UserContext to DirectoryObjectResourceFactory, in case needed by a particular resource (such as for additional permission checks).

This commit is contained in:
Michael Jumper
2016-07-12 00:31:52 -07:00
parent f440f55823
commit bca4e34b51
2 changed files with 7 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ package org.apache.guacamole.rest.directory;
import org.apache.guacamole.net.auth.Directory; import org.apache.guacamole.net.auth.Directory;
import org.apache.guacamole.net.auth.Identifiable; import org.apache.guacamole.net.auth.Identifiable;
import org.apache.guacamole.net.auth.UserContext;
/** /**
* Factory which creates DirectoryObjectResource instances exposing objects of * Factory which creates DirectoryObjectResource instances exposing objects of
@@ -40,6 +41,9 @@ public interface DirectoryObjectResourceFactory<InternalType extends Identifiabl
/** /**
* Creates a new DirectoryObjectResource which exposes the given object. * Creates a new DirectoryObjectResource which exposes the given object.
* *
* @param userContext
* The UserContext which contains the given Directory.
*
* @param directory * @param directory
* The Directory which contains the object being exposed. * The Directory which contains the object being exposed.
* *
@@ -51,6 +55,7 @@ public interface DirectoryObjectResourceFactory<InternalType extends Identifiabl
* A new DirectoryObjectResource which exposes the given object. * A new DirectoryObjectResource which exposes the given object.
*/ */
DirectoryObjectResource<InternalType, ExternalType> DirectoryObjectResource<InternalType, ExternalType>
create(Directory<InternalType> directory, InternalType object); create(UserContext userContext, Directory<InternalType> directory,
InternalType object);
} }

View File

@@ -258,7 +258,7 @@ public class DirectoryResource<InternalType extends Identifiable, ExternalType>
throw new GuacamoleResourceNotFoundException("Not found: \"" + identifier + "\""); throw new GuacamoleResourceNotFoundException("Not found: \"" + identifier + "\"");
// Return a resource which provides access to the retrieved object // Return a resource which provides access to the retrieved object
return resourceFactory.create(directory, object); return resourceFactory.create(userContext, directory, object);
} }