001package com.nimbusds.jwt; 002 003 004/** 005 * Handler of parsed {@link JWT JSON Web Tokens} (JWT). Invoked by a 006 * {@link JWTParser} after parsing a JWT to indicate its exact type - 007 * {@link PlainJWT plain}, {@link SignedJWT signed} or 008 * {@link EncryptedJWT encrypted}. 009 * 010 * @since 3.4 011 */ 012public interface JWTHandler<T> { 013 014 015 /** 016 * Invoked when the {@link JWTParser} determines that the parsed JWT is 017 * plain (unsecured). 018 * 019 * @param plainJWT The parsed plain JWT. Not {@code null}. 020 * 021 * @return Any object to be used after inspecting the JWT, or 022 * {@code null} if no return value is necessary. 023 */ 024 public T onPlainJWT(final PlainJWT plainJWT); 025 026 027 /** 028 * Invoked when the {@link JWTParser} determines that the parsed JWT is 029 * signed (JWS). 030 * 031 * @param signedJWT The parsed signed JWT. Not {@code null}. 032 * 033 * @return Any object to be used after inspecting the JWT, or 034 * {@code null} if no return value is necessary. 035 */ 036 public T onSignedJWT(final SignedJWT signedJWT); 037 038 039 /** 040 * Invoked when the {@link JWTParser} determines that the parsed JWT is 041 * encrypted (JWE). 042 * 043 * @param encryptedJWT The parsed encrypted JWT. Not {@code null}. 044 * 045 * @return Any object to be used after inspecting the JWT, or 046 * {@code null} if no return value is necessary. 047 */ 048 public T onEncryptedJWT(final EncryptedJWT encryptedJWT); 049}