Class SignatureUtil
java.lang.Object
org.keycloak.saml.processing.core.saml.v2.util.SignatureUtil
Signature utility for signing content
- Since:
- Dec 16, 2008
- Author:
- Anil.Saldhana@redhat.com
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic KeyValueType
createKeyValue
(PublicKey key) Creates aKeyValueType
that wraps the specified public key.static String
Get the XML Signature URI for the algo (RSA, DSA)static void
marshall
(SignatureType signature, OutputStream os) Marshall a SignatureType to output streamstatic byte[]
sign
(String stringToBeSigned, PrivateKey signingKey) Sign a string using the private keystatic boolean
validate
(byte[] signedContent, byte[] signatureValue, String signatureAlgorithm, X509Certificate validatingCert) Validate the signature using a x509 certificatestatic boolean
Validate the signed content with the signature value
-
Constructor Details
-
SignatureUtil
public SignatureUtil()
-
-
Method Details
-
marshall
public static void marshall(SignatureType signature, OutputStream os) throws jakarta.xml.bind.JAXBException, SAXException Marshall a SignatureType to output stream- Parameters:
signature
-os
-- Throws:
SAXException
jakarta.xml.bind.JAXBException
-
getXMLSignatureAlgorithmURI
Get the XML Signature URI for the algo (RSA, DSA)- Parameters:
algo
-- Returns:
-
sign
public static byte[] sign(String stringToBeSigned, PrivateKey signingKey) throws GeneralSecurityException Sign a string using the private key- Parameters:
stringToBeSigned
-signingKey
-- Returns:
- Throws:
GeneralSecurityException
-
validate
public static boolean validate(byte[] signedContent, byte[] signatureValue, PublicKey validatingKey) throws GeneralSecurityException Validate the signed content with the signature value- Parameters:
signedContent
-signatureValue
-validatingKey
-- Returns:
- Throws:
GeneralSecurityException
-
validate
public static boolean validate(byte[] signedContent, byte[] signatureValue, String signatureAlgorithm, X509Certificate validatingCert) throws GeneralSecurityException Validate the signature using a x509 certificate- Parameters:
signedContent
-signatureValue
-signatureAlgorithm
-validatingCert
-- Returns:
- Throws:
GeneralSecurityException
-
createKeyValue
Creates a
KeyValueType
that wraps the specified public key. This method supports DSA and RSA keys.- Parameters:
key
- thePublicKey
that will be represented as aKeyValueType
.- Returns:
- the constructed
KeyValueType
ornull
if the specified key is neither a DSA nor a RSA key.
-