mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUAC-586: Use auth provider identifiers within schema REST service.
This commit is contained in:
@@ -28,6 +28,7 @@ import java.util.Map;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
@@ -36,7 +37,9 @@ import org.glyptodon.guacamole.environment.Environment;
|
||||
import org.glyptodon.guacamole.environment.LocalEnvironment;
|
||||
import org.glyptodon.guacamole.form.Form;
|
||||
import org.glyptodon.guacamole.net.auth.UserContext;
|
||||
import org.glyptodon.guacamole.net.basic.GuacamoleSession;
|
||||
import org.glyptodon.guacamole.net.basic.rest.AuthProviderRESTExposure;
|
||||
import org.glyptodon.guacamole.net.basic.rest.ObjectRetrievalService;
|
||||
import org.glyptodon.guacamole.net.basic.rest.auth.AuthenticationService;
|
||||
import org.glyptodon.guacamole.protocols.ProtocolInfo;
|
||||
|
||||
@@ -46,7 +49,7 @@ import org.glyptodon.guacamole.protocols.ProtocolInfo;
|
||||
*
|
||||
* @author Michael Jumper
|
||||
*/
|
||||
@Path("/schema")
|
||||
@Path("/schema/{dataSource}")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public class SchemaRESTService {
|
||||
@@ -57,6 +60,12 @@ public class SchemaRESTService {
|
||||
@Inject
|
||||
private AuthenticationService authenticationService;
|
||||
|
||||
/**
|
||||
* Service for convenient retrieval of objects.
|
||||
*/
|
||||
@Inject
|
||||
private ObjectRetrievalService retrievalService;
|
||||
|
||||
/**
|
||||
* Retrieves the possible attributes of a user object.
|
||||
*
|
||||
@@ -64,6 +73,10 @@ public class SchemaRESTService {
|
||||
* The authentication token that is used to authenticate the user
|
||||
* performing the operation.
|
||||
*
|
||||
* @param authProviderIdentifier
|
||||
* The unique identifier of the AuthenticationProvider associated with
|
||||
* the UserContext dictating the available user attributes.
|
||||
*
|
||||
* @return
|
||||
* A collection of forms which describe the possible attributes of a
|
||||
* user object.
|
||||
@@ -74,10 +87,13 @@ public class SchemaRESTService {
|
||||
@GET
|
||||
@Path("/users/attributes")
|
||||
@AuthProviderRESTExposure
|
||||
public Collection<Form> getUserAttributes(@QueryParam("token") String authToken) throws GuacamoleException {
|
||||
public Collection<Form> getUserAttributes(@QueryParam("token") String authToken,
|
||||
@PathParam("dataSource") String authProviderIdentifier)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Retrieve all possible user attributes
|
||||
UserContext userContext = authenticationService.getUserContext(authToken);
|
||||
GuacamoleSession session = authenticationService.getGuacamoleSession(authToken);
|
||||
UserContext userContext = retrievalService.retrieveUserContext(session, authProviderIdentifier);
|
||||
return userContext.getUserAttributes();
|
||||
|
||||
}
|
||||
@@ -89,6 +105,10 @@ public class SchemaRESTService {
|
||||
* The authentication token that is used to authenticate the user
|
||||
* performing the operation.
|
||||
*
|
||||
* @param authProviderIdentifier
|
||||
* The unique identifier of the AuthenticationProvider associated with
|
||||
* the UserContext dictating the available connection attributes.
|
||||
*
|
||||
* @return
|
||||
* A collection of forms which describe the possible attributes of a
|
||||
* connection object.
|
||||
@@ -99,10 +119,13 @@ public class SchemaRESTService {
|
||||
@GET
|
||||
@Path("/connections/attributes")
|
||||
@AuthProviderRESTExposure
|
||||
public Collection<Form> getConnectionAttributes(@QueryParam("token") String authToken) throws GuacamoleException {
|
||||
public Collection<Form> getConnectionAttributes(@QueryParam("token") String authToken,
|
||||
@PathParam("dataSource") String authProviderIdentifier)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Retrieve all possible connection attributes
|
||||
UserContext userContext = authenticationService.getUserContext(authToken);
|
||||
GuacamoleSession session = authenticationService.getGuacamoleSession(authToken);
|
||||
UserContext userContext = retrievalService.retrieveUserContext(session, authProviderIdentifier);
|
||||
return userContext.getConnectionAttributes();
|
||||
|
||||
}
|
||||
@@ -114,6 +137,11 @@ public class SchemaRESTService {
|
||||
* The authentication token that is used to authenticate the user
|
||||
* performing the operation.
|
||||
*
|
||||
* @param authProviderIdentifier
|
||||
* The unique identifier of the AuthenticationProvider associated with
|
||||
* the UserContext dictating the available connection group
|
||||
* attributes.
|
||||
*
|
||||
* @return
|
||||
* A collection of forms which describe the possible attributes of a
|
||||
* connection group object.
|
||||
@@ -124,10 +152,13 @@ public class SchemaRESTService {
|
||||
@GET
|
||||
@Path("/connectionGroups/attributes")
|
||||
@AuthProviderRESTExposure
|
||||
public Collection<Form> getConnectionGroupAttributes(@QueryParam("token") String authToken) throws GuacamoleException {
|
||||
public Collection<Form> getConnectionGroupAttributes(@QueryParam("token") String authToken,
|
||||
@PathParam("dataSource") String authProviderIdentifier)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Retrieve all possible connection group attributes
|
||||
UserContext userContext = authenticationService.getUserContext(authToken);
|
||||
GuacamoleSession session = authenticationService.getGuacamoleSession(authToken);
|
||||
UserContext userContext = retrievalService.retrieveUserContext(session, authProviderIdentifier);
|
||||
return userContext.getConnectionGroupAttributes();
|
||||
|
||||
}
|
||||
@@ -139,6 +170,13 @@ public class SchemaRESTService {
|
||||
* The authentication token that is used to authenticate the user
|
||||
* performing the operation.
|
||||
*
|
||||
* @param authProviderIdentifier
|
||||
* The unique identifier of the AuthenticationProvider associated with
|
||||
* the UserContext dictating the protocols available. Currently, the
|
||||
* UserContext actually does not dictate this, the the same set of
|
||||
* protocols will be retrieved for all users, though the identifier
|
||||
* given here will be validated.
|
||||
*
|
||||
* @return
|
||||
* A map of protocol information, where each key is the unique name
|
||||
* associated with that protocol.
|
||||
@@ -149,10 +187,13 @@ public class SchemaRESTService {
|
||||
@GET
|
||||
@Path("/protocols")
|
||||
@AuthProviderRESTExposure
|
||||
public Map<String, ProtocolInfo> getProtocols(@QueryParam("token") String authToken) throws GuacamoleException {
|
||||
public Map<String, ProtocolInfo> getProtocols(@QueryParam("token") String authToken,
|
||||
@PathParam("dataSource") String authProviderIdentifier)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Verify the given auth token is valid
|
||||
authenticationService.getUserContext(authToken);
|
||||
// Verify the given auth token and auth provider identifier are valid
|
||||
GuacamoleSession session = authenticationService.getGuacamoleSession(authToken);
|
||||
retrievalService.retrieveUserContext(session, authProviderIdentifier);
|
||||
|
||||
// Get and return a map of all protocols.
|
||||
Environment env = new LocalEnvironment();
|
||||
|
@@ -39,12 +39,18 @@ angular.module('rest').factory('schemaService', ['$injector',
|
||||
* @link{Form} objects if successful. Each element of the array describes
|
||||
* a logical grouping of possible attributes.
|
||||
*
|
||||
* @param {String} dataSource
|
||||
* The unique identifier of the data source containing the users whose
|
||||
* available attributes are to be retrieved. This identifier
|
||||
* corresponds to an AuthenticationProvider within the Guacamole web
|
||||
* application.
|
||||
*
|
||||
* @returns {Promise.<Form[]>}
|
||||
* A promise which will resolve with an array of @link{Form}
|
||||
* objects, where each @link{Form} describes a logical grouping of
|
||||
* possible attributes.
|
||||
*/
|
||||
service.getUserAttributes = function getUserAttributes() {
|
||||
service.getUserAttributes = function getUserAttributes(dataSource) {
|
||||
|
||||
// Build HTTP parameters set
|
||||
var httpParameters = {
|
||||
@@ -55,7 +61,7 @@ angular.module('rest').factory('schemaService', ['$injector',
|
||||
return $http({
|
||||
cache : cacheService.schema,
|
||||
method : 'GET',
|
||||
url : 'api/schema/users/attributes',
|
||||
url : 'api/schema/' + encodeURIComponent(dataSource) + '/users/attributes',
|
||||
params : httpParameters
|
||||
});
|
||||
|
||||
@@ -67,12 +73,18 @@ angular.module('rest').factory('schemaService', ['$injector',
|
||||
* @link{Form} objects if successful. Each element of the array describes
|
||||
* a logical grouping of possible attributes.
|
||||
*
|
||||
* @param {String} dataSource
|
||||
* The unique identifier of the data source containing the connections
|
||||
* whose available attributes are to be retrieved. This identifier
|
||||
* corresponds to an AuthenticationProvider within the Guacamole web
|
||||
* application.
|
||||
*
|
||||
* @returns {Promise.<Form[]>}
|
||||
* A promise which will resolve with an array of @link{Form}
|
||||
* objects, where each @link{Form} describes a logical grouping of
|
||||
* possible attributes.
|
||||
*/
|
||||
service.getConnectionAttributes = function getConnectionAttributes() {
|
||||
service.getConnectionAttributes = function getConnectionAttributes(dataSource) {
|
||||
|
||||
// Build HTTP parameters set
|
||||
var httpParameters = {
|
||||
@@ -83,7 +95,7 @@ angular.module('rest').factory('schemaService', ['$injector',
|
||||
return $http({
|
||||
cache : cacheService.schema,
|
||||
method : 'GET',
|
||||
url : 'api/schema/connections/attributes',
|
||||
url : 'api/schema/' + encodeURIComponent(dataSource) + '/connections/attributes',
|
||||
params : httpParameters
|
||||
});
|
||||
|
||||
@@ -95,12 +107,18 @@ angular.module('rest').factory('schemaService', ['$injector',
|
||||
* of @link{Form} objects if successful. Each element of the array
|
||||
* a logical grouping of possible attributes.
|
||||
*
|
||||
* @param {String} dataSource
|
||||
* The unique identifier of the data source containing the connection
|
||||
* groups whose available attributes are to be retrieved. This
|
||||
* identifier corresponds to an AuthenticationProvider within the
|
||||
* Guacamole web application.
|
||||
*
|
||||
* @returns {Promise.<Form[]>}
|
||||
* A promise which will resolve with an array of @link{Form}
|
||||
* objects, where each @link{Form} describes a logical grouping of
|
||||
* possible attributes.
|
||||
*/
|
||||
service.getConnectionGroupAttributes = function getConnectionGroupAttributes() {
|
||||
service.getConnectionGroupAttributes = function getConnectionGroupAttributes(dataSource) {
|
||||
|
||||
// Build HTTP parameters set
|
||||
var httpParameters = {
|
||||
@@ -111,7 +129,7 @@ angular.module('rest').factory('schemaService', ['$injector',
|
||||
return $http({
|
||||
cache : cacheService.schema,
|
||||
method : 'GET',
|
||||
url : 'api/schema/connectionGroups/attributes',
|
||||
url : 'api/schema/' + encodeURIComponent(dataSource) + '/connectionGroups/attributes',
|
||||
params : httpParameters
|
||||
});
|
||||
|
||||
@@ -122,11 +140,16 @@ angular.module('rest').factory('schemaService', ['$injector',
|
||||
* a promise that provides a map of @link{Protocol} objects by protocol
|
||||
* name if successful.
|
||||
*
|
||||
* @param {String} dataSource
|
||||
* The unique identifier of the data source defining available
|
||||
* protocols. This identifier corresponds to an AuthenticationProvider
|
||||
* within the Guacamole web application.
|
||||
*
|
||||
* @returns {Promise.<Object.<String, Protocol>>}
|
||||
* A promise which will resolve with a map of @link{Protocol}
|
||||
* objects by protocol name upon success.
|
||||
*/
|
||||
service.getProtocols = function getProtocols() {
|
||||
service.getProtocols = function getProtocols(dataSource) {
|
||||
|
||||
// Build HTTP parameters set
|
||||
var httpParameters = {
|
||||
@@ -137,7 +160,7 @@ angular.module('rest').factory('schemaService', ['$injector',
|
||||
return $http({
|
||||
cache : cacheService.schema,
|
||||
method : 'GET',
|
||||
url : 'api/schema/protocols',
|
||||
url : 'api/schema/' + encodeURIComponent(dataSource) + '/protocols',
|
||||
params : httpParameters
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user