mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
GUACAMOLE-289: Isolate extension REST services to ".../api/ext/" and ".../api/session/ext".
This commit is contained in:
@@ -43,8 +43,9 @@ public interface UserContext {
|
|||||||
* properly annotated with JSR-311 annotations, and may serve as the root
|
* properly annotated with JSR-311 annotations, and may serve as the root
|
||||||
* resource for any number of extension-specific REST resources related to
|
* resource for any number of extension-specific REST resources related to
|
||||||
* an authenticated user's session. The returned resource is ultimately
|
* an authenticated user's session. The returned resource is ultimately
|
||||||
* exposed at ".../api/session/data/IDENTIFIER/ext/", where IDENTIFIER is
|
* exposed at ".../api/session/ext/IDENTIFIER/", where IDENTIFIER is the
|
||||||
* the identifier of the AuthenticationProvider.
|
* identifier of the AuthenticationProvider associated with this
|
||||||
|
* UserContext.
|
||||||
*
|
*
|
||||||
* REST resources which are NOT related to an authenticated user's session
|
* REST resources which are NOT related to an authenticated user's session
|
||||||
* should instead be returned from AuthenticationProvider.getResource().
|
* should instead be returned from AuthenticationProvider.getResource().
|
||||||
|
@@ -28,6 +28,7 @@ import javax.ws.rs.PathParam;
|
|||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
|
import org.apache.guacamole.GuacamoleResourceNotFoundException;
|
||||||
import org.apache.guacamole.GuacamoleSession;
|
import org.apache.guacamole.GuacamoleSession;
|
||||||
import org.apache.guacamole.net.auth.UserContext;
|
import org.apache.guacamole.net.auth.UserContext;
|
||||||
import org.apache.guacamole.rest.tunnel.TunnelCollectionResource;
|
import org.apache.guacamole.rest.tunnel.TunnelCollectionResource;
|
||||||
@@ -101,6 +102,40 @@ public class SessionResource {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the arbitrary REST resource exposed by the UserContext
|
||||||
|
* associated with the AuthenticationProvider having the given identifier.
|
||||||
|
*
|
||||||
|
* @param authProviderIdentifier
|
||||||
|
* The unique identifier of the AuthenticationProvider associated with
|
||||||
|
* the UserContext whose arbitrary REST service is being retrieved.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* The arbitrary REST resource exposed by the UserContext exposed by
|
||||||
|
* this UserContextresource.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If no such resource could be found, or if an error occurs while
|
||||||
|
* retrieving that resource.
|
||||||
|
*/
|
||||||
|
@Path("ext/{dataSource}")
|
||||||
|
public Object getExtensionResource(
|
||||||
|
@PathParam("dataSource") String authProviderIdentifier)
|
||||||
|
throws GuacamoleException {
|
||||||
|
|
||||||
|
// Pull UserContext defined by the given auth provider identifier
|
||||||
|
UserContext userContext = session.getUserContext(authProviderIdentifier);
|
||||||
|
|
||||||
|
// Pull resource from user context
|
||||||
|
Object resource = userContext.getResource();
|
||||||
|
if (resource != null)
|
||||||
|
return resource;
|
||||||
|
|
||||||
|
// UserContext-specific resource could not be found
|
||||||
|
throw new GuacamoleResourceNotFoundException("No such resource.");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a resource representing all tunnels associated with session
|
* Retrieves a resource representing all tunnels associated with session
|
||||||
* exposed by this SessionResource.
|
* exposed by this SessionResource.
|
||||||
|
@@ -29,7 +29,6 @@ import javax.ws.rs.Path;
|
|||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.GuacamoleResourceNotFoundException;
|
|
||||||
import org.apache.guacamole.net.auth.ActiveConnection;
|
import org.apache.guacamole.net.auth.ActiveConnection;
|
||||||
import org.apache.guacamole.net.auth.Connection;
|
import org.apache.guacamole.net.auth.Connection;
|
||||||
import org.apache.guacamole.net.auth.ConnectionGroup;
|
import org.apache.guacamole.net.auth.ConnectionGroup;
|
||||||
@@ -254,29 +253,4 @@ public class UserContextResource {
|
|||||||
return new SchemaResource(userContext);
|
return new SchemaResource(userContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the arbitrary REST resource exposed by the UserContext exposed
|
|
||||||
* by this UserContextResource.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* The arbitrary REST resource exposed by the UserContext exposed by
|
|
||||||
* this UserContextresource.
|
|
||||||
*
|
|
||||||
* @throws GuacamoleException
|
|
||||||
* If no such resource could be found, or if an error occurs while
|
|
||||||
* retrieving that resource.
|
|
||||||
*/
|
|
||||||
@Path("ext")
|
|
||||||
public Object getExtensionResource() throws GuacamoleException {
|
|
||||||
|
|
||||||
// Pull resource from user context
|
|
||||||
Object resource = userContext.getResource();
|
|
||||||
if (resource != null)
|
|
||||||
return resource;
|
|
||||||
|
|
||||||
// UserContext-specific resource could not be found
|
|
||||||
throw new GuacamoleResourceNotFoundException("No such resource.");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user