mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-289: Isolate extension REST services to ".../api/ext/" and ".../api/session/ext".
This commit is contained in:
@@ -28,6 +28,7 @@ import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleResourceNotFoundException;
|
||||
import org.apache.guacamole.GuacamoleSession;
|
||||
import org.apache.guacamole.net.auth.UserContext;
|
||||
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
|
||||
* exposed by this SessionResource.
|
||||
|
@@ -29,7 +29,6 @@ import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleResourceNotFoundException;
|
||||
import org.apache.guacamole.net.auth.ActiveConnection;
|
||||
import org.apache.guacamole.net.auth.Connection;
|
||||
import org.apache.guacamole.net.auth.ConnectionGroup;
|
||||
@@ -254,29 +253,4 @@ public class UserContextResource {
|
||||
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