Package dev.paseto.jpaseto
Interface KeyResolver
-
- All Known Implementing Classes:
KeyResolverAdapter
public interface KeyResolverAPubicKeyResolvercan be used by aPasetoParserto find a public key that should be used to verify a paseto token signature.A
PubicKeyResolveris 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
PubicKeyResolveris invoked once during parsing before the signature is verified.KeyResolverAdapter
If you only need to resolve a signing key for a particular type of token, consider using the
KeyResolverAdapterand overriding only the method you need to support instead of implementing this interface directly.- Since:
- 0.1
- See Also:
KeyResolverAdapter
-
-
Method Summary
All Methods Instance Methods Abstract 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.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.
-
-
-
Method Detail
-
resolvePublicKey
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.- 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
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.- 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.
-
-