Class PsToken

  • All Implemented Interfaces:
    Pass

    public final class PsToken
    extends Object
    implements Pass
    Pass with JSON Web Token (JWT).

    The class is immutable and thread-safe.

    Since:
    1.4
    • Constructor Detail

      • PsToken

        public PsToken​(String key)
        Ctor. This is equivalent to PsToken(key, 3600), signing with 256 bit.
        Parameters:
        key - The secret key to sign with
      • PsToken

        public PsToken​(String key,
                       long seconds)
        Ctor. This uses a 256-bit HMAC signature.
        Parameters:
        key - The secret key to sign with
        seconds - The life span of the token.
    • Method Detail

      • enter

        public Opt<Identity> enter​(Request req)
                            throws IOException
        Description copied from interface: Pass
        Authenticate the user by the request.
        Specified by:
        enter in interface Pass
        Parameters:
        req - The request
        Returns:
        Identity of the user found
        Throws:
        IOException
      • exit

        public Response exit​(Response res,
                             Identity idt)
                      throws Exception
        Description copied from interface: Pass
        Wrap the response with the user.
        Specified by:
        exit in interface Pass
        Parameters:
        res - Response
        idt - Identity
        Returns:
        New response
        Throws:
        Exception - If fails