mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
GUAC-586: Use auth provider identifiers within connection REST service.
This commit is contained in:
@@ -48,6 +48,7 @@ import org.glyptodon.guacamole.net.auth.permission.ObjectPermission;
|
|||||||
import org.glyptodon.guacamole.net.auth.permission.ObjectPermissionSet;
|
import org.glyptodon.guacamole.net.auth.permission.ObjectPermissionSet;
|
||||||
import org.glyptodon.guacamole.net.auth.permission.SystemPermission;
|
import org.glyptodon.guacamole.net.auth.permission.SystemPermission;
|
||||||
import org.glyptodon.guacamole.net.auth.permission.SystemPermissionSet;
|
import org.glyptodon.guacamole.net.auth.permission.SystemPermissionSet;
|
||||||
|
import org.glyptodon.guacamole.net.basic.GuacamoleSession;
|
||||||
import org.glyptodon.guacamole.net.basic.rest.AuthProviderRESTExposure;
|
import org.glyptodon.guacamole.net.basic.rest.AuthProviderRESTExposure;
|
||||||
import org.glyptodon.guacamole.net.basic.rest.ObjectRetrievalService;
|
import org.glyptodon.guacamole.net.basic.rest.ObjectRetrievalService;
|
||||||
import org.glyptodon.guacamole.net.basic.rest.auth.AuthenticationService;
|
import org.glyptodon.guacamole.net.basic.rest.auth.AuthenticationService;
|
||||||
@@ -60,7 +61,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*
|
*
|
||||||
* @author James Muehlner
|
* @author James Muehlner
|
||||||
*/
|
*/
|
||||||
@Path("/connections")
|
@Path("/data/{dataSource}/connections")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public class ConnectionRESTService {
|
public class ConnectionRESTService {
|
||||||
@@ -89,6 +90,10 @@ public class ConnectionRESTService {
|
|||||||
* The authentication token that is used to authenticate the user
|
* The authentication token that is used to authenticate the user
|
||||||
* performing the operation.
|
* performing the operation.
|
||||||
*
|
*
|
||||||
|
* @param authProviderIdentifier
|
||||||
|
* The unique identifier of the AuthenticationProvider associated with
|
||||||
|
* the UserContext containing the connection to be retrieved.
|
||||||
|
*
|
||||||
* @param connectionID
|
* @param connectionID
|
||||||
* The identifier of the connection to retrieve.
|
* The identifier of the connection to retrieve.
|
||||||
*
|
*
|
||||||
@@ -102,12 +107,14 @@ public class ConnectionRESTService {
|
|||||||
@Path("/{connectionID}")
|
@Path("/{connectionID}")
|
||||||
@AuthProviderRESTExposure
|
@AuthProviderRESTExposure
|
||||||
public APIConnection getConnection(@QueryParam("token") String authToken,
|
public APIConnection getConnection(@QueryParam("token") String authToken,
|
||||||
@PathParam("connectionID") String connectionID) throws GuacamoleException {
|
@PathParam("dataSource") String authProviderIdentifier,
|
||||||
|
@PathParam("connectionID") String connectionID)
|
||||||
|
throws GuacamoleException {
|
||||||
|
|
||||||
UserContext userContext = authenticationService.getUserContext(authToken);
|
GuacamoleSession session = authenticationService.getGuacamoleSession(authToken);
|
||||||
|
|
||||||
// Retrieve the requested connection
|
// Retrieve the requested connection
|
||||||
return new APIConnection(retrievalService.retrieveConnection(userContext, connectionID));
|
return new APIConnection(retrievalService.retrieveConnection(session, authProviderIdentifier, connectionID));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,6 +125,11 @@ public class ConnectionRESTService {
|
|||||||
* The authentication token that is used to authenticate the user
|
* The authentication token that is used to authenticate the user
|
||||||
* performing the operation.
|
* performing the operation.
|
||||||
*
|
*
|
||||||
|
* @param authProviderIdentifier
|
||||||
|
* The unique identifier of the AuthenticationProvider associated with
|
||||||
|
* the UserContext containing the connection whose parameters are to be
|
||||||
|
* retrieved.
|
||||||
|
*
|
||||||
* @param connectionID
|
* @param connectionID
|
||||||
* The identifier of the connection.
|
* The identifier of the connection.
|
||||||
*
|
*
|
||||||
@@ -131,9 +143,12 @@ public class ConnectionRESTService {
|
|||||||
@Path("/{connectionID}/parameters")
|
@Path("/{connectionID}/parameters")
|
||||||
@AuthProviderRESTExposure
|
@AuthProviderRESTExposure
|
||||||
public Map<String, String> getConnectionParameters(@QueryParam("token") String authToken,
|
public Map<String, String> getConnectionParameters(@QueryParam("token") String authToken,
|
||||||
@PathParam("connectionID") String connectionID) throws GuacamoleException {
|
@PathParam("dataSource") String authProviderIdentifier,
|
||||||
|
@PathParam("connectionID") String connectionID)
|
||||||
|
throws GuacamoleException {
|
||||||
|
|
||||||
UserContext userContext = authenticationService.getUserContext(authToken);
|
GuacamoleSession session = authenticationService.getGuacamoleSession(authToken);
|
||||||
|
UserContext userContext = retrievalService.retrieveUserContext(session, authProviderIdentifier);
|
||||||
User self = userContext.self();
|
User self = userContext.self();
|
||||||
|
|
||||||
// Retrieve permission sets
|
// Retrieve permission sets
|
||||||
@@ -163,6 +178,11 @@ public class ConnectionRESTService {
|
|||||||
* The authentication token that is used to authenticate the user
|
* The authentication token that is used to authenticate the user
|
||||||
* performing the operation.
|
* performing the operation.
|
||||||
*
|
*
|
||||||
|
* @param authProviderIdentifier
|
||||||
|
* The unique identifier of the AuthenticationProvider associated with
|
||||||
|
* the UserContext containing the connection whose history is to be
|
||||||
|
* retrieved.
|
||||||
|
*
|
||||||
* @param connectionID
|
* @param connectionID
|
||||||
* The identifier of the connection.
|
* The identifier of the connection.
|
||||||
*
|
*
|
||||||
@@ -177,12 +197,14 @@ public class ConnectionRESTService {
|
|||||||
@Path("/{connectionID}/history")
|
@Path("/{connectionID}/history")
|
||||||
@AuthProviderRESTExposure
|
@AuthProviderRESTExposure
|
||||||
public List<APIConnectionRecord> getConnectionHistory(@QueryParam("token") String authToken,
|
public List<APIConnectionRecord> getConnectionHistory(@QueryParam("token") String authToken,
|
||||||
@PathParam("connectionID") String connectionID) throws GuacamoleException {
|
@PathParam("dataSource") String authProviderIdentifier,
|
||||||
|
@PathParam("connectionID") String connectionID)
|
||||||
|
throws GuacamoleException {
|
||||||
|
|
||||||
|
GuacamoleSession session = authenticationService.getGuacamoleSession(authToken);
|
||||||
|
|
||||||
UserContext userContext = authenticationService.getUserContext(authToken);
|
|
||||||
|
|
||||||
// Retrieve the requested connection
|
// Retrieve the requested connection
|
||||||
Connection connection = retrievalService.retrieveConnection(userContext, connectionID);
|
Connection connection = retrievalService.retrieveConnection(session, authProviderIdentifier, connectionID);
|
||||||
|
|
||||||
// Retrieve the requested connection's history
|
// Retrieve the requested connection's history
|
||||||
List<APIConnectionRecord> apiRecords = new ArrayList<APIConnectionRecord>();
|
List<APIConnectionRecord> apiRecords = new ArrayList<APIConnectionRecord>();
|
||||||
@@ -201,6 +223,10 @@ public class ConnectionRESTService {
|
|||||||
* The authentication token that is used to authenticate the user
|
* The authentication token that is used to authenticate the user
|
||||||
* performing the operation.
|
* performing the operation.
|
||||||
*
|
*
|
||||||
|
* @param authProviderIdentifier
|
||||||
|
* The unique identifier of the AuthenticationProvider associated with
|
||||||
|
* the UserContext containing the connection to be deleted.
|
||||||
|
*
|
||||||
* @param connectionID
|
* @param connectionID
|
||||||
* The identifier of the connection to delete.
|
* The identifier of the connection to delete.
|
||||||
*
|
*
|
||||||
@@ -210,10 +236,13 @@ public class ConnectionRESTService {
|
|||||||
@DELETE
|
@DELETE
|
||||||
@Path("/{connectionID}")
|
@Path("/{connectionID}")
|
||||||
@AuthProviderRESTExposure
|
@AuthProviderRESTExposure
|
||||||
public void deleteConnection(@QueryParam("token") String authToken, @PathParam("connectionID") String connectionID)
|
public void deleteConnection(@QueryParam("token") String authToken,
|
||||||
|
@PathParam("dataSource") String authProviderIdentifier,
|
||||||
|
@PathParam("connectionID") String connectionID)
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
|
||||||
UserContext userContext = authenticationService.getUserContext(authToken);
|
GuacamoleSession session = authenticationService.getGuacamoleSession(authToken);
|
||||||
|
UserContext userContext = retrievalService.retrieveUserContext(session, authProviderIdentifier);
|
||||||
|
|
||||||
// Get the connection directory
|
// Get the connection directory
|
||||||
Directory<Connection> connectionDirectory = userContext.getConnectionDirectory();
|
Directory<Connection> connectionDirectory = userContext.getConnectionDirectory();
|
||||||
@@ -231,6 +260,10 @@ public class ConnectionRESTService {
|
|||||||
* The authentication token that is used to authenticate the user
|
* The authentication token that is used to authenticate the user
|
||||||
* performing the operation.
|
* performing the operation.
|
||||||
*
|
*
|
||||||
|
* @param authProviderIdentifier
|
||||||
|
* The unique identifier of the AuthenticationProvider associated with
|
||||||
|
* the UserContext in which the connection is to be created.
|
||||||
|
*
|
||||||
* @param connection
|
* @param connection
|
||||||
* The connection to create.
|
* The connection to create.
|
||||||
*
|
*
|
||||||
@@ -244,9 +277,11 @@ public class ConnectionRESTService {
|
|||||||
@Produces(MediaType.TEXT_PLAIN)
|
@Produces(MediaType.TEXT_PLAIN)
|
||||||
@AuthProviderRESTExposure
|
@AuthProviderRESTExposure
|
||||||
public String createConnection(@QueryParam("token") String authToken,
|
public String createConnection(@QueryParam("token") String authToken,
|
||||||
|
@PathParam("dataSource") String authProviderIdentifier,
|
||||||
APIConnection connection) throws GuacamoleException {
|
APIConnection connection) throws GuacamoleException {
|
||||||
|
|
||||||
UserContext userContext = authenticationService.getUserContext(authToken);
|
GuacamoleSession session = authenticationService.getGuacamoleSession(authToken);
|
||||||
|
UserContext userContext = retrievalService.retrieveUserContext(session, authProviderIdentifier);
|
||||||
|
|
||||||
// Validate that connection data was provided
|
// Validate that connection data was provided
|
||||||
if (connection == null)
|
if (connection == null)
|
||||||
@@ -270,6 +305,10 @@ public class ConnectionRESTService {
|
|||||||
* The authentication token that is used to authenticate the user
|
* The authentication token that is used to authenticate the user
|
||||||
* performing the operation.
|
* performing the operation.
|
||||||
*
|
*
|
||||||
|
* @param authProviderIdentifier
|
||||||
|
* The unique identifier of the AuthenticationProvider associated with
|
||||||
|
* the UserContext containing the connection to be updated.
|
||||||
|
*
|
||||||
* @param connectionID
|
* @param connectionID
|
||||||
* The identifier of the connection to update.
|
* The identifier of the connection to update.
|
||||||
*
|
*
|
||||||
@@ -283,9 +322,12 @@ public class ConnectionRESTService {
|
|||||||
@Path("/{connectionID}")
|
@Path("/{connectionID}")
|
||||||
@AuthProviderRESTExposure
|
@AuthProviderRESTExposure
|
||||||
public void updateConnection(@QueryParam("token") String authToken,
|
public void updateConnection(@QueryParam("token") String authToken,
|
||||||
@PathParam("connectionID") String connectionID, APIConnection connection) throws GuacamoleException {
|
@PathParam("dataSource") String authProviderIdentifier,
|
||||||
|
@PathParam("connectionID") String connectionID,
|
||||||
|
APIConnection connection) throws GuacamoleException {
|
||||||
|
|
||||||
UserContext userContext = authenticationService.getUserContext(authToken);
|
GuacamoleSession session = authenticationService.getGuacamoleSession(authToken);
|
||||||
|
UserContext userContext = retrievalService.retrieveUserContext(session, authProviderIdentifier);
|
||||||
|
|
||||||
// Validate that connection data was provided
|
// Validate that connection data was provided
|
||||||
if (connection == null)
|
if (connection == null)
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Glyptodon LLC
|
* Copyright (C) 2015 Glyptodon LLC
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@@ -48,7 +48,7 @@ angular.module('rest').factory('connectionService', ['$injector',
|
|||||||
* // Do something with the connection
|
* // Do something with the connection
|
||||||
* });
|
* });
|
||||||
*/
|
*/
|
||||||
service.getConnection = function getConnection(id) {
|
service.getConnection = function getConnection(dataSource, id) {
|
||||||
|
|
||||||
// Build HTTP parameters set
|
// Build HTTP parameters set
|
||||||
var httpParameters = {
|
var httpParameters = {
|
||||||
@@ -59,7 +59,7 @@ angular.module('rest').factory('connectionService', ['$injector',
|
|||||||
return $http({
|
return $http({
|
||||||
cache : cacheService.connections,
|
cache : cacheService.connections,
|
||||||
method : 'GET',
|
method : 'GET',
|
||||||
url : 'api/connections/' + encodeURIComponent(id),
|
url : 'api/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(id),
|
||||||
params : httpParameters
|
params : httpParameters
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ angular.module('rest').factory('connectionService', ['$injector',
|
|||||||
* A promise which will resolve with an array of
|
* A promise which will resolve with an array of
|
||||||
* @link{ConnectionHistoryEntry} objects upon success.
|
* @link{ConnectionHistoryEntry} objects upon success.
|
||||||
*/
|
*/
|
||||||
service.getConnectionHistory = function getConnectionHistory(id) {
|
service.getConnectionHistory = function getConnectionHistory(dataSource, id) {
|
||||||
|
|
||||||
// Build HTTP parameters set
|
// Build HTTP parameters set
|
||||||
var httpParameters = {
|
var httpParameters = {
|
||||||
@@ -87,7 +87,7 @@ angular.module('rest').factory('connectionService', ['$injector',
|
|||||||
// Retrieve connection history
|
// Retrieve connection history
|
||||||
return $http({
|
return $http({
|
||||||
method : 'GET',
|
method : 'GET',
|
||||||
url : 'api/connections/' + encodeURIComponent(id) + '/history',
|
url : 'api/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(id) + '/history',
|
||||||
params : httpParameters
|
params : httpParameters
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ angular.module('rest').factory('connectionService', ['$injector',
|
|||||||
* A promise which will resolve with an map of parameter name/value
|
* A promise which will resolve with an map of parameter name/value
|
||||||
* pairs upon success.
|
* pairs upon success.
|
||||||
*/
|
*/
|
||||||
service.getConnectionParameters = function getConnectionParameters(id) {
|
service.getConnectionParameters = function getConnectionParameters(dataSource, id) {
|
||||||
|
|
||||||
// Build HTTP parameters set
|
// Build HTTP parameters set
|
||||||
var httpParameters = {
|
var httpParameters = {
|
||||||
@@ -116,7 +116,7 @@ angular.module('rest').factory('connectionService', ['$injector',
|
|||||||
return $http({
|
return $http({
|
||||||
cache : cacheService.connections,
|
cache : cacheService.connections,
|
||||||
method : 'GET',
|
method : 'GET',
|
||||||
url : 'api/connections/' + encodeURIComponent(id) + '/parameters',
|
url : 'api/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(id) + '/parameters',
|
||||||
params : httpParameters
|
params : httpParameters
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ angular.module('rest').factory('connectionService', ['$injector',
|
|||||||
* A promise for the HTTP call which will succeed if and only if the
|
* A promise for the HTTP call which will succeed if and only if the
|
||||||
* save operation is successful.
|
* save operation is successful.
|
||||||
*/
|
*/
|
||||||
service.saveConnection = function saveConnection(connection) {
|
service.saveConnection = function saveConnection(dataSource, connection) {
|
||||||
|
|
||||||
// Build HTTP parameters set
|
// Build HTTP parameters set
|
||||||
var httpParameters = {
|
var httpParameters = {
|
||||||
@@ -146,7 +146,7 @@ angular.module('rest').factory('connectionService', ['$injector',
|
|||||||
if (!connection.identifier) {
|
if (!connection.identifier) {
|
||||||
return $http({
|
return $http({
|
||||||
method : 'POST',
|
method : 'POST',
|
||||||
url : 'api/connections',
|
url : 'api/data/' + encodeURIComponent(dataSource) + '/connections',
|
||||||
params : httpParameters,
|
params : httpParameters,
|
||||||
data : connection
|
data : connection
|
||||||
})
|
})
|
||||||
@@ -162,7 +162,7 @@ angular.module('rest').factory('connectionService', ['$injector',
|
|||||||
else {
|
else {
|
||||||
return $http({
|
return $http({
|
||||||
method : 'PUT',
|
method : 'PUT',
|
||||||
url : 'api/connections/' + encodeURIComponent(connection.identifier),
|
url : 'api/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(connection.identifier),
|
||||||
params : httpParameters,
|
params : httpParameters,
|
||||||
data : connection
|
data : connection
|
||||||
})
|
})
|
||||||
@@ -185,7 +185,7 @@ angular.module('rest').factory('connectionService', ['$injector',
|
|||||||
* A promise for the HTTP call which will succeed if and only if the
|
* A promise for the HTTP call which will succeed if and only if the
|
||||||
* delete operation is successful.
|
* delete operation is successful.
|
||||||
*/
|
*/
|
||||||
service.deleteConnection = function deleteConnection(connection) {
|
service.deleteConnection = function deleteConnection(dataSource, connection) {
|
||||||
|
|
||||||
// Build HTTP parameters set
|
// Build HTTP parameters set
|
||||||
var httpParameters = {
|
var httpParameters = {
|
||||||
@@ -195,7 +195,7 @@ angular.module('rest').factory('connectionService', ['$injector',
|
|||||||
// Delete connection
|
// Delete connection
|
||||||
return $http({
|
return $http({
|
||||||
method : 'DELETE',
|
method : 'DELETE',
|
||||||
url : 'api/connections/' + encodeURIComponent(connection.identifier),
|
url : 'api/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(connection.identifier),
|
||||||
params : httpParameters
|
params : httpParameters
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user