mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUAC-932: Update protocol service to use Protocol class. Remove single permission add/remove from REST service.
This commit is contained in:
@@ -101,65 +101,6 @@ public class PermissionRESTService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a permissions for a user with the given userID.
|
|
||||||
*
|
|
||||||
* @param authToken The authentication token that is used to authenticate
|
|
||||||
* the user performing the operation.
|
|
||||||
* @param userID The user ID to add the permission for.
|
|
||||||
* @param permission The permission to add for the user with the given userID.
|
|
||||||
* @throws GuacamoleException If a problem is encountered while adding the permission.
|
|
||||||
*/
|
|
||||||
@POST
|
|
||||||
@Path("/{userID}")
|
|
||||||
@AuthProviderRESTExposure
|
|
||||||
public void addPermission(@QueryParam("token") String authToken,
|
|
||||||
@PathParam("userID") String userID, APIPermission permission)
|
|
||||||
throws GuacamoleException {
|
|
||||||
|
|
||||||
UserContext userContext = authenticationService.getUserContext(authToken);
|
|
||||||
|
|
||||||
// Get the user
|
|
||||||
User user = userContext.getUserDirectory().get(userID);
|
|
||||||
if (user == null)
|
|
||||||
throw new HTTPException(Status.NOT_FOUND, "User not found with the provided userID.");
|
|
||||||
|
|
||||||
// Add the new permission
|
|
||||||
user.addPermission(permission.toPermission());
|
|
||||||
userContext.getUserDirectory().update(user);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a permissions for a user with the given userID.
|
|
||||||
*
|
|
||||||
* @param authToken The authentication token that is used to authenticate
|
|
||||||
* the user performing the operation.
|
|
||||||
* @param userID The user ID to remove the permission for.
|
|
||||||
* @param permission The permission to remove for the user with the given userID.
|
|
||||||
* @throws GuacamoleException If a problem is encountered while removing the permission.
|
|
||||||
*/
|
|
||||||
@POST
|
|
||||||
@Path("/remove/{userID}/")
|
|
||||||
@AuthProviderRESTExposure
|
|
||||||
public void removePermission(@QueryParam("token") String authToken,
|
|
||||||
@PathParam("userID") String userID, APIPermission permission)
|
|
||||||
throws GuacamoleException {
|
|
||||||
|
|
||||||
UserContext userContext = authenticationService.getUserContext(authToken);
|
|
||||||
|
|
||||||
// Get the user
|
|
||||||
User user = userContext.getUserDirectory().get(userID);
|
|
||||||
if (user == null)
|
|
||||||
throw new HTTPException(Status.NOT_FOUND, "User not found with the provided userID.");
|
|
||||||
|
|
||||||
// Remove the permission
|
|
||||||
user.removePermission(permission.toPermission());
|
|
||||||
userContext.getUserDirectory().update(user);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies a given list of permission patches.
|
* Applies a given list of permission patches.
|
||||||
*
|
*
|
||||||
|
@@ -28,14 +28,18 @@ angular.module('rest').factory('protocolService', ['$http', function protocolSer
|
|||||||
var service = {};
|
var service = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a request to the REST API to get the list of protocols,
|
* Makes a request to the REST API to get the list of protocols, returning
|
||||||
* returning a promise that can be used for processing the results of the call.
|
* a promise that provides an array of @link{Protocol} objects if
|
||||||
|
* successful.
|
||||||
*
|
*
|
||||||
* @returns {promise} A promise for the HTTP call.
|
* @returns {Promise.<Protocol[]>}
|
||||||
|
* A promise which will resolve with an array of @link{Protocol}
|
||||||
|
* objects upon success.
|
||||||
*/
|
*/
|
||||||
service.getProtocols = function getProtocols() {
|
service.getProtocols = function getProtocols() {
|
||||||
return $http.get("api/protocol");
|
return $http.get("api/protocol");
|
||||||
};
|
};
|
||||||
|
|
||||||
return service;
|
return service;
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
Reference in New Issue
Block a user