View Javadoc
1   /*
2    * The contents of this file are subject to the terms of the Common Development and
3    * Distribution License (the License). You may not use this file except in compliance with the
4    * License.
5    *
6    * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
7    * specific language governing permission and limitations under the License.
8    *
9    * When distributing Covered Software, include this CDDL Header Notice in each file and include
10   * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
11   * Header, with the fields enclosed by brackets [] replaced by your own identifying
12   * information: "Portions copyright [year] [name of copyright owner]".
13   *
14   * Copyright 2013-2015 ForgeRock AS.
15   */
16  
17  package org.forgerock.json.jose.jwt;
18  
19  /**
20   * The interface for all types of JSON Web Tokens (JWTs).
21   * <p>
22   * JSON Web Token (JWT) is a means of representing claims to be transferred between two parties.  The claims in a JWT
23   * are encoded as a JSON object that is digitally signed or MACed using JSON Web Signature (JWS) and/or encrypted using
24   * JSON Web Encryption (JWE).
25   * <p>
26   * @see <a href="http://tools.ietf.org/html/draft-jones-json-web-token-10">JSON Web Token Specification</a>
27   *
28   * @since 2.0.0
29   */
30  public interface Jwt {
31  
32      /**
33       * Gets the header object for the JWT, which contains properties which describe the cryptographic operations
34       * applied to the JWT, among other properties.
35       * <p>
36       * When the JWT is digitally signed or MACed, the JWT Header is a JWS Header.  When the JWT is encrypted, the JWT
37       * Header is a JWE Header.
38       *
39       * @return The JWTs Header.
40       */
41      JwtHeader getHeader();
42  
43      /**
44       * Gets the claims set object for the Jwt, which contains all of the claims (name value pairs) conveyed by the JWT.
45       *
46       * @return The JWTs Claims Set.
47       */
48      JwtClaimsSet getClaimsSet();
49  
50      /**
51       * Builds the JWT into a <code>String</code> by following the steps specified in the relevant specification
52       * according to whether the JWT is being signed and/or encrypted.
53       * <p>
54       * @see <a href="http://tools.ietf.org/html/draft-jones-json-web-token-10#section-7">
55       *     JSON Web Token Specification</a>
56       * @see <a href="http://tools.ietf.org/html/draft-ietf-jose-json-web-signature-11#section-5">
57       *     JSON Web Signature Specification</a>
58       * @see <a href="http://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-11#section-5">
59       *     JSON Web Encryption Specification</a>
60       *
61       * @return The base64url encoded UTF-8 parts of the JWT.
62       */
63      String build();
64  }