java.lang.Object
one.jpro.platform.auth.core.jwt.JWTOptions
All Implemented Interfaces:
Options

public class JWTOptions extends Object implements Options
Options describing a JWT (JSON Web Token).
  • Constructor Details

    • JWTOptions

      public JWTOptions()
      Default constructor.
    • JWTOptions

      public JWTOptions(JWTOptions other)
      Copy constructor for JWTOptions. Initializes a new instance of JWTOptions by copying configuration from another instance.
      Parameters:
      other - the JWT options to copy
  • Method Details

    • getIssuer

      public String getIssuer()
      Gets the issuer claim that identifies the principal that issued the JWT.
      Returns:
      the issuer identifier
    • setIssuer

      public JWTOptions setIssuer(String issuer)
      Sets the issuer claim that identifies the principal that issued the JWT.
      Parameters:
      issuer - the issuer identifier
      Returns:
      the current instance of JWTOptions for method chaining
    • getSubject

      public String getSubject()
      Gets the subject claim that identifies the principal that is the subject of the JWT.
      Returns:
      the subject identifier
    • setSubject

      public JWTOptions setSubject(String subject)
      Sets the subject claim that identifies the principal that is the subject of the JWT.
      Parameters:
      subject - the subject identifier
      Returns:
      the current instance of JWTOptions for method chaining
    • getAudience

      public List<String> getAudience()
      Gets the audience claim that identifies the recipients that the JWT is intended for.
      Returns:
      the list of audience identifiers
    • setAudience

      public JWTOptions setAudience(List<String> audience)
      Sets the audience claim that identifies the recipients that the JWT is intended for.
      Parameters:
      audience - the list of audience identifiers
      Returns:
      the current instance of JWTOptions for method chaining
    • getClaims

      public List<String> getClaims()
      Gets the claims intended for the JWT token.
      Returns:
      the list of claims
    • setClaims

      public JWTOptions setClaims(List<String> claims)
      Sets the claims for the JWT token.
      Parameters:
      claims - the list of claims to be set for the JWT token
      Returns:
      the current instance of JWTOptions for method chaining
    • getLeeway

      public long getLeeway()
      Gets the leeway for the JWT token's expiration time validation in seconds.
      Returns:
      the leeway in seconds
    • setLeeway

      public JWTOptions setLeeway(long leeway)
      Sets the leeway for the JWT token's expiration time validation in seconds.
      Parameters:
      leeway - the leeway in seconds
      Returns:
      the current instance of JWTOptions for method chaining
    • isIgnoreIssuedAt

      public boolean isIgnoreIssuedAt()
      Checks if the "issued at" claim (iat) is being ignored for the JWT validation.
      Returns:
      true if the "issued at" claim is being ignored; false otherwise
    • setIgnoreIssuedAt

      public JWTOptions setIgnoreIssuedAt(boolean ignoreIssuedAt)
      Sets whether the "issued at" claim (iat) should be ignored for the JWT validation.
      Parameters:
      ignoreIssuedAt - flag indicating whether to ignore the "issued at" claim
      Returns:
      the current instance of JWTOptions for method chaining
    • getCacheSize

      public long getCacheSize()
      Gets the size of the cache for storing generated JWTs or validation data.
      Returns:
      the cache size
    • setCacheSize

      public JWTOptions setCacheSize(long cacheSize)
      Sets the size of the cache for storing generated JWTs or validation data.
      Parameters:
      cacheSize - the cache size
      Returns:
      the current instance of JWTOptions for method chaining
    • getExpiresIn

      public Duration getExpiresIn()
      Gets the duration after which the JWT should be considered expired.
      Returns:
      the Duration until the token expires
    • setExpiresIn

      public JWTOptions setExpiresIn(Duration expiresIn)
      Gets the duration after which the JWT should be considered expired.
      Returns:
      the Duration until the token expires
    • getNonceAlgorithm

      public String getNonceAlgorithm()
      Gets the algorithm used to generate a nonce for the JWT token.
      Returns:
      the nonce algorithm
    • setNonceAlgorithm

      public JWTOptions setNonceAlgorithm(String nonceAlgorithm)
      Sets the algorithm used to generate a nonce for the JWT token.
      Parameters:
      nonceAlgorithm - the nonce algorithm
      Returns:
      the current instance of JWTOptions for method chaining
    • toJSON

      public org.json.JSONObject toJSON()
      Converts the current JWT options to a JSON object suitable for serialization. This includes all the JWT claim settings and additional options such as leeway, cache size, and expiry duration.
      Specified by:
      toJSON in interface Options
      Returns:
      a JSONObject representing the JWT options