Package com.auth0.jwt.algorithms
Class CryptoHelper
- java.lang.Object
-
- com.auth0.jwt.algorithms.CryptoHelper
-
class CryptoHelper extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static byteJWT_PART_SEPARATOR
-
Constructor Summary
Constructors Constructor Description CryptoHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description (package private) byte[]createSignatureFor(java.lang.String algorithm, byte[] secretBytes, byte[] contentBytes)Deprecated.rather use corresponding method which takes header and payload as separate inputs(package private) byte[]createSignatureFor(java.lang.String algorithm, byte[] secretBytes, byte[] headerBytes, byte[] payloadBytes)Create signature for JWT header and payload.(package private) byte[]createSignatureFor(java.lang.String algorithm, java.security.PrivateKey privateKey, byte[] contentBytes)Deprecated.rather use corresponding method which takes header and payload as separate inputs(package private) byte[]createSignatureFor(java.lang.String algorithm, java.security.PrivateKey privateKey, byte[] headerBytes, byte[] payloadBytes)Create signature for JWT header and payload using a private key.(package private) booleanverifySignatureFor(java.lang.String algorithm, byte[] secretBytes, byte[] contentBytes, byte[] signatureBytes)Deprecated.rather use corresponding method which takes header and payload as separate inputs(package private) booleanverifySignatureFor(java.lang.String algorithm, byte[] secretBytes, byte[] headerBytes, byte[] payloadBytes, byte[] signatureBytes)Verify signature for JWT header and payload.(package private) booleanverifySignatureFor(java.lang.String algorithm, byte[] secretBytes, java.lang.String header, java.lang.String payload, byte[] signatureBytes)Verify signature for JWT header and payload.(package private) booleanverifySignatureFor(java.lang.String algorithm, java.security.PublicKey publicKey, byte[] contentBytes, byte[] signatureBytes)Deprecated.rather use corresponding method which takes header and payload as separate inputs(package private) booleanverifySignatureFor(java.lang.String algorithm, java.security.PublicKey publicKey, byte[] headerBytes, byte[] payloadBytes, byte[] signatureBytes)Verify signature for JWT header and payload using a public key.(package private) booleanverifySignatureFor(java.lang.String algorithm, java.security.PublicKey publicKey, java.lang.String header, java.lang.String payload, byte[] signatureBytes)Verify signature for JWT header and payload.
-
-
-
Field Detail
-
JWT_PART_SEPARATOR
private static final byte JWT_PART_SEPARATOR
- See Also:
- Constant Field Values
-
-
Method Detail
-
verifySignatureFor
boolean verifySignatureFor(java.lang.String algorithm, byte[] secretBytes, java.lang.String header, java.lang.String payload, byte[] signatureBytes) throws java.security.NoSuchAlgorithmException, java.security.InvalidKeyExceptionVerify 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:
java.security.NoSuchAlgorithmException- if the algorithm is not supported.java.security.InvalidKeyException- if the given key is inappropriate for initializing the specified algorithm.
-
verifySignatureFor
boolean verifySignatureFor(java.lang.String algorithm, byte[] secretBytes, byte[] headerBytes, byte[] payloadBytes, byte[] signatureBytes) throws java.security.NoSuchAlgorithmException, java.security.InvalidKeyExceptionVerify 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:
java.security.NoSuchAlgorithmException- if the algorithm is not supported.java.security.InvalidKeyException- if the given key is inappropriate for initializing the specified algorithm.
-
createSignatureFor
byte[] createSignatureFor(java.lang.String algorithm, byte[] secretBytes, byte[] headerBytes, byte[] payloadBytes) throws java.security.NoSuchAlgorithmException, java.security.InvalidKeyExceptionCreate signature for JWT header and payload.- Parameters:
algorithm- algorithm name.secretBytes- algorithm secret.headerBytes- JWT header.payloadBytes- JWT payload.- Returns:
- the signature bytes.
- Throws:
java.security.NoSuchAlgorithmException- if the algorithm is not supported.java.security.InvalidKeyException- if the given key is inappropriate for initializing the specified algorithm.
-
verifySignatureFor
boolean verifySignatureFor(java.lang.String algorithm, java.security.PublicKey publicKey, java.lang.String header, java.lang.String payload, byte[] signatureBytes) throws java.security.NoSuchAlgorithmException, java.security.InvalidKeyException, java.security.SignatureExceptionVerify 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:
java.security.NoSuchAlgorithmException- if the algorithm is not supported.java.security.InvalidKeyException- if the given key is inappropriate for initializing the specified algorithm.java.security.SignatureException
-
verifySignatureFor
boolean verifySignatureFor(java.lang.String algorithm, java.security.PublicKey publicKey, byte[] headerBytes, byte[] payloadBytes, byte[] signatureBytes) throws java.security.NoSuchAlgorithmException, java.security.InvalidKeyException, java.security.SignatureExceptionVerify 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:
java.security.NoSuchAlgorithmException- if the algorithm is not supported.java.security.InvalidKeyException- if the given key is inappropriate for initializing the specified algorithm.java.security.SignatureException
-
createSignatureFor
byte[] createSignatureFor(java.lang.String algorithm, java.security.PrivateKey privateKey, byte[] headerBytes, byte[] payloadBytes) throws java.security.NoSuchAlgorithmException, java.security.InvalidKeyException, java.security.SignatureExceptionCreate 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:
java.security.NoSuchAlgorithmException- if the algorithm is not supported.java.security.InvalidKeyException- if the given key is inappropriate for initializing the specified algorithm.java.security.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(java.lang.String algorithm, byte[] secretBytes, byte[] contentBytes, byte[] signatureBytes) throws java.security.NoSuchAlgorithmException, java.security.InvalidKeyExceptionDeprecated.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:
java.security.NoSuchAlgorithmException- if the algorithm is not supported.java.security.InvalidKeyException- if the given key is inappropriate for initializing the specified algorithm.
-
createSignatureFor
@Deprecated byte[] createSignatureFor(java.lang.String algorithm, byte[] secretBytes, byte[] contentBytes) throws java.security.NoSuchAlgorithmException, java.security.InvalidKeyExceptionDeprecated.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:
java.security.NoSuchAlgorithmException- if the algorithm is not supported.java.security.InvalidKeyException- if the given key is inappropriate for initializing the specified algorithm.
-
verifySignatureFor
@Deprecated boolean verifySignatureFor(java.lang.String algorithm, java.security.PublicKey publicKey, byte[] contentBytes, byte[] signatureBytes) throws java.security.NoSuchAlgorithmException, java.security.InvalidKeyException, java.security.SignatureExceptionDeprecated.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:
java.security.NoSuchAlgorithmException- if the algorithm is not supported.java.security.InvalidKeyException- if the given key is inappropriate for initializing the specified algorithm.java.security.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(java.lang.String algorithm, java.security.PrivateKey privateKey, byte[] contentBytes) throws java.security.NoSuchAlgorithmException, java.security.InvalidKeyException, java.security.SignatureExceptionDeprecated.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:
java.security.NoSuchAlgorithmException- if the algorithm is not supported.java.security.InvalidKeyException- if the given key is inappropriate for initializing the specified algorithm.java.security.SignatureException- if this signature object is not initialized properly or if this signature algorithm is unable to process the input data provided.
-
-