public final class XMLSecTool extends Object
| Modifier and Type | Field and Description |
|---|---|
private static Logger |
log
Class logger.
|
| Modifier | Constructor and Description |
|---|---|
private |
XMLSecTool()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected static void |
addSignatureELement(CommandLineArguments cli,
Element root,
Element signature)
Adds the signature element at the appropriate place in the document.
|
protected static String |
determineSignatureAlgorithm(CommandLineArguments cli,
org.opensaml.security.x509.X509Credential signingCredential)
Determine the signature algorithm to use.
|
protected static Reference |
extractReference(XMLSignature signature)
Extract the reference within the provided XML signature while ensuring that there
is only one such reference.
|
protected static org.opensaml.security.x509.X509Credential |
getCredential(CommandLineArguments cli)
Gets the credentials used for signing and signature verification.
|
protected static Collection<X509CRL> |
getCRLs(CommandLineArguments cli)
Gets the CRLs referenced on the command line, if any.
|
protected static DocumentBuilder |
getParser()
Constructs a DOM parser used to parse the input XML.
|
protected static Element |
getSignatureElement(Document xmlDoc)
Gets the signature element from the document.
|
protected static String |
getSignatureReferenceUri(CommandLineArguments cli,
Element rootElement)
Gets the reference of the URI to use for the signature.
|
protected static InputStream |
getXmlInputStreamFromFile(CommandLineArguments cli)
Creates an input stream that reads the input XML from a file.
|
protected static InputStream |
getXmlInputStreamFromUrl(CommandLineArguments cli)
Creates an input stream that reads the input XML from an HTTP URL.
|
protected static void |
initLogging(CommandLineArguments cli)
Initialize the logging subsystem.
|
static void |
main(String[] args)
Main command-line entry point.
|
protected static void |
markIdAttribute(Element docElement,
Reference reference)
Reconcile the given reference with the document element, by making sure that
the appropriate attribute is marked as an ID attribute.
|
protected static Document |
parseXML(CommandLineArguments cli)
Parses the input XML from its source and converts it to a DOM document.
|
protected static void |
populateKeyInfo(Document doc,
KeyInfo keyInfo,
org.opensaml.security.x509.X509Credential credential)
Populates an XML signature's KeyInfo with X.509 credential information.
|
protected static void |
schemaValidate(CommandLineArguments cli,
Document xml)
Validates the document against the schema source indicated by the CLI arguments.
|
protected static void |
sign(CommandLineArguments cli,
org.opensaml.security.x509.X509Credential signingCredential,
Document xml)
Signs a document.
|
protected static void |
validateSignatureReference(Document xmlDocument,
Reference ref)
Validates the reference within the XML signature by performing the following checks.
|
protected static void |
validateSignatureReferenceUri(Document xmlDocument,
Reference reference)
Validates that the element resolved by the signature validation layer is the same as the
element resolved by the DOM layer.
|
protected static void |
validateSignatureTransforms(Reference reference)
Validate the transforms included in the Signature Reference.
|
protected static void |
verifySignature(CommandLineArguments cli,
org.opensaml.security.x509.X509Credential credential,
Document xmlDocument)
Verifies that the signature on a document is valid.
|
protected static void |
writeDocument(CommandLineArguments cli,
Node xml)
Writes a DOM element to the output file.
|
private static Logger log
public static void main(String[] args)
args - command-line argumentsprotected static Document parseXML(CommandLineArguments cli)
cli - command line argumentsprotected static InputStream getXmlInputStreamFromFile(CommandLineArguments cli)
cli - command line argumentsprotected static InputStream getXmlInputStreamFromUrl(CommandLineArguments cli)
cli - command line argumentsprotected static DocumentBuilder getParser()
protected static void schemaValidate(CommandLineArguments cli, Document xml)
cli - command line argumentsxml - document to validateprotected static void sign(@Nonnull CommandLineArguments cli, @Nonnull org.opensaml.security.x509.X509Credential signingCredential, @Nonnull Document xml)
cli - command line argumentssigningCredential - credential to use for signingxml - document to be signedprotected static String determineSignatureAlgorithm(@Nonnull CommandLineArguments cli, @Nonnull org.opensaml.security.x509.X509Credential signingCredential)
cli - command line argumentssigningCredential - credential to use for signingStringprotected static void populateKeyInfo(Document doc, KeyInfo keyInfo, org.opensaml.security.x509.X509Credential credential)
doc - XML document in which the elements will be rootedkeyInfo - the KeyInfo to be populatedcredential - the credentialprotected static String getSignatureReferenceUri(CommandLineArguments cli, Element rootElement)
cli - command line argumentsrootElement - document root elementprotected static void addSignatureELement(CommandLineArguments cli, Element root, Element signature)
cli - command line argumentroot - element to which the signature will be added as a childsignature - signature to be added to the document's root elementprotected static void markIdAttribute(Element docElement, Reference reference)
docElement - document element whose appropriate attribute should be markedreference - reference which references the document elementprotected static void verifySignature(CommandLineArguments cli, @Nonnull org.opensaml.security.x509.X509Credential credential, Document xmlDocument)
cli - command line argumentcredential - credential to use for validationxmlDocument - document whose signature will be validatedprotected static Reference extractReference(XMLSignature signature)
signature - signature to extract the reference fromprotected static void validateSignatureReference(Document xmlDocument, Reference ref)
xmlDocument - current XML documentref - reference to be verifiedprotected static void validateSignatureReferenceUri(Document xmlDocument, Reference reference)
xmlDocument - the signed documentreference - the reference to be validatedprotected static void validateSignatureTransforms(Reference reference)
reference - the Signature reference containing the transforms to evaluateprotected static Element getSignatureElement(Document xmlDoc)
xmlDoc - document from which to pull the signatureprotected static org.opensaml.security.x509.X509Credential getCredential(CommandLineArguments cli)
cli - command line argumentsprotected static Collection<X509CRL> getCRLs(CommandLineArguments cli)
cli - command line argumentsprotected static void writeDocument(CommandLineArguments cli, Node xml)
cli - command line argumentsxml - the XML element to outputprotected static void initLogging(CommandLineArguments cli)
cli - command line argumentsCopyright © 2011–2016. All rights reserved.