Interface JwsBuilder


public interface JwsBuilder
The JwsBuilder provides a simple API to issue JWS formatted token as defined in http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-16 and http://tools.ietf.org/html/draft-ietf-jose-json-web-signature-21
  • Method Summary

    Modifier and Type
    Method
    Description
     
    Set the (Audience) Claim as for http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-16#section-4.1.3
    Set a custom claim field
    setExpiresIn(long expiresIn)
    Set the expiration time for the token expressed in seconds
    setIssuedAt(long iat)
    Set the (Issued At) Claim as for https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-25#section-4.1.6 If the set Issued At is too far away in the future (20 seconds or more than current time) the set Issued At will be ignored and the current time is used instead to build the JWT
    Set the (Issuer) Claim as for http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-16#section-4.1.1
    Set the scope associate with the token
    Set the (Subject) Claim as for http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-16#section-4.1.2
  • Method Details

    • build

      String build() throws CryptoException
      Returns:
      a signed JWS as defined in http://tools.ietf.org/html/draft-ietf-jose-json-web-signature-21
      Throws:
      CryptoException - if any problem occurs signing the token
    • setIssuer

      JwsBuilder setIssuer(String iss)
      Set the (Issuer) Claim as for http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-16#section-4.1.1
      Parameters:
      iss - The (Issuer) Claim
      Returns:
      JwsBuilder
    • setSubject

      JwsBuilder setSubject(String sub)
      Set the (Subject) Claim as for http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-16#section-4.1.2
      Parameters:
      sub - The (Subject) Claim as
      Returns:
      JwsBuilder
    • setAudience

      JwsBuilder setAudience(String aud)
      Set the (Audience) Claim as for http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-16#section-4.1.3
      Parameters:
      aud - The (Audience) Claim
      Returns:
      JwsBuilder
    • setExpiresIn

      JwsBuilder setExpiresIn(long expiresIn)
      Set the expiration time for the token expressed in seconds
      Parameters:
      expiresIn - The expiration time for the token expressed in seconds
      Returns:
      JwsBuilder
    • setScope

      JwsBuilder setScope(String scope)
      Set the scope associate with the token
      Parameters:
      scope - The scope associate with the token
      Returns:
      JwsBuilder
    • setCustomClaimsSetField

      JwsBuilder setCustomClaimsSetField(String key, Object value)
      Set a custom claim field
      Parameters:
      key - The claim field custom name
      value - The claim field value
      Returns:
      JwsBuilder
    • setIssuedAt

      JwsBuilder setIssuedAt(long iat)
      Set the (Issued At) Claim as for https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-25#section-4.1.6 If the set Issued At is too far away in the future (20 seconds or more than current time) the set Issued At will be ignored and the current time is used instead to build the JWT
      Parameters:
      iat - The (Issued At) Claim expressed in seconds
      Returns:
      JwsBuilder
      Since:
      1.1