001package com.nimbusds.jwt; 002 003 004import java.text.ParseException; 005 006import com.nimbusds.jose.Header; 007import com.nimbusds.jose.util.Base64URL; 008 009 010/** 011 * JSON Web Token (JWT) interface. 012 * 013 * @author Vladimir Dzhuvinov 014 * @version $version$ (2014-07-08) 015 */ 016public interface JWT { 017 018 019 /** 020 * Gets the JOSE header of the JSON Web Token (JWT). 021 * 022 * @return The header. 023 */ 024 public Header getHeader(); 025 026 027 /** 028 * Gets the claims set of the JSON Web Token (JWT). 029 * 030 * @return The claims set, {@code null} if not available (for an 031 * encrypted JWT that isn't decrypted). 032 * 033 * @throws ParseException If the payload of the JWT doesn't represent a 034 * valid JSON object and a JWT claims set. 035 */ 036 public ReadOnlyJWTClaimsSet getJWTClaimsSet() 037 throws ParseException; 038 039 040 /** 041 * Gets the original parsed Base64URL parts used to create the JSON Web 042 * Token (JWT). 043 * 044 * @return The original Base64URL parts used to creates the JWT, 045 * {@code null} if the JWT was created from scratch. The 046 * individual parts may be empty or {@code null} to indicate a 047 * missing part. 048 */ 049 public Base64URL[] getParsedParts(); 050 051 052 /** 053 * Gets the original parsed string used to create the JSON Web Token 054 * (JWT). 055 * 056 * @see #getParsedParts 057 * 058 * @return The parsed string used to create the JWT, {@code null} if 059 * the JWT was created from scratch. 060 */ 061 public String getParsedString(); 062 063 064 /** 065 * Serialises the JSON Web Token (JWT) to its compact format consisting 066 * of Base64URL-encoded parts delimited by period ('.') characters. 067 * 068 * @return The serialised JWT. 069 * 070 * @throws IllegalStateException If the JWT is not in a state that 071 * permits serialisation. 072 */ 073 public String serialize(); 074}