T
- the type of object to return to the parser caller after handling the parsed JWT.public abstract class JwtHandlerAdapter<T> extends SupportedJwtVisitor<T> implements JwtHandler<T>
JwtHandler
interface that allows for anonymous subclasses to process only the JWT results that are
known/expected for a particular use case.
All of the methods in this implementation throw exceptions: overridden methods represent scenarios expected by calling code in known situations. It would be unexpected to receive a JWT that did not match parsing expectations, so all non-overridden methods throw exceptions to indicate that the JWT input was unexpected.
Constructor and Description |
---|
JwtHandlerAdapter()
Default constructor, does not initialize any internal state.
|
Modifier and Type | Method and Description |
---|---|
T |
onClaimsJwe(Jwe<Claims> jwe)
This method is invoked when a
JwtParser determines that the parsed JWT is
a valid Claims JWE. |
T |
onClaimsJws(Jws<Claims> jws)
This method is invoked when a
JwtParser determines that the parsed JWT is
a valid Claims JWS. |
T |
onClaimsJwt(Jwt<Header,Claims> jwt)
This method is invoked when a
JwtParser determines that the parsed JWT is
a Claims JWT. |
T |
onContentJwe(Jwe<byte[]> jwe)
This method is invoked when a
JwtParser determines that the parsed JWT is
a content JWE. |
T |
onContentJws(Jws<byte[]> jws)
This method is invoked when a
JwtParser determines that the parsed JWT is
a content JWS. |
T |
onContentJwt(Jwt<Header,byte[]> jwt)
This method is invoked when a
JwtParser determines that the parsed JWT is
an unsecured content JWT. |
T |
onDecryptedClaims(Jwe<Claims> jwe)
Handles an encountered JWE message that has been authenticated and decrypted, and has a
Claims payload. |
T |
onDecryptedContent(Jwe<byte[]> jwe)
Handles an encountered JWE message that has been authenticated and decrypted, and has byte[] array payload.
|
T |
onUnsecuredClaims(Jwt<Header,Claims> jwt)
Handles an encountered unsecured Claims JWT - one that is not cryptographically signed nor
encrypted, and has a
Claims payload. |
T |
onUnsecuredContent(Jwt<Header,byte[]> jwt)
Handles an encountered unsecured content JWT - one that is not cryptographically signed nor
encrypted, and has a byte[] array payload.
|
T |
onVerifiedClaims(Jws<Claims> jws)
Handles an encountered JWS message that has been cryptographically verified/authenticated and has a
Claims payload. |
T |
onVerifiedContent(Jws<byte[]> jws)
Handles an encountered JWS message that has been cryptographically verified/authenticated and has
a byte[] array payload.
|
visit, visit, visit
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
visit, visit, visit
public JwtHandlerAdapter()
public T onUnsecuredContent(Jwt<Header,byte[]> jwt)
SupportedJwtVisitor
Header.getContentType()
value, the application may inspect that value to determine how to convert
the byte array to the final type as desired.
The default implementation immediately throws an UnsupportedJwtException
; it is expected that
subclasses will override this method if the application needs to support this type of JWT.
onUnsecuredContent
in class SupportedJwtVisitor<T>
jwt
- the parsed unsecured content JWTnull
if no return value is necessary.public T onUnsecuredClaims(Jwt<Header,Claims> jwt)
SupportedJwtVisitor
Claims
payload.
The default implementation immediately throws an UnsupportedJwtException
; it is expected that
subclasses will override this method if the application needs to support this type of JWT.
onUnsecuredClaims
in class SupportedJwtVisitor<T>
jwt
- the parsed unsecured content JWTnull
if no return value is necessary.public T onVerifiedContent(Jws<byte[]> jws)
SupportedJwtVisitor
Header.getContentType()
value, the
application may inspect that value to determine how to convert the byte array to the final type as desired.
The default implementation immediately throws an UnsupportedJwtException
; it is expected that
subclasses will override this method if the application needs to support this type of JWT.
onVerifiedContent
in class SupportedJwtVisitor<T>
jws
- the parsed verified/authenticated JWS.null
if no return value is necessary.public T onVerifiedClaims(Jws<Claims> jws)
SupportedJwtVisitor
Claims
payload.
The default implementation immediately throws an UnsupportedJwtException
; it is expected that
subclasses will override this method if the application needs to support this type of JWT.
onVerifiedClaims
in class SupportedJwtVisitor<T>
jws
- the parsed signed (and verified) Claims JWSnull
if no return value is necessary.public T onDecryptedContent(Jwe<byte[]> jwe)
SupportedJwtVisitor
Header.getContentType()
value, the application may inspect that
value to determine how to convert the byte array to the final type as desired.
The default implementation immediately throws an UnsupportedJwtException
; it is expected that
subclasses will override this method if the application needs to support this type of JWT.
onDecryptedContent
in class SupportedJwtVisitor<T>
jwe
- the parsed authenticated and decrypted content JWE.null
if no return value is necessary.public T onDecryptedClaims(Jwe<Claims> jwe)
SupportedJwtVisitor
Claims
payload.
The default implementation immediately throws an UnsupportedJwtException
; it is expected that
subclasses will override this method if the application needs to support this type of JWT.
onDecryptedClaims
in class SupportedJwtVisitor<T>
jwe
- the parsed authenticated and decrypted content JWE.null
if no return value is necessary.public T onContentJwt(Jwt<Header,byte[]> jwt)
JwtHandler
JwtParser
determines that the parsed JWT is
an unsecured content JWT. An unsecured content JWT has a byte array payload that is not
cryptographically signed or encrypted. If the JWT creator set the (optional)
contentType
header value, the application may inspect that value to determine
how to convert the byte array to the final content type as desired.onContentJwt
in interface JwtHandler<T>
jwt
- the parsed unsecured content JWTnull
if no return value is necessary.public T onClaimsJwt(Jwt<Header,Claims> jwt)
JwtHandler
JwtParser
determines that the parsed JWT is
a Claims JWT. A Claims JWT has a Claims
payload that is not cryptographically signed or encrypted.onClaimsJwt
in interface JwtHandler<T>
jwt
- the parsed claims JWTnull
if no return value is necessary.public T onContentJws(Jws<byte[]> jws)
JwtHandler
JwtParser
determines that the parsed JWT is
a content JWS. A content JWS is a JWT with a byte array payload that has been cryptographically signed.
If the JWT creator set the (optional) contentType
header value, the
application may inspect that value to determine how to convert the byte array to the final content type
as desired.
This method will only be invoked if the cryptographic signature can be successfully verified.
onContentJws
in interface JwtHandler<T>
jws
- the parsed content JWSnull
if no return value is necessary.public T onClaimsJws(Jws<Claims> jws)
JwtHandler
JwtParser
determines that the parsed JWT is
a valid Claims JWS. A Claims JWS is a JWT with a Claims
payload that has been cryptographically signed.
This method will only be invoked if the cryptographic signature can be successfully verified.
onClaimsJws
in interface JwtHandler<T>
jws
- the parsed claims JWSnull
if no return value is necessary.public T onContentJwe(Jwe<byte[]> jwe)
JwtHandler
JwtParser
determines that the parsed JWT is
a content JWE. A content JWE is a JWE with a byte array payload that has been encrypted. If the JWT creator set
the (optional) contentType
header value, the application may inspect that
value to determine how to convert the byte array to the final content type as desired.
This method will only be invoked if the content JWE can be successfully decrypted.
onContentJwe
in interface JwtHandler<T>
jwe
- the parsed content jwenull
if no return value is necessary.public T onClaimsJwe(Jwe<Claims> jwe)
JwtHandler
JwtParser
determines that the parsed JWT is
a valid Claims JWE. A Claims JWE is a JWT with a Claims
payload that has been encrypted.
This method will only be invoked if the Claims JWE can be successfully decrypted.
onClaimsJwe
in interface JwtHandler<T>
jwe
- the parsed claims jwenull
if no return value is necessary.Copyright © 2014–2025 jsonwebtoken.io. All rights reserved.