Class SessionService

java.lang.Object
com.inesm.KeyManager.services.SessionService

@Service public class SessionService extends Object
Provides a access control and authorization.
  • 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 functionalities
      messageManager - the service that provides message management functionalities
      reqService - the service that provides requests functionalities
      keyManager - the service that provides key management functionalities
      settings - the service that provides settings
  • Method Details

    • create

      public void create(User user)
      Creates a new session.
      Parameters:
      user - the user associated with the session
    • update

      public void update()
      Updates a session's permissions.
    • selfCheck

      public void selfCheck(User user) throws PermissionDeniedException
      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

      public void validate(int operation_id) throws SessionTimeoutException, PermissionDeniedException
      Validates an operation for the current user.
      Parameters:
      operation_id - the operationID of the operation
      Throws:
      SessionTimeoutException - if the session timed out
      PermissionDeniedException - if the user is not authorized to perform the specified operation
    • logout

      public void logout()
      Destroys the current session.
    • getCurrentUser

      public User getCurrentUser()
      Gets the current user registered in the session.
      Returns:
      the user retrieved
    • getCurrentStation

      public Station getCurrentStation()
      Gets the current station.
      Returns:
      the station retrieved
    • intercept

      Intercept an operation. Used to enforce no-lone zones and account for mission ownership.
      Parameters:
      operationID - the operationID of the operation
      data - the input data of the operation
      Throws:
      ObjectNotMappedException - if the input data received mapped to a object that is not mapped in the application
      InvalidParametersException - if the shared resource contained an invalid missionUUID
      NoLoneZoneException - if the operation provided was a no-lone zone
      GlobalOperationException - if the resource used in the operation was not owned by the current station
      OperationNotSupportedException - if the resource used in the operation was not owned by the current station and the operation cannot be requested to another station
    • interceptRequest

      Intercepts a request.
      Parameters:
      request - the request to be intercepted
      Throws:
      InvalidParametersException - if the shared resource contained an invalid missionUUID
      GlobalOperationException - if the resource used in the operation was not owned by the current station
      ObjectNotMappedException - if the request data mapped to a object that is not mapped in the application
      OperationNotSupportedException - 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 ObjectNotMappedException
      ObjectNotMappedException - 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 operation
      mission - the mission being updated
      added - the newly added shared stations to the mission
      removed - the newly removed shared stations from the mission
      Throws:
      InvalidParametersException - if the shared resource contained an invalid missionUUID ObjectNotMappedException
      ObjectNotMappedException - if the input data received mapped to an object that is not mapped in the application
      ObjectNotFoundException - if the mission specified could not be found