Package com.auth0.jwt.algorithms
Class CryptoHelper
java.lang.Object
com.auth0.jwt.algorithms.CryptoHelper
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) byte[]
createSignatureFor
(String algorithm, byte[] secretBytes, byte[] contentBytes) Deprecated.rather use corresponding method which takes header and payload as separate inputs(package private) byte[]
createSignatureFor
(String algorithm, byte[] secretBytes, byte[] headerBytes, byte[] payloadBytes) Create signature for JWT header and payload.(package private) byte[]
createSignatureFor
(String algorithm, PrivateKey privateKey, byte[] contentBytes) Deprecated.rather use corresponding method which takes header and payload as separate inputs(package private) byte[]
createSignatureFor
(String algorithm, PrivateKey privateKey, byte[] headerBytes, byte[] payloadBytes) Create signature for JWT header and payload using a private key.(package private) boolean
verifySignatureFor
(String algorithm, byte[] secretBytes, byte[] contentBytes, byte[] signatureBytes) Deprecated.rather use corresponding method which takes header and payload as separate inputs(package private) boolean
verifySignatureFor
(String algorithm, byte[] secretBytes, byte[] headerBytes, byte[] payloadBytes, byte[] signatureBytes) Verify signature for JWT header and payload.(package private) boolean
verifySignatureFor
(String algorithm, byte[] secretBytes, String header, String payload, byte[] signatureBytes) Verify signature for JWT header and payload.(package private) boolean
verifySignatureFor
(String algorithm, PublicKey publicKey, byte[] contentBytes, byte[] signatureBytes) Deprecated.rather use corresponding method which takes header and payload as separate inputs(package private) boolean
verifySignatureFor
(String algorithm, PublicKey publicKey, byte[] headerBytes, byte[] payloadBytes, byte[] signatureBytes) Verify signature for JWT header and payload using a public key.(package private) boolean
verifySignatureFor
(String algorithm, PublicKey publicKey, String header, String payload, byte[] signatureBytes) Verify signature for JWT header and payload.
-
Field Details
-
JWT_PART_SEPARATOR
private static final byte JWT_PART_SEPARATOR- See Also:
-
-
Constructor Details
-
CryptoHelper
CryptoHelper()
-
-
Method Details
-
verifySignatureFor
boolean verifySignatureFor(String algorithm, byte[] secretBytes, String header, String payload, byte[] signatureBytes) throws NoSuchAlgorithmException, InvalidKeyException Verify signature for JWT header and payload.- Parameters:
algorithm
- algorithm name.secretBytes
- algorithm secret.header
- JWT header.payload
- JWT payload.signatureBytes
- JWT signature.- Returns:
- true if signature is valid.
- Throws:
NoSuchAlgorithmException
- if the algorithm is not supported.InvalidKeyException
- if the given key is inappropriate for initializing the specified algorithm.
-
verifySignatureFor
boolean verifySignatureFor(String algorithm, byte[] secretBytes, byte[] headerBytes, byte[] payloadBytes, byte[] signatureBytes) throws NoSuchAlgorithmException, InvalidKeyException Verify signature for JWT header and payload.- Parameters:
algorithm
- algorithm name.secretBytes
- algorithm secret.headerBytes
- JWT header.payloadBytes
- JWT payload.signatureBytes
- JWT signature.- Returns:
- true if signature is valid.
- Throws:
NoSuchAlgorithmException
- if the algorithm is not supported.InvalidKeyException
- if the given key is inappropriate for initializing the specified algorithm.
-
createSignatureFor
byte[] createSignatureFor(String algorithm, byte[] secretBytes, byte[] headerBytes, byte[] payloadBytes) throws NoSuchAlgorithmException, InvalidKeyException Create signature for JWT header and payload.- Parameters:
algorithm
- algorithm name.secretBytes
- algorithm secret.headerBytes
- JWT header.payloadBytes
- JWT payload.- Returns:
- the signature bytes.
- Throws:
NoSuchAlgorithmException
- if the algorithm is not supported.InvalidKeyException
- if the given key is inappropriate for initializing the specified algorithm.
-
verifySignatureFor
boolean verifySignatureFor(String algorithm, PublicKey publicKey, String header, String payload, byte[] signatureBytes) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException Verify signature for JWT header and payload.- Parameters:
algorithm
- algorithm name.publicKey
- algorithm public key.header
- JWT header.payload
- JWT payload.signatureBytes
- JWT signature.- Returns:
- true if signature is valid.
- Throws:
NoSuchAlgorithmException
- if the algorithm is not supported.InvalidKeyException
- if the given key is inappropriate for initializing the specified algorithm.SignatureException
-
verifySignatureFor
boolean verifySignatureFor(String algorithm, PublicKey publicKey, byte[] headerBytes, byte[] payloadBytes, byte[] signatureBytes) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException Verify signature for JWT header and payload using a public key.- Parameters:
algorithm
- algorithm name.publicKey
- the public key to use for verification.headerBytes
- JWT header.payloadBytes
- JWT payload.signatureBytes
- JWT signature.- Returns:
- true if signature is valid.
- Throws:
NoSuchAlgorithmException
- if the algorithm is not supported.InvalidKeyException
- if the given key is inappropriate for initializing the specified algorithm.SignatureException
-
createSignatureFor
byte[] createSignatureFor(String algorithm, PrivateKey privateKey, byte[] headerBytes, byte[] payloadBytes) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException Create signature for JWT header and payload using a private key.- Parameters:
algorithm
- algorithm name.privateKey
- the private key to use for signing.headerBytes
- JWT header.payloadBytes
- JWT payload.- Returns:
- the signature bytes.
- Throws:
NoSuchAlgorithmException
- if the algorithm is not supported.InvalidKeyException
- if the given key is inappropriate for initializing the specified algorithm.SignatureException
- if this signature object is not initialized properly or if this signature algorithm is unable to process the input data provided.
-
verifySignatureFor
@Deprecated boolean verifySignatureFor(String algorithm, byte[] secretBytes, byte[] contentBytes, byte[] signatureBytes) throws NoSuchAlgorithmException, InvalidKeyException Deprecated.rather use corresponding method which takes header and payload as separate inputsVerify signature.- Parameters:
algorithm
- algorithm name.secretBytes
- algorithm secret.contentBytes
- the content to which the signature applies.signatureBytes
- JWT signature.- Returns:
- true if signature is valid.
- Throws:
NoSuchAlgorithmException
- if the algorithm is not supported.InvalidKeyException
- if the given key is inappropriate for initializing the specified algorithm.
-
createSignatureFor
@Deprecated byte[] createSignatureFor(String algorithm, byte[] secretBytes, byte[] contentBytes) throws NoSuchAlgorithmException, InvalidKeyException Deprecated.rather use corresponding method which takes header and payload as separate inputsCreate signature.- Parameters:
algorithm
- algorithm name.secretBytes
- algorithm secret.contentBytes
- the content to be signed.- Returns:
- the signature bytes.
- Throws:
NoSuchAlgorithmException
- if the algorithm is not supported.InvalidKeyException
- if the given key is inappropriate for initializing the specified algorithm.
-
verifySignatureFor
@Deprecated boolean verifySignatureFor(String algorithm, PublicKey publicKey, byte[] contentBytes, byte[] signatureBytes) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException Deprecated.rather use corresponding method which takes header and payload as separate inputsVerify signature using a public key.- Parameters:
algorithm
- algorithm name.publicKey
- algorithm public key.contentBytes
- the content to which the signature applies.signatureBytes
- JWT signature.- Returns:
- the signature bytes.
- Throws:
NoSuchAlgorithmException
- if the algorithm is not supported.InvalidKeyException
- if the given key is inappropriate for initializing the specified algorithm.SignatureException
- if this signature object is not initialized properly or if this signature algorithm is unable to process the input data provided.
-
createSignatureFor
@Deprecated byte[] createSignatureFor(String algorithm, PrivateKey privateKey, byte[] contentBytes) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException Deprecated.rather use corresponding method which takes header and payload as separate inputsCreate signature using a private key.- Parameters:
algorithm
- algorithm name.privateKey
- the private key to use for signing.contentBytes
- the content to be signed.- Returns:
- the signature bytes.
- Throws:
NoSuchAlgorithmException
- if the algorithm is not supported.InvalidKeyException
- if the given key is inappropriate for initializing the specified algorithm.SignatureException
- if this signature object is not initialized properly or if this signature algorithm is unable to process the input data provided.
-