Package com.ibm.security.access.signing
Class SigningHelper
java.lang.Object
com.ibm.security.access.signing.SigningHelper
Simple class to handle signing of data using backing Java Signing classes.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]
certificateToPublicKey
(byte[] certificate) Convert they bytes of an x509 certificate to a public key.boolean
checkKey
(byte[] keyBytes) Check if a public key is validboolean
checkKeyB64
(String key) Check if a base64 encoded public key is validboolean
checkKeyB64Url
(String key) Check if a base64 url encoded public key is validbyte[]
getPublicKey
(String keyStore, String label) Retrieve a public key from Verify Identity Access.getPublicKeyB64
(String keyStore, String label) Retrieve a public key from Verify Identity Access.getPublicKeyB64Url
(String keyStore, String label) Retrieve a public key from Verify Identity Access.static String[]
byte[]
sign
(byte[] data, byte[] privateKey) Sign a piece of data using a provided private key.byte[]
Sign a piece of data using a given keystore and label.Sign a piece of data using the provided private key.Sign a piece of data using a given keystore and label.signB64Url
(String data, String privateKey) Sign a piece of data using the provided private key.signB64Url
(String data, String keyStore, String label) Sign a piece of data using a given keystore and label.verify
(byte[] data, byte[] signature, byte[] publicKey) Validate a piece of data against a given signature and public keyValidate a piece of data against a given signature and public keyValidate a piece of data against a given signature and public key The signature and public key values will be Base64 decoded to get the bytes to use in the verification.Validate a piece of data against a given signature and public key The signature value will be Base64 decoded to get the bytes to use.verifyB64Url
(String data, String signature, String publicKey) Validate a piece of data against a given signature and public key The signature and public key values will be Base64Url decoded to get the bytes to use in the verificationverifyB64Url
(String data, String signature, String keyStore, String label) Validate a piece of data against a given signature and public key This method assumes ALL parameters are a base64URL encoded string.
-
Field Details
-
SigningHelper_java_sourceCodeID
- See Also:
-
SigningHelper_java_copyright
- See Also:
-
-
Constructor Details
-
SigningHelper
-
-
Method Details
-
getSupportedAlgorithms
-
verifyB64
Validate a piece of data against a given signature and public key The signature and public key values will be Base64 decoded to get the bytes to use in the verification.- Parameters:
data
- to validate against the provided signature. This value is not decodedsignature
- provided signature to validate againstpublicKey
- to use when signing the data- Returns:
- true if the signature matches, false if it does not, null if an error occured.
-
verifyB64Url
Validate a piece of data against a given signature and public key The signature and public key values will be Base64Url decoded to get the bytes to use in the verification- Parameters:
data
- to validate against the provided signature. This value is not decodedsignature
- provided signature to validate againstpublicKey
- to use when signing the data- Returns:
- true if the signature matches, false if it does not, null if an error occured.
-
verify
Validate a piece of data against a given signature and public key- Parameters:
data
- to validate against the provided signature.signature
- provided signature to validate againstpublicKey
- to use when signing the data- Returns:
- true if the signature matches, false if it does not, null if an error occured.
-
verifyB64
Validate a piece of data against a given signature and public key The signature value will be Base64 decoded to get the bytes to use.- Parameters:
signature
- provided signature to validate againstkeyStore
- to search for public key inlabel
- of the certificate to use- Returns:
- true if the signature matches, false if it does not, null if an error occured.
-
verifyB64Url
Validate a piece of data against a given signature and public key This method assumes ALL parameters are a base64URL encoded string. All provided values will be Base64Url decoded to get the bytes to use.- Parameters:
signature
- provided signature to validate againstkeyStore
- to search for public key inlabel
- of the certificate to use- Returns:
- true if the signature matches, false if it does not, null if an error occured.
-
verify
Validate a piece of data against a given signature and public key- Parameters:
signature
- provided signature to validate againstkeyStore
- to search for public key inlabel
- of the certificate to use- Returns:
- true if the signature matches, false if it does not, null if an error occured.
-
getPublicKeyB64
Retrieve a public key from Verify Identity Access.- Parameters:
keyStore
- to retrieve the key fromthe
- label of the key to retrieve- Returns:
- the bytes of this public key as a base64 encoded string / null if an error occurred
-
getPublicKeyB64Url
Retrieve a public key from Verify Identity Access.- Parameters:
keyStore
- to retrieve the key fromthe
- label of the key to retrieve- Returns:
- the bytes of this public key as a base64url encoded string / null if an error occurred
-
getPublicKey
Retrieve a public key from Verify Identity Access.- Parameters:
keyStore
- to retrieve the key fromthe
- label of the key to retrieve- Returns:
- the bytes of this public key / null if an error occured
-
signB64Url
Sign a piece of data using the provided private key. It is assumed that the private key is base64url encoded. The produced signature is base64 url encoded.- Parameters:
data
- to signprivateKey
- to perform the signing with- Returns:
- base64url encoded signature of the data.
-
signB64Url
Sign a piece of data using a given keystore and label. It is assumed that the private key is base64url encoded. The produced signature is base64 url encoded.- Parameters:
data
- to signkeyStore
- to retrieve the key fromlabel
- for the key to use- Returns:
- base64url encoded signature of the data.
-
signB64
Sign a piece of data using the provided private key. It is assumed that the private key is base64 encoded. The produced signature is base64 encoded.- Parameters:
data
- to signprivateKey
- to perform the signing with- Returns:
- base64 encoded signature of the data.
-
signB64
Sign a piece of data using a given keystore and label. It is assumed that the private key is base64 encoded. The produced signature is base64 encoded.- Parameters:
data
- to signkeyStore
- to retrieve the key fromlabel
- for the key to use- Returns:
- base64 encoded signature of the data.
-
sign
public byte[] sign(byte[] data, byte[] privateKey) Sign a piece of data using a provided private key. It is assumed that the private key is not encoded. The produced signature is the raw bytes produced by the sign call- Parameters:
data
- to signkeyStore
- to retrieve the key fromlabel
- for the key to use- Returns:
- base64 encoded signature of the data.
-
sign
Sign a piece of data using a given keystore and label. It is assumed that the private key is not encoded. The produced signature is the raw bytes produced by the sign call- Parameters:
data
- to signkeyStore
- to retrieve the key fromlabel
- for the key to use- Returns:
- base64 encoded signature of the data.
-
certificateToPublicKey
public byte[] certificateToPublicKey(byte[] certificate) Convert they bytes of an x509 certificate to a public key.- Parameters:
certificate
- to extract the public key from- Returns:
- null on error / the public key contained in the certificate.
-
checkKey
public boolean checkKey(byte[] keyBytes) Check if a public key is valid- Parameters:
bytes
- to check- Returns:
- true if its a valid public key / false if its invalid
-
checkKeyB64
Check if a base64 encoded public key is valid- Parameters:
bytes
- to check- Returns:
- true if its a valid public key / false if its invalid
-
checkKeyB64Url
Check if a base64 url encoded public key is valid- Parameters:
bytes
- to check- Returns:
- true if its a valid public key / false if its invalid
-