public abstract class BaseTokenGenerator extends java.lang.Object implements TokenGenerator
Modifier and Type | Field and Description |
---|---|
static long |
ALLOWED_CLOCK_SKEW |
static int |
PREIMAGE_LENGTH |
Constructor and Description |
---|
BaseTokenGenerator() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
generateInvoiceToken(OrderRequest orderRequest,
MinimalInvoice invoice,
RequestData requestData,
java.time.Instant expireDate,
java.time.Instant notBefore,
java.lang.String recipientSubject)
Help method to generate a JWT token containing a invoice data claim.
|
java.lang.String |
generatePaymentToken(OrderRequest orderRequest,
Order order,
RequestData requestData,
java.time.Instant expireDate,
java.time.Instant notBefore,
java.lang.String recipientSubject)
Help method to generate a JWT token containing a payment data claim.
|
java.lang.String |
generateSettlementToken(OrderRequest orderRequest,
Settlement settlement,
RequestData requestData,
java.time.Instant expireDate,
java.time.Instant notBefore,
java.lang.String recipientSubject)
Help method to generate a JWT token containing a settlement data claim.
|
java.lang.String |
generateToken(java.lang.String tokenContextType,
java.time.Instant expireDate,
java.time.Instant notBefore,
boolean encrypt,
java.lang.String recipientSubject,
JWTClaim... claim)
General method to generate JWT token that is JWS signed and optionally JWE encrypted.
|
PreImageData |
genPreImageData()
Method that should generate a random pre image data used to
create invoice.
|
protected java.security.SecureRandom |
getSecureRandom() |
org.jose4j.jwt.JwtClaims |
parseToken(java.lang.String tokenContextType,
java.lang.String jwtToken)
Method to parse, verify signature and decrypt (if encrypted) a token.
|
protected abstract void |
populateJWEDecryptionAlgAndKey(TokenContext context,
org.jose4j.jwe.JsonWebEncryption jwe)
Method to set the encryption algorithm and key used to deencrypt the token.
|
protected abstract void |
populateJWEEncryptionAlgAndKey(TokenContext context,
java.lang.String recipientSubject,
org.jose4j.jwe.JsonWebEncryption jwe)
Method to set the encryption algorithm and key used to encrypt the token.
|
protected abstract void |
populateJWSSignatureAlgAndKey(TokenContext context,
org.jose4j.jws.JsonWebSignature jws)
Method to set the signature algorithm and key used to sign the token.
|
protected abstract void |
populateJWSVerifyAlgAndKey(TokenContext context,
org.jose4j.jws.JsonWebSignature jws)
Method to set algorithm whitelisting and verification key before verification of the JWS signature.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getIssuerName
public static final int PREIMAGE_LENGTH
public static final long ALLOWED_CLOCK_SKEW
public PreImageData genPreImageData() throws InternalErrorException
genPreImageData
in interface TokenGenerator
InternalErrorException
- if internal errors occurred generating
the pre image data.public java.lang.String generatePaymentToken(OrderRequest orderRequest, Order order, RequestData requestData, java.time.Instant expireDate, java.time.Instant notBefore, java.lang.String recipientSubject) throws TokenException, java.io.IOException, InternalErrorException
generatePaymentToken
in interface TokenGenerator
orderRequest
- the order request derived from the payment required annotation.order
- the payment data to include in the token.requestData
- optional request data that could be set if workflow requires it.expireDate
- the expire date of the token in the future.notBefore
- an optional not before data, indicating when the token starts to become valid. Use null not to set.recipientSubject
- the subject (usually keyId) of the recipient, required if asymmetrical keys are used, otherwise it
can be null.TokenException
- if problems occurred looking up the recipient public key.java.io.IOException
- if communication problems occurred with underlying systems.InternalErrorException
- if internal problems occurred processing the token.public java.lang.String generateInvoiceToken(OrderRequest orderRequest, MinimalInvoice invoice, RequestData requestData, java.time.Instant expireDate, java.time.Instant notBefore, java.lang.String recipientSubject) throws TokenException, java.io.IOException, InternalErrorException
generateInvoiceToken
in interface TokenGenerator
orderRequest
- the order request derived from the payment required annotation.invoice
- the invoice data to include in the token.requestData
- optional request data that could be set if workflow requires it.expireDate
- the expire date of the token in the future.notBefore
- an optional not before data, indicating when the token starts to become valid. Use null not to set.recipientSubject
- the subject (usually keyId) of the recipient, required if asymmetrical keys are used, otherwise it
can be null.TokenException
- if problems occurred looking up the recipient public key.java.io.IOException
- if communication problems occurred with underlying systems.InternalErrorException
- if internal problems occurred processing the token.public java.lang.String generateSettlementToken(OrderRequest orderRequest, Settlement settlement, RequestData requestData, java.time.Instant expireDate, java.time.Instant notBefore, java.lang.String recipientSubject) throws TokenException, java.io.IOException, InternalErrorException
generateSettlementToken
in interface TokenGenerator
orderRequest
- the order request derived from the payment required annotation.settlement
- the settlement data to include in the token.requestData
- optional request data that could be set if workflow requires it.expireDate
- the expire date of the token in the future.notBefore
- an optional not before data, indicating when the token starts to become valid. Use null not to set.recipientSubject
- the subject (usually keyId) of the recipient, required if asymmetrical keys are used, otherwise it
can be null.TokenException
- if problems occurred looking up the recipient public key.java.io.IOException
- if communication problems occurred with underlying systems.InternalErrorException
- if internal problems occurred processing the token.public java.lang.String generateToken(java.lang.String tokenContextType, java.time.Instant expireDate, java.time.Instant notBefore, boolean encrypt, java.lang.String recipientSubject, JWTClaim... claim) throws TokenException, java.io.IOException, InternalErrorException
generateToken
in interface TokenGenerator
tokenContextType
- the type the token contextexpireDate
- the expire date of the token in the future.notBefore
- an optional not before data, indicating when the token starts to become valid. Use null not to set.encrypt
- true if JWE encrypted token should be generated.recipientSubject
- the subject (usually keyId) of the recipient, required if asymmetrical keys are used, otherwise it
can be null.claim
- a list of claims to include in the token.TokenException
- if problems occurred looking up the recipient public key.java.io.IOException
- if communication problems occurred with underlying systems.InternalErrorException
- if internal problems occurred processing the token.public org.jose4j.jwt.JwtClaims parseToken(java.lang.String tokenContextType, java.lang.String jwtToken) throws TokenException, java.io.IOException, InternalErrorException
parseToken
in interface TokenGenerator
tokenContextType
- the type of token context used when parsing a token.jwtToken
- The JWT token string data to parse.TokenException
- if problems occurred parsing, verifying or decrypting the token.java.io.IOException
- if communication problems occurred with underlying systems.InternalErrorException
- if internal problems occurred processing the token.protected abstract void populateJWSSignatureAlgAndKey(TokenContext context, org.jose4j.jws.JsonWebSignature jws) throws java.io.IOException, InternalErrorException
context
- the related token context.jws
- the signature to populate used algorithm and key for.java.io.IOException
- if communication problems occurred with underlying systems.InternalErrorException
- if internal problem occurred setting the JWS properties.protected abstract void populateJWSVerifyAlgAndKey(TokenContext context, org.jose4j.jws.JsonWebSignature jws) throws TokenException, org.jose4j.lang.JoseException, java.io.IOException, InternalErrorException
context
- the related token context.jws
- the signature to check signing algorithm and signing key for.TokenException
- if no trusted signing key could be found.org.jose4j.lang.JoseException
- if JWT problems occurred.java.io.IOException
- if communication problems occurred with underlying systems.InternalErrorException
- if internal problem occurred setting the JWS properties.protected abstract void populateJWEEncryptionAlgAndKey(TokenContext context, java.lang.String recipientSubject, org.jose4j.jwe.JsonWebEncryption jwe) throws TokenException, java.io.IOException, InternalErrorException
context
- the related token context.recipientSubject
- the subject name of the recipient for the generated token, could be null if not applicable.jwe
- the encryption object to populate used algorithm and key for.TokenException
- if no related encryption key could be found.java.io.IOException
- if communication problems occurred with underlying systems.InternalErrorException
- if internal problem occurred setting the JWE properties.protected abstract void populateJWEDecryptionAlgAndKey(TokenContext context, org.jose4j.jwe.JsonWebEncryption jwe) throws java.io.IOException, InternalErrorException
context
- the related token context.jwe
- the encryption object to populate used algorithm and key for.java.io.IOException
- if communication problems occurred with underlying systems.InternalErrorException
- if internal problem occurred setting the JWE properties.protected java.security.SecureRandom getSecureRandom() throws InternalErrorException
InternalErrorException