Interface KeyResolver

  • All Known Implementing Classes:
    KeyResolverAdapter

    public interface KeyResolver
    A 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.

    KeyResolverAdapter

    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.

    Since:
    0.1
    See Also:
    KeyResolverAdapter
    • 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 parsed
        purpose - the purpose of the token to be parsed
        footer - 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 parsed
        purpose - the purpose of the token to be parsed
        footer - 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.