GUACAMOLE-289: Add getResource() functions to UserContext and AuthenticationProvider, allowing extensions to expose arbitrary REST resources/services.

This commit is contained in:
Michael Jumper
2017-04-29 12:34:32 -07:00
parent 0c2bcdbd81
commit 4455cbc781
16 changed files with 254 additions and 0 deletions

View File

@@ -40,6 +40,26 @@ public interface AuthenticationProvider {
*/
String getIdentifier();
/**
* Returns an arbitrary REST resource. The REST resource returned must be
* properly annotated with JSR-311 annotations, and may serve as the root
* resource for any number of extension-specific REST resources which are
* unrelated to an authenticated user's session. The returned resource is
* ultimately exposed at ".../api/ext/IDENTIFIER/", where IDENTIFIER is the
* identifier of the AuthenticationProvider.
*
* REST resources which ARE related to an authenticated user's session
* should instead be returned from UserContext.getResource().
*
* @return
* An arbitrary REST resource, annotated with JSR-311 annotations, or
* null if no such resource is defined.
*
* @throws GuacamoleException
* If the REST resource cannot be returned due to an error.
*/
Object getResource() throws GuacamoleException;
/**
* Returns an AuthenticatedUser representing the user authenticated by the
* given credentials, if any.

View File

@@ -38,6 +38,26 @@ public interface UserContext {
*/
User self();
/**
* Returns an arbitrary REST resource. The REST resource returned must be
* properly annotated with JSR-311 annotations, and may serve as the root
* resource for any number of extension-specific REST resources related to
* an authenticated user's session. The returned resource is ultimately
* exposed at ".../api/session/data/IDENTIFIER/ext/", where IDENTIFIER is
* the identifier of the AuthenticationProvider.
*
* REST resources which are NOT related to an authenticated user's session
* should instead be returned from AuthenticationProvider.getResource().
*
* @return
* An arbitrary REST resource, annotated with JSR-311 annotations, or
* null if no such resource is defined.
*
* @throws GuacamoleException
* If the REST resource cannot be returned due to an error.
*/
Object getResource() throws GuacamoleException;
/**
* Returns the AuthenticationProvider which created this UserContext, which
* may not be the same AuthenticationProvider that authenticated the user

View File

@@ -203,6 +203,11 @@ public abstract class SimpleAuthenticationProvider
}
@Override
public Object getResource() throws GuacamoleException {
return null;
}
@Override
public AuthenticatedUser authenticateUser(final Credentials credentials)
throws GuacamoleException {

View File

@@ -163,6 +163,11 @@ public class SimpleUserContext implements UserContext {
return self;
}
@Override
public Object getResource() throws GuacamoleException {
return null;
}
@Override
public AuthenticationProvider getAuthenticationProvider() {
return authProvider;