Class JwtManager

java.lang.Object
com.jalios.jcms.security.JwtManager
All Implemented Interfaces:
JPropertiesListener

public class JwtManager extends Object implements JPropertiesListener
  • Method Details

    • 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(String token, 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 String generateToken(org.jose4j.jwt.JwtClaims claims, File privateKeyFile, 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 String generateToken(org.jose4j.jwt.JwtClaims claims, 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 String generateToken(PrivateKey key, Member mbr, String issuer, float expiration, String url, Integer prefixLength, List<String> methodList, String ipMask) throws org.jose4j.lang.JoseException
      Generate a JWT token using 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:
      the JWT token
      Throws:
      org.jose4j.lang.JoseException - thrown if the token cannot be generated
    • generateToken

      public String generateToken(org.jose4j.jwt.JwtClaims claims, PrivateKey key, PublicKey receiverKey) throws org.jose4j.lang.JoseException
      Generate an 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, 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, String issuer, float expiration, String url, Integer prefixLength, List<String> methodList, 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
    • generateDefaultClaims

      public org.jose4j.jwt.JwtClaims generateDefaultClaims(Member mbr, String issuer, String url, AccessTokenOptions options)
      Generated the default JWT claims for the specified options
      Parameters:
      mbr - the Member as subject
      issuer - the issuer of the JWT Claims (usually the channel name)
      url - the url to check
      options - the token options MUST NOT be null
      Returns:
      a new JwtClaims
      Since:
      10.0.8 / JCMS-4770
    • generateDefaultClaims

      public org.jose4j.jwt.JwtClaims generateDefaultClaims(String mbrLoginOrId, String issuer, String url, AccessTokenOptions options)
      Generated the default JWT claims for the specified options
      Parameters:
      mbrLoginOrId - the Member login or id, used as Claims subject, must not be null nor empty
      issuer - the issuer of the JWT Claims (usually the channel name)
      url - the url to check
      options - the token options MUST NOT be null
      Returns:
      a new JwtClaims
      Since:
      10.0.8 / JCMS-10606