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

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String build()  
      JwsBuilder setAudience​(java.lang.String aud)
      Set the (Audience) Claim as for http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-16#section-4.1.3
      JwsBuilder setCustomClaimsSetField​(java.lang.String key, java.lang.Object value)
      Set a custom claim field
      JwsBuilder setExpiresIn​(long expiresIn)
      Set the expiration time for the token expressed in seconds
      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
      JwsBuilder setIssuer​(java.lang.String iss)
      Set the (Issuer) Claim as for http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-16#section-4.1.1
      JwsBuilder setScope​(java.lang.String scope)
      Set the scope associate with the token
      JwsBuilder setSubject​(java.lang.String sub)
      Set the (Subject) Claim as for http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-16#section-4.1.2
    • Method Detail

      • build

        java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.String scope)
        Set the scope associate with the token
        Parameters:
        scope - The scope associate with the token
        Returns:
        JwsBuilder
      • setCustomClaimsSetField

        JwsBuilder setCustomClaimsSetField​(java.lang.String key,
                                           java.lang.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