Search in sources :

Example 1 with SignatureTimeDocument

use of org.openxmlformats.schemas.xpackage.x2006.digitalSignature.SignatureTimeDocument in project poi by apache.

the class OOXMLSignatureFacet method addSignatureTime.

protected void addSignatureTime(Document document, List<XMLStructure> objectContent) {
    /*
         * SignatureTime
         */
    DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ROOT);
    fmt.setTimeZone(LocaleUtil.TIMEZONE_UTC);
    String nowStr = fmt.format(signatureConfig.getExecutionTime());
    LOG.log(POILogger.DEBUG, "now: " + nowStr);
    SignatureTimeDocument sigTime = SignatureTimeDocument.Factory.newInstance();
    CTSignatureTime ctTime = sigTime.addNewSignatureTime();
    ctTime.setFormat("YYYY-MM-DDThh:mm:ssTZD");
    ctTime.setValue(nowStr);
    Element n = (Element) document.importNode(ctTime.getDomNode(), true);
    List<XMLStructure> signatureTimeContent = new ArrayList<XMLStructure>();
    signatureTimeContent.add(new DOMStructure(n));
    SignatureProperty signatureTimeSignatureProperty = getSignatureFactory().newSignatureProperty(signatureTimeContent, "#" + signatureConfig.getPackageSignatureId(), "idSignatureTime");
    List<SignatureProperty> signaturePropertyContent = new ArrayList<SignatureProperty>();
    signaturePropertyContent.add(signatureTimeSignatureProperty);
    SignatureProperties signatureProperties = getSignatureFactory().newSignatureProperties(signaturePropertyContent, "id-signature-time-" + signatureConfig.getExecutionTime());
    objectContent.add(signatureProperties);
}
Also used : Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) XMLStructure(javax.xml.crypto.XMLStructure) SignatureProperty(javax.xml.crypto.dsig.SignatureProperty) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) CTSignatureTime(org.openxmlformats.schemas.xpackage.x2006.digitalSignature.CTSignatureTime) DOMStructure(javax.xml.crypto.dom.DOMStructure) SignatureProperties(javax.xml.crypto.dsig.SignatureProperties) SignatureTimeDocument(org.openxmlformats.schemas.xpackage.x2006.digitalSignature.SignatureTimeDocument) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 XMLStructure (javax.xml.crypto.XMLStructure)1 DOMStructure (javax.xml.crypto.dom.DOMStructure)1 SignatureProperties (javax.xml.crypto.dsig.SignatureProperties)1 SignatureProperty (javax.xml.crypto.dsig.SignatureProperty)1 CTSignatureTime (org.openxmlformats.schemas.xpackage.x2006.digitalSignature.CTSignatureTime)1 SignatureTimeDocument (org.openxmlformats.schemas.xpackage.x2006.digitalSignature.SignatureTimeDocument)1 Element (org.w3c.dom.Element)1