Interface SessionToken

  • All Superinterfaces:
    Serializable

    public interface SessionToken
    extends Serializable
    A session token identifies a session in ADEPT2. A session is used to synchronise access from and to different system components in ADEPT2. This is related to hierarchical transactions in database management systems. Every method offered by an ADEPT2-service needs a session token. This allows the component to synchronise the execution of the method with other currently running requests. Since requests can be arbitrarily nested, session can also be nested. Therefore a session token provides access to its parent session. Parent and child sessions have a common UUID (getSessionID()) as well as a UUID specific for the token (getChildSessionID()). This allows to either lock and synchronise on a session token hierarchy or on a single session token.

    Session tokens carry a security token for identifying the user and the corresponding rights. Security tokens are created when the user has successfully logged on and they are encapsulated by session token factories. They are always signed with the private key of the security manager. This ensures their integrity. It is always checked against the public key of the security manager when accessing the security token.

    A session token is used like a transaction in a database management system, and has nothing to do with a user session, for instance a session in a web browser. The latter corresponds to a session factory in ADEPT2. This is retrieved when logging on and used until logging off.

    Session tokens are serialisable lightweight objects which can be created arbitrarily. This requires to overwrite Object.equals(Object) and Object.hashCode() in the implementation. A nice string representation Object.toString() is also very useful, for instance for LockExceptions.

    Author:
    Ulrich Kreher
    • Field Detail

      • serialVersionUID

        static final long serialVersionUID
        Generated ID for serialisation.
        See Also:
        Constant Field Values
    • Method Detail

      • getSessionID

        UUID getSessionID()
        Gets the ID to uniquely identify the session token hierarchy. In case of a child session the ID equals the ID of the top-level session.
        Returns:
        The unique ID of the top-level session token.
      • getChildSessionID

        UUID getChildSessionID()
        Gets the ID to uniquely identify the child session-token. In case of a top-level session this ID equals getSessionID().
        Returns:
        The unique ID of this child session-token (different from the ID of the parent session).
      • getChildLevel

        int getChildLevel()
        Gets the level of the child, 0 is the parent session.
        Returns:
        The level of the child starting with 0 for the top-level session.
      • getParentSession

        SessionToken getParentSession()
        Gets a reference to the parent session if this session is a child session, or a reference to this session in case of a top-level session.
        Returns:
        The parent session token or this in case this session has no parent.
      • isAncestorSession

        boolean isAncestorSession​(SessionToken session)
        Gets whether the designated session is a transitive parent session of this session.
        Parameters:
        session - The session token which to check for whether it is a transitive parent session of this session.
        Returns:
        Whether the designated session is a transitive parent session of this session.
      • getSecurityToken

        SignedSecurityToken getSecurityToken()
        Gets the security token (signed) which identifies the user for this session. The called component can verify whether the requesting user has the necessary rights for the operation.
        A security token does not need to be inherited, it may be replaced by the called component (in a child session) with a privileged security token.
        Returns:
        The security token for this session token allowing to check for sufficient access rights.
      • getTopLevelSecurityToken

        SignedSecurityToken getTopLevelSecurityToken()
        Gets the security token (signed) of the top-level parent session token of this session token. This allows to retrieve the initial security context of this session token hierarchy.
        Returns:
        The security token for top-level parent of this session token.
      • getCallingComponent

        URI[] getCallingComponent()
        Gets communication protocol depended references to the ADEPT2-component which has initiated this session, for instance, ADEPT2Editor, ExecutionManager, ...
        Returns:
        The communication protocol depended URIs identifying the initiating component of the session.
      • getChildCallingComponent

        URI[] getChildCallingComponent()
        Gets the URIs for the component which has created this subsession. In case of a top-level session this equals getCallingComponent().
        Returns:
        The component URIs identifying the component creating this subsession.
      • getAdditionalAttributeValue

        String getAdditionalAttributeValue​(String attributeName)
        Returns the value of the additional attribute set when the token has been created. If the value is not set in the current session token, its parent will be asked for the attribute value. If the designated attribute does not exist in any ancestor, null will be returned.
        Parameters:
        attributeName - The name of the additional attribute.
        Returns:
        The value of the additional attribute or null in case the attribute does not exist (or it is deliberately null).