Class JsonWebToken

    • Constructor Detail

      • JsonWebToken

        public JsonWebToken​(org.jose4j.jwt.JwtClaims jwtClaims)
        Construct a new instance.
        Parameters:
        jwtClaims - the JWT claims for this instance (may not be null)
    • Method Detail

      • getIssuer

        public String getIssuer()
        Get the issuer claim.
        Returns:
        the issuer claim
        Throws:
        IllegalArgumentException - if the issuer claim is malformed
      • getSubject

        public String getSubject()
        Get the subject claim.
        Returns:
        the subject claim
        Throws:
        IllegalArgumentException - if the subject claim is malformed
      • getAudience

        public List<String> getAudience()
        Get the audience claim.
        Returns:
        the audience claim
        Throws:
        IllegalArgumentException - if the audience claim is malformed
      • getExpiration

        public Long getExpiration()
        Get the expiration claim.
        Returns:
        the expiration claim
        Throws:
        IllegalArgumentException - if the expiration claim is malformed
      • isExpired

        public boolean isExpired()
        Return whether this JWT is expired.
        Returns:
        true if this JWT is expired and false otherwise
        Throws:
        IllegalArgumentException - if the issuer claim is malformed
      • getNotBefore

        public Long getNotBefore()
        Get the not before claim.
        Returns:
        the not before claim
        Throws:
        IllegalArgumentException - if the not before claim is malformed
      • isNotBefore

        public boolean isNotBefore()
        Return whether the current time is greater than or equal to the value of the not before claim.
        Returns:
        true if the not before claim is null or if the current time is greater than or equal to the value of the not before claim and false otherwise
        Throws:
        IllegalArgumentException - if the not before claim is malformed
      • isActive

        public boolean isActive()
        Checks that the token is not expired and isn't prior to the not before time.
        Returns:
        true if the token is active and false otherwise
      • getIssuedAt

        public Long getIssuedAt()
        Get the issued at claim.
        Returns:
        the issued at claim
        Throws:
        IllegalArgumentException - if the issued at claim is malformed
      • getClaimNames

        public Set<String> getClaimNames()
        Get the claim names.
        Returns:
        the claim names
      • hasClaim

        public boolean hasClaim​(String claimName)
        Return whether this token has the given claim.
        Parameters:
        claimName - the claim name to check
        Returns:
        true if this token has the given claim and false otherwise
      • getClaimValue

        public Object getClaimValue​(String claimName)
        Get the value of the given claim.
        Parameters:
        claimName - the claim to retrieve
        Returns:
        the value of the given claim
      • getClaimValue

        public <T> T getClaimValue​(String claimName,
                                   Class<T> type)
        Get the value of the given claim.
        Type Parameters:
        T - the type of the value
        Parameters:
        claimName - the claim to retrieve
        type - the type that should be returned
        Returns:
        the value of the given claim
        Throws:
        IllegalArgumentException - if the claim is malformed
      • getClaimValueAsString

        public String getClaimValueAsString​(String claimName)
        Get the value of the given claim.
        Parameters:
        claimName - the claim to retrieve
        Returns:
        the value of the given claim as a string
      • getStringListClaimValue

        public List<String> getStringListClaimValue​(String claimName)
        Get the value of the given claim as a string list.
        Parameters:
        claimName - the claim to retrieve
        Returns:
        the value of the given claim as a string list
      • getName

        public String getName()
        Get the name claim.
        Returns:
        the name claim
      • getPrincipalName

        public String getPrincipalName​(OidcClientConfiguration deployment)
        Get the principal name.
        Parameters:
        deployment - the OIDC client configuration that should be used to determine the principal
        Returns:
        the principal name
      • getGivenName

        public String getGivenName()
        Get the given name claim.
        Returns:
        the given name claim
      • getFamilyName

        public String getFamilyName()
        Get the family name claim.
        Returns:
        the family name claim
      • getMiddleName

        public String getMiddleName()
        Get the middle name claim.
        Returns:
        the middle name claim
      • getNickName

        public String getNickName()
        Get the nick name claim.
        Returns:
        the nick name claim
      • getPreferredUsername

        public String getPreferredUsername()
        Get the preferred username claim.
        Returns:
        the preferred username claim
      • getEmail

        public String getEmail()
        Get the email claim.
        Returns:
        the email claim
      • getCurrentTimeInSeconds

        private static int getCurrentTimeInSeconds()
      • getClaimValueAsLong

        Long getClaimValueAsLong​(String claimName)
      • wrapValue

        public static jakarta.json.JsonValue wrapValue​(Object value)
      • replaceMap

        public static jakarta.json.JsonObject replaceMap​(Map<String,​Object> map)
      • toJsonArray

        private static jakarta.json.JsonArray toJsonArray​(Collection<?> collection)