public class SignatureUtil extends Object
Constructor and Description |
---|
SignatureUtil() |
Modifier and Type | Method and Description |
---|---|
static KeyValueType |
createKeyValue(PublicKey key)
Creates a
KeyValueType that wraps the specified public key. |
static DSAKeyValueType |
getDSAKeyValue(Element element)
Given a dsig:DSAKeyValue element, return
DSAKeyValueType |
static RSAKeyValueType |
getRSAKeyValue(Element element)
Given a dsig:DSAKeyValue element, return
DSAKeyValueType |
static String |
getXMLSignatureAlgorithmURI(String algo)
Get the XML Signature URI for the algo (RSA, DSA)
|
static void |
marshall(SignatureType signature,
OutputStream os)
Marshall a SignatureType to output stream
|
static byte[] |
sign(String stringToBeSigned,
PrivateKey signingKey)
Sign a string using the private key
|
static boolean |
validate(byte[] signedContent,
byte[] signatureValue,
PublicKey validatingKey)
Validate the signed content with the signature value
|
static boolean |
validate(byte[] signedContent,
byte[] signatureValue,
String signatureAlgorithm,
X509Certificate validatingCert)
Validate the signature using a x509 certificate
|
public static void marshall(SignatureType signature, OutputStream os) throws JAXBException, SAXException
signature
- os
- SAXException
JAXBException
public static String getXMLSignatureAlgorithmURI(String algo)
algo
- public static byte[] sign(String stringToBeSigned, PrivateKey signingKey) throws GeneralSecurityException
stringToBeSigned
- signingKey
- GeneralSecurityException
public static boolean validate(byte[] signedContent, byte[] signatureValue, PublicKey validatingKey) throws GeneralSecurityException
signedContent
- signatureValue
- validatingKey
- GeneralSecurityException
public static boolean validate(byte[] signedContent, byte[] signatureValue, String signatureAlgorithm, X509Certificate validatingCert) throws GeneralSecurityException
signedContent
- signatureValue
- signatureAlgorithm
- validatingCert
- GeneralSecurityException
public static DSAKeyValueType getDSAKeyValue(Element element) throws ParsingException
DSAKeyValueType
element
- ParsingException
public static RSAKeyValueType getRSAKeyValue(Element element) throws ParsingException
DSAKeyValueType
element
- ParsingException
public static KeyValueType createKeyValue(PublicKey key)
Creates a KeyValueType
that wraps the specified public key. This method supports DSA and RSA keys.
key
- the PublicKey
that will be represented as a KeyValueType
.KeyValueType
or null
if the specified key is neither a DSA nor a RSA
key.Copyright © 2021 JBoss by Red Hat. All rights reserved.