Package com.itextpdf.text.pdf.security
Class MakeXmlSignature
java.lang.Object
com.itextpdf.text.pdf.security.MakeXmlSignature
Class that signs your XML.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classEmpty class for key simulation -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static XMLSignatureFactoryprivate static ElementfindElement(NodeList nodes, String localName) Find Signature and SignatureValue elements after marshalization.private static ReferencegenerateContentReference(XMLSignatureFactory fac, XmlSignatureAppearance sap, String referenceId) private static ReferencegenerateCustomReference(XMLSignatureFactory fac, String uri, String type, String id) private static KeyInfogenerateKeyInfo(Certificate[] chain, XmlSignatureAppearance sap) private static KeyInfogenerateKeyInfo(PublicKey publicKey) private static XMLObjectgenerateXadesObject(XMLSignatureFactory fac, XmlSignatureAppearance sap, String signatureId, String contentReferenceId, String signedPropertiesId, String[] signaturePolicy) private static byte[]getByteArrayOfNode(Node node) private static Stringprivate static Stringprivate static Stringprivate static voidsign(XMLSignatureFactory fac, ExternalSignature externalSignature, XmlLocator locator, org.apache.jcp.xml.dsig.internal.dom.DOMSignedInfo si, XMLObject xo, KeyInfo ki, String signatureId) static voidsignXades(XmlSignatureAppearance sap, ExternalSignature externalSignature, Certificate[] chain, boolean includeSignaturePolicy) Signs the xml with XAdES BES using the enveloped mode, with optional xpath transform (see XmlSignatureAppearance).static voidsignXadesBes(XmlSignatureAppearance sap, ExternalSignature externalSignature, Certificate[] chain) Signs the xml with XAdES BES using the enveloped mode, with optional xpath transform (see XmlSignatureAppearance).static voidsignXadesEpes(XmlSignatureAppearance sap, ExternalSignature externalSignature, Certificate[] chain) Signs the xml with XAdES BES using the enveloped mode, with optional xpath transform (see XmlSignatureAppearance).static voidsignXmlDSig(XmlSignatureAppearance sap, ExternalSignature externalSignature, Certificate[] chain) Signs the xml with XmlDSig using the enveloped mode, with optional xpath transform (see XmlSignatureAppearance).static voidsignXmlDSig(XmlSignatureAppearance sap, ExternalSignature externalSignature, PublicKey publicKey) Signs the xml with XmlDSig using the enveloped mode, with optional xpath transform (see XmlSignatureAppearance).static voidsignXmlDSig(XmlSignatureAppearance sap, ExternalSignature externalSignature, KeyInfo keyInfo) Signs the xml with XmlDSig using the enveloped mode, with optional xpath transform (see XmlSignatureAppearance).private static voidverifyArguments(XmlSignatureAppearance sap, ExternalSignature externalSignature)
-
Constructor Details
-
MakeXmlSignature
public MakeXmlSignature()
-
-
Method Details
-
signXmlDSig
public static void signXmlDSig(XmlSignatureAppearance sap, ExternalSignature externalSignature, KeyInfo keyInfo) throws GeneralSecurityException, IOException, DocumentException Signs the xml with XmlDSig using the enveloped mode, with optional xpath transform (see XmlSignatureAppearance).- Parameters:
sap- the XmlSignatureAppearanceexternalSignature- the interface providing the actual signingkeyInfo- KeyInfo for verification- Throws:
GeneralSecurityExceptionIOExceptionDocumentException
-
signXmlDSig
public static void signXmlDSig(XmlSignatureAppearance sap, ExternalSignature externalSignature, Certificate[] chain) throws DocumentException, GeneralSecurityException, IOException Signs the xml with XmlDSig using the enveloped mode, with optional xpath transform (see XmlSignatureAppearance).- Parameters:
sap- the XmlSignatureAppearanceexternalSignature- the interface providing the actual signingchain- the certificate chain- Throws:
GeneralSecurityExceptionIOExceptionDocumentException
-
signXmlDSig
public static void signXmlDSig(XmlSignatureAppearance sap, ExternalSignature externalSignature, PublicKey publicKey) throws GeneralSecurityException, DocumentException, IOException Signs the xml with XmlDSig using the enveloped mode, with optional xpath transform (see XmlSignatureAppearance).- Parameters:
sap- the XmlSignatureAppearanceexternalSignature- the interface providing the actual signingpublicKey- PublicKey for verification- Throws:
GeneralSecurityExceptionIOExceptionDocumentException
-
signXades
public static void signXades(XmlSignatureAppearance sap, ExternalSignature externalSignature, Certificate[] chain, boolean includeSignaturePolicy) throws GeneralSecurityException, DocumentException, IOException Signs the xml with XAdES BES using the enveloped mode, with optional xpath transform (see XmlSignatureAppearance).- Parameters:
sap- the XmlSignatureAppearanceexternalSignature- the interface providing the actual signingchain- the certificate chainincludeSignaturePolicy- if true SignaturePolicyIdentifier will be included (XAdES-EPES)- Throws:
GeneralSecurityExceptionIOExceptionDocumentException
-
signXadesBes
public static void signXadesBes(XmlSignatureAppearance sap, ExternalSignature externalSignature, Certificate[] chain) throws GeneralSecurityException, DocumentException, IOException Signs the xml with XAdES BES using the enveloped mode, with optional xpath transform (see XmlSignatureAppearance).- Parameters:
sap- the XmlSignatureAppearanceexternalSignature- the interface providing the actual signingchain- the certificate chain- Throws:
GeneralSecurityExceptionIOExceptionDocumentException
-
signXadesEpes
public static void signXadesEpes(XmlSignatureAppearance sap, ExternalSignature externalSignature, Certificate[] chain) throws GeneralSecurityException, DocumentException, IOException Signs the xml with XAdES BES using the enveloped mode, with optional xpath transform (see XmlSignatureAppearance).- Parameters:
sap- the XmlSignatureAppearanceexternalSignature- the interface providing the actual signingchain- the certificate chain- Throws:
GeneralSecurityExceptionIOExceptionDocumentException
-
verifyArguments
private static void verifyArguments(XmlSignatureAppearance sap, ExternalSignature externalSignature) throws DocumentException - Throws:
DocumentException
-
findElement
Find Signature and SignatureValue elements after marshalization. -
generateKeyInfo
-
generateKeyInfo
- Throws:
GeneralSecurityException
-
getRandomId
-
createSignatureFactory
-
generateXadesObject
private static XMLObject generateXadesObject(XMLSignatureFactory fac, XmlSignatureAppearance sap, String signatureId, String contentReferenceId, String signedPropertiesId, String[] signaturePolicy) throws GeneralSecurityException - Throws:
GeneralSecurityException
-
getX509IssuerName
-
getX509SerialNumber
-
generateContentReference
private static Reference generateContentReference(XMLSignatureFactory fac, XmlSignatureAppearance sap, String referenceId) throws GeneralSecurityException - Throws:
GeneralSecurityException
-
generateCustomReference
private static Reference generateCustomReference(XMLSignatureFactory fac, String uri, String type, String id) throws GeneralSecurityException - Throws:
GeneralSecurityException
-
sign
private static void sign(XMLSignatureFactory fac, ExternalSignature externalSignature, XmlLocator locator, org.apache.jcp.xml.dsig.internal.dom.DOMSignedInfo si, XMLObject xo, KeyInfo ki, String signatureId) throws DocumentException - Throws:
DocumentException
-
getByteArrayOfNode
-