Package com.inesm.KeyManager.services
Class SessionService
java.lang.Object
com.inesm.KeyManager.services.SessionService
Provides a access control and authorization.
-
Constructor Summary
ConstructorsConstructorDescriptionSessionService(UserManager userManager, MessageManager messageManager, RequestService reqService, KeyManager keyManager, SettingsService settings) Session Service Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidCreates a new session.voidDistributes the results of an operation.voiddistribute(int operationID, Resource data) Distributes the results of an operation.Gets the current station.Gets the current user registered in the session.voidIntercept an operation.voidinterceptRequest(Request request) Intercepts a request.voidlogout()Destroys the current session.voidChecks if a user is currently the one associated with the session.voidupdate()Updates a session's permissions.voidvalidate(int operation_id) Validates an operation for the current user.
-
Constructor Details
-
SessionService
@Autowired public SessionService(UserManager userManager, MessageManager messageManager, RequestService reqService, KeyManager keyManager, SettingsService settings) Session Service Constructor.- Parameters:
userManager- the service that provides user management functionalitiesmessageManager- the service that provides message management functionalitiesreqService- the service that provides requests functionalitieskeyManager- the service that provides key management functionalitiessettings- the service that provides settings
-
-
Method Details
-
create
Creates a new session.- Parameters:
user- the user associated with the session
-
update
public void update()Updates a session's permissions. -
selfCheck
Checks if a user is currently the one associated with the session.- Parameters:
user- the user to be checked, must have username set- Throws:
PermissionDeniedException- if the user is not the same associated with the current session, or not defined
-
validate
Validates an operation for the current user.- Parameters:
operation_id- the operationID of the operation- Throws:
SessionTimeoutException- if the session timed outPermissionDeniedException- if the user is not authorized to perform the specified operation
-
logout
public void logout()Destroys the current session. -
getCurrentUser
Gets the current user registered in the session.- Returns:
- the user retrieved
-
getCurrentStation
Gets the current station.- Returns:
- the station retrieved
-
intercept
public void intercept(int operationID, Resource data) throws ObjectNotMappedException, InvalidParametersException, NoLoneZoneException, GlobalOperationException, OperationNotSupportedException Intercept an operation. Used to enforce no-lone zones and account for mission ownership.- Parameters:
operationID- the operationID of the operationdata- the input data of the operation- Throws:
ObjectNotMappedException- if the input data received mapped to a object that is not mapped in the applicationInvalidParametersException- if the shared resource contained an invalid missionUUIDNoLoneZoneException- if the operation provided was a no-lone zoneGlobalOperationException- if the resource used in the operation was not owned by the current stationOperationNotSupportedException- if the resource used in the operation was not owned by the current station and the operation cannot be requested to another station
-
interceptRequest
public void interceptRequest(Request request) throws InvalidParametersException, ObjectNotMappedException, GlobalOperationException, OperationNotSupportedException Intercepts a request.- Parameters:
request- the request to be intercepted- Throws:
InvalidParametersException- if the shared resource contained an invalid missionUUIDGlobalOperationException- if the resource used in the operation was not owned by the current stationObjectNotMappedException- if the request data mapped to a object that is not mapped in the applicationOperationNotSupportedException- if the resource used in the operation was not owned by the current station and the operation cannot be requested to another station
-
distribute
public void distribute(int operationID, Resource data) throws InvalidParametersException, ObjectNotMappedException Distributes the results of an operation. If the resource manipulated in the operation is a shared resource, will send the operation information to all stations that share that resource.- Parameters:
operationID- the operationID of the operation.data- the input data of the operation- Throws:
InvalidParametersException- if the shared resource contained an invalid missionUUID ObjectNotMappedExceptionObjectNotMappedException- if the input data received mapped to an object that is not mapped in the application
-
distribute
public void distribute(int operationID, Mission mission, List<Station> added, List<Station> removed) throws InvalidParametersException, ObjectNotMappedException, ObjectNotFoundException Distributes the results of an operation. If the resource manipulated in the operation is a shared resource, will send the operation information to all stations that share that resource.Specific distribute function for mission updates where shared stations and mission owners may have been updated by the application, so it is necessary to add information about who used to share the resource or who used to own it.
Also, if any station is added to the mission sharing, it will send an extra message for mission creation and for those who are removed from sharing it will simply send a delete message.
- Parameters:
operationID- the operationID of the operationmission- the mission being updatedadded- the newly added shared stations to the missionremoved- the newly removed shared stations from the mission- Throws:
InvalidParametersException- if the shared resource contained an invalid missionUUID ObjectNotMappedExceptionObjectNotMappedException- if the input data received mapped to an object that is not mapped in the applicationObjectNotFoundException- if the mission specified could not be found
-