Class JwtManager

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.jose4j.jwt.JwtClaims generateDefaultClaims​(Member mbr, java.lang.String issuer, float expiration)
      generate default claims
      org.jose4j.jwt.JwtClaims generateDefaultClaims​(Member mbr, java.lang.String issuer, float expiration, java.lang.String url, java.lang.Integer prefixLength, java.util.List<java.lang.String> methodList, java.lang.String ipMask)
      generate default claims
      java.lang.String generateToken​(java.security.PrivateKey key, Member mbr, java.lang.String issuer, float expiration, java.lang.String url, java.lang.Integer prefixLength, java.util.List<java.lang.String> methodList, java.lang.String ipMask)
      generate default claims
      java.lang.String generateToken​(org.jose4j.jwt.JwtClaims claims, java.io.File privateKeyFile, java.lang.String password)
      Generate a Jwt token
      java.lang.String generateToken​(org.jose4j.jwt.JwtClaims claims, java.security.PrivateKey key)
      Generate a Jwt token
      java.lang.String generateToken​(org.jose4j.jwt.JwtClaims claims, java.security.PrivateKey key, java.security.PublicKey receiverKey)
      Generate a encrypted Jwt token
      static JwtManager getInstance()  
      void propertiesChange​(JProperties properties)
      Invoked after properties have been modified in JCMS and save on disk.
      org.jose4j.jwt.JwtClaims readToken​(java.lang.String token, java.security.PublicKey key)
      Read a token against the provided publicKey
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInstance

        public static JwtManager getInstance()
      • propertiesChange

        public void propertiesChange​(JProperties properties)
        Description copied from interface: JPropertiesListener
        Invoked after properties have been modified in JCMS and save on disk.

        You cannot alter the value received in parameters.

        Note that properties parameter may be null, a limited set of site properties, or all site properties.

        To check that a property has been modified, reload the "current" property instead using channel.getProperties or channel.getProperty.

        Specified by:
        propertiesChange in interface JPropertiesListener
        Parameters:
        properties - the properties which have been submitted to change
      • readToken

        public org.jose4j.jwt.JwtClaims readToken​(java.lang.String token,
                                                  java.security.PublicKey key)
        Read a token against the provided publicKey
        Parameters:
        token - the JWT token
        key - the public Key
        Returns:
        the JwtClaims is token can be read and if it 's valid, null otherwise
      • generateToken

        public java.lang.String generateToken​(org.jose4j.jwt.JwtClaims claims,
                                              java.io.File privateKeyFile,
                                              java.lang.String password)
                                       throws org.jose4j.lang.JoseException
        Generate a Jwt token
        Parameters:
        claims - the claims
        privateKeyFile - the PrivateKey file to encrypt with
        password - the password of the PrivateKey
        Returns:
        the JWT token
        Throws:
        org.jose4j.lang.JoseException - thrown if the token cannot be generated
      • generateToken

        public java.lang.String generateToken​(org.jose4j.jwt.JwtClaims claims,
                                              java.security.PrivateKey key)
                                       throws org.jose4j.lang.JoseException
        Generate a Jwt token
        Parameters:
        claims - the claims
        key - the PrivateKey file to encrypt with
        Returns:
        the JWT token
        Throws:
        org.jose4j.lang.JoseException - thrown if the token cannot be generated
      • generateToken

        public java.lang.String generateToken​(java.security.PrivateKey key,
                                              Member mbr,
                                              java.lang.String issuer,
                                              float expiration,
                                              java.lang.String url,
                                              java.lang.Integer prefixLength,
                                              java.util.List<java.lang.String> methodList,
                                              java.lang.String ipMask)
                                       throws org.jose4j.lang.JoseException
        generate default claims
        Parameters:
        key - the PrivateKey file to encrypt with
        mbr - the Member as subject
        issuer - the issuer of the JWT Claims
        expiration - the expiration duration in minutes
        url - the url to check
        prefixLength - the length of the prefix
        methodList - the List of authorized (not null and non empty if the check must be done)
        ipMask - the ipMask (a regex) id the ip check must be done
        Returns:
        he JWT token
        Throws:
        org.jose4j.lang.JoseException - thrown if the token cannot be generated
      • generateToken

        public java.lang.String generateToken​(org.jose4j.jwt.JwtClaims claims,
                                              java.security.PrivateKey key,
                                              java.security.PublicKey receiverKey)
                                       throws org.jose4j.lang.JoseException
        Generate a encrypted Jwt token
        Parameters:
        claims - the claims
        key - the PrivateKey file to encrypt with
        receiverKey - the PublicKey of the receiver
        Returns:
        the JWT token
        Throws:
        org.jose4j.lang.JoseException - thrown if the token cannot be generated
      • generateDefaultClaims

        public org.jose4j.jwt.JwtClaims generateDefaultClaims​(Member mbr,
                                                              java.lang.String issuer,
                                                              float expiration)
        generate default claims
        Parameters:
        mbr - the Member as subject
        issuer - the issuer of the JWT Claims
        expiration - the expiration duration in minutes
        Returns:
        the JwtClaims
      • generateDefaultClaims

        public org.jose4j.jwt.JwtClaims generateDefaultClaims​(Member mbr,
                                                              java.lang.String issuer,
                                                              float expiration,
                                                              java.lang.String url,
                                                              java.lang.Integer prefixLength,
                                                              java.util.List<java.lang.String> methodList,
                                                              java.lang.String ipMask)
        generate default claims
        Parameters:
        mbr - the Member as subject
        issuer - the issuer of the JWT Claims
        expiration - the expiration duration in minutes
        url - the url to check
        prefixLength - the length of the prefix
        methodList - the List of authorized (not null and non empty if the check must be done)
        ipMask - (a regex) id the ip check must be done
        Returns:
        the JwtClaims