Class KeyResolverAdapter
- java.lang.Object
-
- dev.paseto.jpaseto.KeyResolverAdapter
-
- All Implemented Interfaces:
KeyResolver
public abstract class KeyResolverAdapter extends java.lang.Object implements KeyResolver
An Adapter implementation of theKeyResolverinterface that allows subclasses to process only the type of paseto token that is known/expected for a particular case.The
resolvePublicKey(Version, Purpose, FooterClaims)andresolveSharedKey(Version, Purpose, FooterClaims)method implementations delegate to theresolvePublicKeyBytes(Version, Purpose, FooterClaims)andresolveSharedKeyBytes(Version, Purpose, FooterClaims)methods respectively. The latter two methods simply throw exceptions: they represent scenarios expected by calling code in known situations, and it is expected that you override the implementation in those known situations; non-overridden *KeyBytes methods indicates that the token input was unexpected.If either
resolvePublicKey(Version, Purpose, FooterClaims)andresolveSharedKey(Version, Purpose, FooterClaims)are not overridden, one (or both) of the *KeyBytes variants must be overridden depending on your expected use case. You do not have to override any method that does not represent an expected condition.- Since:
- 0.1
-
-
Constructor Summary
Constructors Constructor Description KeyResolverAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.security.PublicKeyresolvePublicKey(Version version, Purpose purpose, FooterClaims footer)Returns the signing key that should be used to validate a digital signature for the paseto token.protected byte[]resolvePublicKeyBytes(Version version, Purpose purpose, FooterClaims footer)Convenience method invoked byresolvePublicKey(Version, Purpose, FooterClaims)that obtains the necessary public key bytes.javax.crypto.SecretKeyresolveSharedKey(Version version, Purpose purpose, FooterClaims footer)Returns the signing key that should be used to validate a digital signature for the paseto token.protected byte[]resolveSharedKeyBytes(Version version, Purpose purpose, FooterClaims footer)Convenience method invoked byresolveSharedKey(Version, Purpose, FooterClaims)that obtains the necessary signing key bytes.
-
-
-
Method Detail
-
resolvePublicKey
public java.security.PublicKey resolvePublicKey(Version version, Purpose purpose, FooterClaims footer)
Description copied from interface:KeyResolverReturns the signing key that should be used to validate a digital signature for the paseto token.- Specified by:
resolvePublicKeyin interfaceKeyResolver- Parameters:
version- the version of the token to be parsedpurpose- the purpose of the token to be parsedfooter- the footer containing claims or plain text of the token to be parsed- Returns:
- the public key that should be used to validate a digital signature for the token.
-
resolveSharedKey
public javax.crypto.SecretKey resolveSharedKey(Version version, Purpose purpose, FooterClaims footer)
Description copied from interface:KeyResolverReturns the signing key that should be used to validate a digital signature for the paseto token.- Specified by:
resolveSharedKeyin interfaceKeyResolver- Parameters:
version- the version of the token to be parsedpurpose- the purpose of the token to be parsedfooter- the footer containing claims or plain text of the token to be parsed- Returns:
- the shared key that should be used to decrypt the token.
-
resolvePublicKeyBytes
protected byte[] resolvePublicKeyBytes(Version version, Purpose purpose, FooterClaims footer)
Convenience method invoked byresolvePublicKey(Version, Purpose, FooterClaims)that obtains the necessary public key bytes. This implementation simply throws an exception: if the paseto token parsed is 'public'.- Parameters:
version- the version of the token to be parsedpurpose- the purpose of the token to be parsedfooter- the footer containing claims or plain text of the token to be parsed- Returns:
- the signing key bytes to use to verify the paseto token signature.
-
resolveSharedKeyBytes
protected byte[] resolveSharedKeyBytes(Version version, Purpose purpose, FooterClaims footer)
Convenience method invoked byresolveSharedKey(Version, Purpose, FooterClaims)that obtains the necessary signing key bytes. This implementation simply throws an exception: if the paseto token parsed is 'local'.- Parameters:
version- the version of the token to be parsedpurpose- the purpose of the token to be parsedfooter- the footer containing claims or plain text of the token to be parsed- Returns:
- the shared key that should be used to decrypt the token.
-
-