public interface KeyResolver
PubicKeyResolver can be used by a PasetoParser to find a public key that
should be used to verify a paseto token signature.
A PubicKeyResolver is necessary when the signing key is not already known before parsing the paseto token and the
token payload or footer (plaintext or claims) must be inspected first to determine how to look up the signing key.
Once returned by the resolver, the PasetoParser will then verify the token signature with the returned key. For
example:
Paseto token = Pasetos.parserBuilder().setSigningKeyResolver(new KeyResolverAdapter() {
@Override
public byte[] resolvePublicKeyBytes(Paseto paseto) {
//inspect the header or claims, lookup and return the signing key
return getPublicKeyBytes(paseto); //implement me
}})
.build()
.parse(tokenString);
A PubicKeyResolver is invoked once during parsing before the signature is verified.
If you only need to resolve a signing key for a particular type of token, consider using
the KeyResolverAdapter and overriding only the method you need to support instead of
implementing this interface directly.
KeyResolverAdapter| Modifier and Type | Method and Description |
|---|---|
java.security.PublicKey |
resolvePublicKey(Version version,
Purpose purpose,
FooterClaims footer)
Returns the signing key that should be used to validate a digital signature for the paseto token.
|
javax.crypto.SecretKey |
resolveSharedKey(Version version,
Purpose purpose,
FooterClaims footer)
Returns the signing key that should be used to validate a digital signature for the paseto token.
|
java.security.PublicKey resolvePublicKey(Version version, Purpose purpose, FooterClaims footer)
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 parsedjavax.crypto.SecretKey resolveSharedKey(Version version, Purpose purpose, FooterClaims footer)
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 parsedCopyright © 2019-2020 paseto.dev. All Rights Reserved.