com.nimbusds.openid.connect.sdk.util
Class DefaultJWTDecoder

java.lang.Object
  extended by com.nimbusds.openid.connect.sdk.util.DefaultJWTDecoder
All Implemented Interfaces:
JWTDecoder

@ThreadSafe
public class DefaultJWTDecoder
extends Object
implements JWTDecoder

The default decoder of JSON Web Tokens (JWTs). This class is thread-safe.

Supports:

Not supported: JWS-signed and then JWE-encrypted (nested) objects.

Author:
Vladimir Dzhuvinov

Constructor Summary
DefaultJWTDecoder()
          Creates a new decoder of JSON Web Tokens (JWTs).
 
Method Summary
 void addJWEDecrypter(com.nimbusds.jose.JWEDecrypter decrypter)
          Adds the specified JWE decrypter for decoding encrypted JWTs.
 void addJWSVerifier(com.nimbusds.jose.JWSVerifier verifier)
          Adds the specified JWS verifier for decoding signed JWTs.
 com.nimbusds.jwt.ReadOnlyJWTClaimsSet decodeJWT(com.nimbusds.jwt.JWT jwt)
          Decodes a JWT object, then applies JWS signature validation and / or JWE decryption if the token is secured.
 Collection<com.nimbusds.jose.JWEDecrypter> getJWEDecrypters()
          Gets the JWE decrypters.
 Collection<com.nimbusds.jose.JWSVerifier> getJWSVerifiers()
          Gets the JWS verifiers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultJWTDecoder

public DefaultJWTDecoder()
Creates a new decoder of JSON Web Tokens (JWTs). The decoder must then be supplied with one or more configured JWS verifiers and / or JWE decrypters.

Method Detail

addJWSVerifier

public void addJWSVerifier(com.nimbusds.jose.JWSVerifier verifier)
Adds the specified JWS verifier for decoding signed JWTs. The JWS algorithms accepted by the verifier should match the ones used to secure the expected JWTs.

Parameters:
verifier - The JWS verifier to add. Must be ready to verify signed JWTs and not null.

getJWSVerifiers

public Collection<com.nimbusds.jose.JWSVerifier> getJWSVerifiers()
Gets the JWS verifiers.

Returns:
The JWS verifiers, empty collection if none.

addJWEDecrypter

public void addJWEDecrypter(com.nimbusds.jose.JWEDecrypter decrypter)
Adds the specified JWE decrypter for decoding encrypted JWTs. The JWE algorithms accepted by the decrypter should match the ones used to secure the expected JWTs.

Parameters:
decrypter - The JWE decrypter to add. Must be ready to decrypt encrypted JWTs and not null.

getJWEDecrypters

public Collection<com.nimbusds.jose.JWEDecrypter> getJWEDecrypters()
Gets the JWE decrypters.

Returns:
The JWE decrypters, empty collection if none.

decodeJWT

public com.nimbusds.jwt.ReadOnlyJWTClaimsSet decodeJWT(com.nimbusds.jwt.JWT jwt)
                                                throws com.nimbusds.jose.JOSEException,
                                                       ParseException
Description copied from interface: JWTDecoder
Decodes a JWT object, then applies JWS signature validation and / or JWE decryption if the token is secured.

Specified by:
decodeJWT in interface JWTDecoder
Parameters:
jwt - The JWT to decode. Must not be null.
Returns:
The JWT claims set.
Throws:
com.nimbusds.jose.JOSEException - If decoding, JWS validation and / or JWE decryption of the JWT failed.
ParseException - If parsing of the JWT claims set failed.


Copyright © 2013 NimbusDS. All Rights Reserved.