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