Package org.forgerock.util
Class SignatureUtil
- java.lang.Object
 - 
- org.forgerock.util.SignatureUtil
 
 
- 
public final class SignatureUtil extends Object
Utility class for signing and verifying signatures. 
- 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SignatureUtilgetInstance()Gets the SignatureUtil instance.byte[]sign(PrivateKey privateKey, String algorithm, String message)Signs a String using the given private key.booleanverify(X509Certificate certificate, String algorithm, String message, byte[] signatureData)Verifies a signature of a String using the certificate.booleanverify(PublicKey publicKey, String algorithm, String message, byte[] signatureData)Verifies a signature of a String using the public key. 
 - 
 
- 
- 
Method Detail
- 
getInstance
public static SignatureUtil getInstance()
Gets the SignatureUtil instance.- Returns:
 - The SignatureUtil singleton instance.
 
 
- 
sign
public byte[] sign(PrivateKey privateKey, String algorithm, String message) throws SignatureException
Signs a String using the given private key. Uses the algorithm from the private key to perform the signature.- Parameters:
 privateKey- The private key to use to sign the String.algorithm- The algorithm to use in the signing.message- The String to sign.- Returns:
 - The byte array of the signature.
 - Throws:
 SignatureException- If there is a problem when performing the signature.
 
- 
verify
public boolean verify(X509Certificate certificate, String algorithm, String message, byte[] signatureData) throws SignatureException
Verifies a signature of a String using the certificate. Uses the algorithm from the certificate to perform the verification of the signature.- Parameters:
 certificate- The X509Certificate to use to verify the signature.algorithm- The algorithm to use in the signing.message- The String that was signed.signatureData- The byte array of the signature.- Returns:
 - Whether or not the signature is valid for the String that was signed.
 - Throws:
 SignatureException- If there is a problem when verifying the signature.
 
- 
verify
public boolean verify(PublicKey publicKey, String algorithm, String message, byte[] signatureData) throws SignatureException
Verifies a signature of a String using the public key. Uses the algorithm from the public key to perform the verification of the signature.- Parameters:
 publicKey- The public key to use to verify the signature.algorithm- The algorithm to use in the signing.message- The String that was signed.signatureData- The byte array of the signature.- Returns:
 - Whether or not the signature is valid for the String that was signed.
 - Throws:
 SignatureException- If there is a problem when verifying the signature.
 
 - 
 
 -