10Duke Java Core
Loading...
Searching...
No Matches
tenduke.sdk.core.service.impl.DefaultJwtService Class Reference

Detailed Description

Default implementation of the JwtService that provides functionality for basic operations such as building, signing and parsing JWTs.

Inheritance diagram for tenduke.sdk.core.service.impl.DefaultJwtService:
tenduke.sdk.core.service.impl.DefaultJwtMetadataParser tenduke.sdk.core.service.JwtService tenduke.sdk.core.service.JwtMetadataParser tenduke.sdk.core.service.JwtMetadataParser

Public Member Functions

 DefaultJwtService (final String keyId, final PrivateKey signingKey)
 Creates a new instance of this class for building and signing JWT's.
 
 DefaultJwtService (final String keyId, final PublicKey verificationKey)
 Creates a new instance of this class for verifying and parsing JWT's.
 
 DefaultJwtService (final String signingKeyId, final PrivateKey signingKey, final String verificationKeyId, final PublicKey verificationKey)
 Creates a new instance of this class for both building and signing JWT's and to parse and verify JWT's.
 
String buildAndSign (final Map< String, Object > claims)
 Builds and signs a JWT.
 
String buildAndSign (final String data)
 Builds and signs a JWT.
 
JwtToken parse (final String jwt)
 Parses a String to a JwtToken and validates the signature.
 
JwtToken parseNoVerify (final String jwt)
 Parses a String to a JwtToken and skips signature verification.
 
DefaultJwtService withTypHeaderValidationDisabled ()
 Turns JWT typ header claim validation off.
 
String signingKeyId ()
 Returns the key id for the private key that is used to sign JWT's.
 
String verificationKeyId ()
 Returns the key id for the public key that is used to validate JWT's.
 
- Public Member Functions inherited from tenduke.sdk.core.service.impl.DefaultJwtMetadataParser
String readKeyIdHeader (final String jwt)
 Reads a key id from the JWT header.
 
- Public Member Functions inherited from tenduke.sdk.core.service.JwtMetadataParser
- Public Member Functions inherited from tenduke.sdk.core.service.JwtService

Protected Member Functions

JwtConsumer configureJwtParser ()
 Configures JwtConsumer with the verification key and the correct settings.
 
void assertKeyIsValid (final PrivateKey key)
 Asserts that the private key is valid for use.
 
void assertModeEnablesSign ()
 Asserts that current service mode allows signing JWTs.
 
void assertModeEnablesVerify ()
 Asserts that current service model allows verifying JWTs.
 
- Protected Member Functions inherited from tenduke.sdk.core.service.impl.DefaultJwtMetadataParser
void assertJwtHeadersAreValid (final String jwt)
 Checks that headers are sane.
 

Additional Inherited Members

- Public Attributes inherited from tenduke.sdk.core.service.JwtMetadataParser
String HEADER_SIGNATURE_ALGORITHM = "alg"
 Header claim name for signature algorithm.
 
String HEADER_KEY_ID = "kid"
 Header claim name for key id.
 
String HEADER_TYPE = "typ"
 Header claim name for token type.
 
String TOKEN_TYPE_JWT = "JWT"
 Header claim type that denotes a JWT.
 
String SIGNATURE_ALGORITHM_RSA_SHA = "RS256"
 Header value for alg claim, denotes RSA-SHA algorithm used for JWT signatures.
 

Constructor & Destructor Documentation

◆ DefaultJwtService() [1/3]

tenduke.sdk.core.service.impl.DefaultJwtService.DefaultJwtService ( final String keyId,
final PrivateKey signingKey )

Creates a new instance of this class for building and signing JWT's.

Parameters
keyIdSigning key id.
signingKeyThe signing key.

◆ DefaultJwtService() [2/3]

tenduke.sdk.core.service.impl.DefaultJwtService.DefaultJwtService ( final String keyId,
final PublicKey verificationKey )

Creates a new instance of this class for verifying and parsing JWT's.

Parameters
keyIdVerification key id.
verificationKeyThe signature verification key.

◆ DefaultJwtService() [3/3]

tenduke.sdk.core.service.impl.DefaultJwtService.DefaultJwtService ( final String signingKeyId,
final PrivateKey signingKey,
final String verificationKeyId,
final PublicKey verificationKey )

Creates a new instance of this class for both building and signing JWT's and to parse and verify JWT's.

Parameters
signingKeyIdSigning key id.
signingKeyThe signing key.
verificationKeyIdThe verification key id.
verificationKeyThe verification key.

Member Function Documentation

◆ assertKeyIsValid()

void tenduke.sdk.core.service.impl.DefaultJwtService.assertKeyIsValid ( final PrivateKey key)
protected

Asserts that the private key is valid for use.

Parameters
keyThe key to validate.

◆ buildAndSign() [1/2]

String tenduke.sdk.core.service.impl.DefaultJwtService.buildAndSign ( final Map< String, Object > claims)

Builds and signs a JWT.

Parameters
claimsA map with key value pairs to use as JWT body JSON data definition.
Returns
A signed JWT with the map data as its body.

Implements tenduke.sdk.core.service.JwtService.

◆ buildAndSign() [2/2]

String tenduke.sdk.core.service.impl.DefaultJwtService.buildAndSign ( final String data)

Builds and signs a JWT.

Parameters
dataData to use as such for the JWT body.
Returns
A signed JWT with the data as its body.

Implements tenduke.sdk.core.service.JwtService.

◆ configureJwtParser()

JwtConsumer tenduke.sdk.core.service.impl.DefaultJwtService.configureJwtParser ( )
protected

Configures JwtConsumer with the verification key and the correct settings.

Returns
configured parser.

◆ parse()

JwtToken tenduke.sdk.core.service.impl.DefaultJwtService.parse ( final String jwt)

Parses a String to a JwtToken and validates the signature.

Parameters
jwtThe String to parse and validate.
Returns
A JwtToken or throws an error if parsing fails.

Implements tenduke.sdk.core.service.JwtService.

◆ parseNoVerify()

JwtToken tenduke.sdk.core.service.impl.DefaultJwtService.parseNoVerify ( final String jwt)

Parses a String to a JwtToken and skips signature verification.

Parameters
jwtThe String to parse and validate.
Returns
A JwtToken parsed from given JWT string.

Implements tenduke.sdk.core.service.JwtService.

◆ signingKeyId()

String tenduke.sdk.core.service.impl.DefaultJwtService.signingKeyId ( )

Returns the key id for the private key that is used to sign JWT's.

Returns
key id for the private key that is used to sign JWT's.

Implements tenduke.sdk.core.service.JwtService.

◆ verificationKeyId()

String tenduke.sdk.core.service.impl.DefaultJwtService.verificationKeyId ( )

Returns the key id for the public key that is used to validate JWT's.

Returns
key id for the public key that is used to validate JWT's.

Implements tenduke.sdk.core.service.JwtService.

◆ withTypHeaderValidationDisabled()

DefaultJwtService tenduke.sdk.core.service.impl.DefaultJwtService.withTypHeaderValidationDisabled ( )

Turns JWT typ header claim validation off.

Returns
this instance.

Reimplemented from tenduke.sdk.core.service.impl.DefaultJwtMetadataParser.


The documentation for this class was generated from the following file: