Package com.inesm.KeyManager.controller
Class UserController
java.lang.Object
com.inesm.KeyManager.controller.Controller
com.inesm.KeyManager.controller.UserController
@RestController
@CrossOrigin(origins={"http://127.0.0.1:4200","http://localhost:4200"})
@RequestMapping("/users")
public class UserController
extends Controller
REST Controller for the users endpoint.
-
Constructor Summary
ConstructorsConstructorDescriptionUserController(UserManager userManager, SessionService session, AppInterface appInterface, LoggerService logger) Constructor for UserController class. -
Method Summary
Modifier and TypeMethodDescriptioncreateUser(javax.servlet.http.HttpServletRequest request) Creates a user in the station.deleteSelf(javax.servlet.http.HttpServletRequest request) Deletes the current user.deleteUser(javax.servlet.http.HttpServletRequest request) Deletes a user in the station.getUser(javax.servlet.http.HttpServletRequest request) Gets a user from the station.Gets all user from the station.login(javax.servlet.http.HttpServletRequest request) Logs a user into the station.voidlogout()Logs out a user from the stationupdateSelfUserPassword(javax.servlet.http.HttpServletRequest request) Updates the current user's password in the station.updateUser(javax.servlet.http.HttpServletRequest request) Updates a user in the station.updateUserPassword(javax.servlet.http.HttpServletRequest request) Updates a user's password in the station.
-
Constructor Details
-
UserController
@Autowired public UserController(UserManager userManager, SessionService session, AppInterface appInterface, LoggerService logger) Constructor for UserController class.- Parameters:
session- the session service to be useduserManager- the user manager to be usedappInterface- the class that defines the interface between java and json objectslogger- the logger service
-
-
Method Details
-
login
@PostMapping(path="login", consumes="application/json;charset=UTF-8", produces="application/json;charset=UTF-8") public String login(javax.servlet.http.HttpServletRequest request) throws JsonBadSintaxException, RequestReadException, ObjectNotFoundException, InvalidLoginException, LoginAttemptLockedException, ResourceLockedException Logs a user into the station.- Parameters:
request- the HTTP request received, containing a user object in JSON format, with the username and password set- Returns:
- a string containing the user object JSON format
- Throws:
JsonBadSintaxException- 400 | Invalid Payload | If the JSON received contained incorrect syntax or mission fieldsRequestReadException- 500 | Couldn't Read Request Body | If the application could not retrieve the request body of the HTTP requestObjectNotFoundException- 400 | Object Not Found | If the requested resource was not found.InvalidLoginException- 401 | Invalid Username/Password | If the login operation failed due to password mismatch, or an hashing operation errorLoginAttemptLockedException- 423 | Login Locked | If the user is currently locked from attempting loginsResourceLockedException- 400 | Resource Locked | If the user is not active
-
getUser
@PostMapping(path="get", consumes="application/json;charset=UTF-8", produces="application/json;charset=UTF-8") public String getUser(javax.servlet.http.HttpServletRequest request) throws ObjectNotFoundException, SessionTimeoutException, PermissionDeniedException, JsonBadSintaxException, RequestReadException, ObjectNotMappedException, InvalidParametersException, NoLoneZoneException, GlobalOperationException, OperationNotSupportedException Gets a user from the station.- Parameters:
request- the HTTP request received, containing a user object in JSON format, with the username set- Returns:
- a string containing the user object JSON format
- Throws:
ObjectNotFoundException- 400 | Object Not Found | If the requested resource was not foundInvalidParametersException- 400 | Invalid Parameters | If there are invalid fields for the resource are providedNoLoneZoneException- 202 | No-Lone Zone | If the operation is classified as a no-lone zoneGlobalOperationException- 202 | Global Operation | If the resource is not owned by the current stationOperationNotSupportedException- 400 | Invalid Operation Request | if the operation is not mappedSessionTimeoutException- 401 | Session Timeout | If the session timed outPermissionDeniedException- 403 | Permission Denied | If the user is not authorized to access this operationJsonBadSintaxException- 400 | Invalid Payload | If the JSON received contained incorrect syntax or mission fieldsRequestReadException- 500 | Couldn't Read Request Body | If the application could not retrieve the request body of the HTTP requestObjectNotMappedException- 500 | Object Not Mapped | If the input data received mapped to an object that is not mapped in the application
-
listUsers
@PostMapping(path="list", produces="application/json;charset=UTF-8") public String listUsers() throws SessionTimeoutException, PermissionDeniedExceptionGets all user from the station.- Returns:
- a string containing the user list in JSON array format
- Throws:
SessionTimeoutException- 401 | Session Timeout | If the session timed outPermissionDeniedException- 403 | Permission Denied | If the user is not authorized to access this operation
-
createUser
@PostMapping(path="create", consumes="application/json;charset=UTF-8", produces="application/json;charset=UTF-8") public String createUser(javax.servlet.http.HttpServletRequest request) throws InvalidParametersException, SessionTimeoutException, PermissionDeniedException, JsonBadSintaxException, RequestReadException, ObjectNotMappedException, NoLoneZoneException, GlobalOperationException, OperationNotSupportedException, HashingErrorException Creates a user in the station.- Parameters:
request- the HTTP request received, containing a user object in JSON format- Returns:
- a string containing the created user object JSON format
- Throws:
InvalidParametersException- 400 | Invalid Parameters | If there are invalid fields for the resource are providedNoLoneZoneException- 202 | No-Lone Zone | If the operation is classified as a no-lone zoneGlobalOperationException- 202 | Global Operation | If the resource is not owned by the current stationOperationNotSupportedException- 400 | Invalid Operation Request | if the operation is not mappedSessionTimeoutException- 401 | Session Timeout | If the session timed outPermissionDeniedException- 403 | Permission Denied | If the user is not authorized to access this operationJsonBadSintaxException- 400 | Invalid Payload | If the JSON received contained incorrect syntax or mission fieldsRequestReadException- 500 | Couldn't Read Request Body | If the application could not retrieve the request body of the HTTP requestObjectNotMappedException- 500 | Object Not Mapped | If the input data received mapped to an object that is not mapped in the applicationHashingErrorException- 500 | Hashing Error | If an error occurred hashing the user password
-
updateUser
@PostMapping(path="update", consumes="application/json;charset=UTF-8", produces="application/json;charset=UTF-8") public String updateUser(javax.servlet.http.HttpServletRequest request) throws ObjectNotFoundException, SessionTimeoutException, PermissionDeniedException, JsonBadSintaxException, RequestReadException, ObjectNotMappedException, InvalidParametersException, NoLoneZoneException, GlobalOperationException, OperationNotSupportedException Updates a user in the station.- Parameters:
request- the HTTP request received, containing a user object in JSON format- Returns:
- a string containing the updated user object JSON format
- Throws:
ObjectNotFoundException- 400 | Object Not Found | If the requested resource was not foundInvalidParametersException- 400 | Invalid Parameters | If there are invalid fields for the resource are providedNoLoneZoneException- 202 | No-Lone Zone | If the operation is classified as a no-lone zoneGlobalOperationException- 202 | Global Operation | If the resource is not owned by the current stationOperationNotSupportedException- 400 | Invalid Operation Request | if the operation is not mappedSessionTimeoutException- 401 | Session Timeout | If the session timed outPermissionDeniedException- 403 | Permission Denied | If the user is not authorized to access this operationJsonBadSintaxException- 400 | Invalid Payload | If the JSON received contained incorrect syntax or mission fieldsRequestReadException- 500 | Couldn't Read Request Body | If the application could not retrieve the request body of the HTTP requestObjectNotMappedException- 500 | Object Not Mapped | If the input data received mapped to an object that is not mapped in the application
-
deleteUser
@PostMapping(path="delete", consumes="application/json;charset=UTF-8", produces="application/json;charset=UTF-8") public String deleteUser(javax.servlet.http.HttpServletRequest request) throws ObjectNotFoundException, SessionTimeoutException, PermissionDeniedException, JsonBadSintaxException, RequestReadException, ObjectNotMappedException, InvalidParametersException, NoLoneZoneException, GlobalOperationException, OperationNotSupportedException Deletes a user in the station.- Parameters:
request- the HTTP request received, containing a user object in JSON format with the username set- Returns:
- a string containing the delete user in JSON format
- Throws:
ObjectNotFoundException- 400 | Object Not Found | If the requested resource was not foundInvalidParametersException- 400 | Invalid Parameters | If there are invalid fields for the resource are providedNoLoneZoneException- 202 | No-Lone Zone | If the operation is classified as a no-lone zoneGlobalOperationException- 202 | Global Operation | If the resource is not owned by the current stationOperationNotSupportedException- 400 | Invalid Operation Request | if the operation is not mappedSessionTimeoutException- 401 | Session Timeout | If the session timed outPermissionDeniedException- 403 | Permission Denied | If the user is not authorized to access this operationJsonBadSintaxException- 400 | Invalid Payload | If the JSON received contained incorrect syntax or mission fieldsRequestReadException- 500 | Couldn't Read Request Body | If the application could not retrieve the request body of the HTTP requestObjectNotMappedException- 500 | Object Not Mapped | If the input data received mapped to an object that is not mapped in the application
-
updateUserPassword
@PostMapping(path="update/password", consumes="application/json;charset=UTF-8", produces="application/json;charset=UTF-8") public String updateUserPassword(javax.servlet.http.HttpServletRequest request) throws ObjectNotFoundException, SessionTimeoutException, PermissionDeniedException, JsonBadSintaxException, RequestReadException, ObjectNotMappedException, InvalidParametersException, NoLoneZoneException, GlobalOperationException, OperationNotSupportedException, HashingErrorException Updates a user's password in the station.- Parameters:
request- the HTTP request received, containing a user object in JSON format with the username and password set- Returns:
- a string containing the user in JSON format
- Throws:
ObjectNotFoundException- 400 | Object Not Found | If the requested resource was not foundInvalidParametersException- 400 | Invalid Parameters | If there are invalid fields for the resource are providedNoLoneZoneException- 202 | No-Lone Zone | If the operation is classified as a no-lone zoneGlobalOperationException- 202 | Global Operation | If the resource is not owned by the current stationOperationNotSupportedException- 400 | Invalid Operation Request | if the operation is not mappedSessionTimeoutException- 401 | Session Timeout | If the session timed outPermissionDeniedException- 403 | Permission Denied | If the user is not authorized to access this operationJsonBadSintaxException- 400 | Invalid Payload | If the JSON received contained incorrect syntax or mission fieldsRequestReadException- 500 | Couldn't Read Request Body | If the application could not retrieve the request body of the HTTP requestObjectNotMappedException- 500 | Object Not Mapped | If the input data received mapped to an object that is not mapped in the applicationHashingErrorException- 500 | Hashing Error | If an error occurred hashing the user passwords
-
updateSelfUserPassword
@PostMapping(path="update/password/self", consumes="application/json;charset=UTF-8", produces="application/json;charset=UTF-8") public String updateSelfUserPassword(javax.servlet.http.HttpServletRequest request) throws ObjectNotFoundException, SessionTimeoutException, PermissionDeniedException, JsonBadSintaxException, RequestReadException, InvalidParametersException, ObjectNotMappedException, NoLoneZoneException, GlobalOperationException, OperationNotSupportedException, HashingErrorException Updates the current user's password in the station.- Parameters:
request- the HTTP request received, containing a user object in JSON format with the username and password set- Returns:
- a string containing the user in JSON format
- Throws:
ObjectNotFoundException- 400 | Object Not Found | If the requested resource was not foundInvalidParametersException- 400 | Invalid Parameters | If there are invalid fields for the resource are providedNoLoneZoneException- 202 | No-Lone Zone | If the operation is classified as a no-lone zoneGlobalOperationException- 202 | Global Operation | If the resource is not owned by the current stationOperationNotSupportedException- 400 | Invalid Operation Request | if the operation is not mappedSessionTimeoutException- 401 | Session Timeout | If the session timed outPermissionDeniedException- 403 | Permission Denied | If the user is not authorized to access this operation or if the user is not the same associated with the current sessionJsonBadSintaxException- 400 | Invalid Payload | If the JSON received contained incorrect syntax or mission fieldsRequestReadException- 500 | Couldn't Read Request Body | If the application could not retrieve the request body of the HTTP requestObjectNotMappedException- 500 | Object Not Mapped | If the input data received mapped to an object that is not mapped in the applicationHashingErrorException- 500 | Hashing Error | If an error occurred hashing the user passwords
-
deleteSelf
@PostMapping(path="delete/self", consumes="application/json;charset=UTF-8", produces="application/json;charset=UTF-8") public String deleteSelf(javax.servlet.http.HttpServletRequest request) throws ObjectNotFoundException, SessionTimeoutException, PermissionDeniedException, JsonBadSintaxException, RequestReadException, InvalidParametersException, ObjectNotMappedException, NoLoneZoneException, GlobalOperationException, OperationNotSupportedException Deletes the current user.- Parameters:
request- the HTTP request received, containing a user object in JSON format with the username set- Returns:
- a string containing the deleted user in JSON format
- Throws:
ObjectNotFoundException- 400 | Object Not Found | If the requested resource was not foundInvalidParametersException- 400 | Invalid Parameters | If there are invalid fields for the resource are providedNoLoneZoneException- 202 | No-Lone Zone | If the operation is classified as a no-lone zoneGlobalOperationException- 202 | Global Operation | If the resource is not owned by the current stationOperationNotSupportedException- 400 | Invalid Operation Request | if the operation is not mappedSessionTimeoutException- 401 | Session Timeout | If the session timed outPermissionDeniedException- 403 | Permission Denied | If the user is not authorized to access this operation or if the user is not the same associated with the current sessionJsonBadSintaxException- 400 | Invalid Payload | If the JSON received contained incorrect syntax or mission fieldsRequestReadException- 500 | Couldn't Read Request Body | If the application could not retrieve the request body of the HTTP requestObjectNotMappedException- 500 | Object Not Mapped | If the input data received mapped to an object that is not mapped in the application
-
logout
Logs out a user from the station- Throws:
SessionTimeoutException- 401 | Session Timeout | If the session timed out
-