/** * This method adds a new empty child {@code XmlNode} with the given element name. * * @param childName the name of the element to add * @return added {@code XmlNode} */ public XmlNode addChild(final String childName) { final XmlNode child = new XmlNode(childName); children.add(child); child.parentNode = this; return child; }
/** * This method adds a new child {@code XmlNode} with the given element name and value. * * @param childName the name of the element to add * @param value the text content of the child {@code XmlNode} * @return added {@code XmlNode} */ public XmlNode addChild(final String childName, final String value) { final XmlNode child = new XmlNode(childName, value); children.add(child); return child; }
public XmlNode addFirstChild(final String childName, final String value) { final XmlNode child = new XmlNode(childName, value); children.add(0, child); return child; }
/** * This method adds a new child {@code XmlNode} with the given element name. The value of the new element is set from the call to {@code messageTag.getMessage()}. A new * attribute 'NAME_ID' is added with the value set to {@code messageTag.name()}. New attributes are created from the {@code attributes} {@code Map}. * * @param childName the name of the element to add * @param messageTag {@code MessageTag} * @param attributes {@code Map} containing pairs: attribute name, attribute value * @return added {@code XmlNode} */ public XmlNode addChild(final String childName, final MessageTag messageTag, final Map<String, String> attributes) { final XmlNode child = new XmlNode(childName, messageTag, attributes); children.add(child); return child; }
/** * This method adds a new child {@code XmlNode} with the given element name. The value of the new element is set from the call to {@code messageTag.getMessage()}. A new * attribute 'NAME_ID' is added with the value set to {@code messageTag.name()}. * * @param childName the name of the element to add * @param messageTag {@code MessageTag} * @return added {@code XmlNode} */ public XmlNode addChild(final String childName, final MessageTag messageTag) { final XmlNode child = new XmlNode(childName, messageTag, null); children.add(child); return child; }
@Override public String toString() { try { final StringBuilder indent = new StringBuilder(); final StringBuilder xml = new StringBuilder(); final XmlNode masterNode = new XmlNode("__Master__", null); final XmlNode savedParentNode = getParent(); setParent(masterNode); writeNodes(masterNode, xml, indent, ""); parentNode = savedParentNode; return xml.toString(); } catch (Exception e) { return super.toString(); } } }
/** * @param xmlNode the {@code XmlNode} to which the element is added * @param element the {@code Node} to be copied */ private static void recursiveCopy(final XmlNode xmlNode, final Node element) { final String name = element.getNodeName(); final XmlNode _xmlNode = new XmlNode(name); final NamedNodeMap attributes = element.getAttributes(); for (int jj = 0; jj < attributes.getLength(); jj++) { final Node attrNode = attributes.item(jj); final String attrName = attrNode.getNodeName(); if (!"xmlns".equals(attrName)) { _xmlNode.setAttribute(attrName, attrNode.getNodeValue()); } } final NodeList nodes = element.getChildNodes(); boolean hasElementNodes = false; for (int ii = 0; ii < nodes.getLength(); ii++) { final Node node = nodes.item(ii); if (node.getNodeType() == Node.ELEMENT_NODE) { hasElementNodes = true; recursiveCopy(_xmlNode, node); } } if (!hasElementNodes) { final String value = element.getTextContent(); _xmlNode.setValue(value); } _xmlNode.setParent(xmlNode); }
/** * 9.2.2.4 Processing<br> * <p/> * The following steps shall be performed:<br> * * @param params */ public ControlTimeSlidingConclusion run(final ProcessParameters params, final XmlDom certificateChain) { prepareParameters(params); LOG.debug(this.getClass().getSimpleName() + ": start."); controlTimeSlidingData = new XmlNode(CONTROL_TIME_SLIDING_DATA); /** * 1) Initialise control-time to the current date/time.<br> */ // The control-time is re-initialised at every turn controlTime = params.getCurrentTime(); final ControlTimeSlidingConclusion conclusion = process(params, certificateChain); conclusion.setControlTime(controlTime); conclusion.setValidationData(controlTimeSlidingData); return conclusion; }
/** * @return the {@code InputStream} representing the content of the node. */ public InputStream getInputStream() { try { final StringBuilder indent = new StringBuilder(); final StringBuilder xml = new StringBuilder(); final XmlNode masterNode = new XmlNode("__Master__"); final XmlNode savedParentNode = getParent(); if (savedParentNode != null) { setNameSpace(savedParentNode.getNameSpace()); } setParent(masterNode); writeNodes(masterNode, xml, indent, ""); parentNode = savedParentNode; final byte[] bytes = xml.toString().getBytes("UTF-8"); final InputStream in = new ByteArrayInputStream(bytes); return in; } catch (UnsupportedEncodingException e) { throw new DSSException("Error during the conversion of the XmlNode to the InputStream :", e); } }
/** * This method carry out the Past Signature Validation process. * <p/> * 9.2.1.2 Input<br> * <p/> * - Signature or time-stamp token . Mandatory<br> * - Target certificate ............ Mandatory<br> * - X.509 Validation Parameters ... Mandatory<br> * - A set of POEs ................. Mandatory<br> * - Certificate meta-data ......... Optional<br> * - Chain Constraints ............. Optional<br> * - Cryptographic Constraints ..... Optional<br> * * @param params * @param signature Can be the document or the timestamp signature * @param currentTimeSignatureConclusion * @param context */ public PastSignatureValidationConclusion run(final ProcessParameters params, final XmlDom signature, final XmlDom currentTimeSignatureConclusion, final String context) { this.contextName = context; prepareParameters(params); LOG.debug(this.getClass().getSimpleName() + ": start."); pastSignatureValidationData = new XmlNode(PAST_SIGNATURE_VALIDATION_DATA); pastSignatureValidationData.setNameSpace(XmlDom.NAMESPACE); final PastSignatureValidationConclusion conclusion = process(params, signature, currentTimeSignatureConclusion); conclusion.setValidationData(pastSignatureValidationData); return conclusion; }
LOG.debug(this.getClass().getSimpleName() + ": start."); validationDataXmlNode = new XmlNode(PAST_CERT_VALIDATION_DATA); validationDataXmlNode.setNameSpace(XmlDom.NAMESPACE);
/** * 5.3 X.509 Certificate Validation (XCV)<br> * This method carry out the XCV process. * * @param params validation process parameters * @return false if the validation failed, true otherwise */ public Conclusion run(final ProcessParameters params, final String contextName) { this.contextName = contextName; prepareParameters(params); validationDataXmlNode = new XmlNode(XCV); validationDataXmlNode.setNameSpace(XmlDom.NAMESPACE); final Conclusion conclusion = process(params); conclusion.setValidationData(validationDataXmlNode); return conclusion; }
/** * This method prepares the execution of the ISC process. * * @param params validation process parameters * @return the {@code Conclusion} which indicates the result of the process */ public Conclusion run(final ProcessParameters params, final String contextName) { this.params = params; this.contextName = contextName; prepareParameters(); /** * 5.1 Identification of the signer's certificate (ISC) */ validationDataXmlNode = new XmlNode(ISC); validationDataXmlNode.setNameSpace(XmlDom.NAMESPACE); final Conclusion conclusion = process(params); conclusion.setValidationData(validationDataXmlNode); return conclusion; }
/** * This method creates {@code XmlNode} representing the conclusion of the validation process. * * @return {@code XmlNode} representing the conclusion of the validation process. */ public XmlNode toXmlNode() { final XmlNode conclusion = new XmlNode(CONCLUSION); conclusion.addChild(INDICATION, indication); if (subIndication != null) { conclusion.addChild(SUB_INDICATION, subIndication); } infoToXmlNode(conclusion); warningToXmlNode(conclusion); errorToXmlNode(conclusion); return conclusion; }
/** * This method generates the validation simpleReport. * * @param params validation process parameters * @return the object representing {@code SimpleReport} */ public SimpleReport build(final ProcessParameters params) { final XmlNode simpleReport = new XmlNode(NodeName.SIMPLE_REPORT); simpleReport.setNameSpace(XmlDom.NAMESPACE); try { addPolicyNode(simpleReport); addValidationTime(params, simpleReport); addDocumentName(simpleReport); addSignatures(params, simpleReport); addStatistics(simpleReport); } catch (Exception e) { if (!"WAS TREATED".equals(e.getMessage())) { notifyException(simpleReport, e); } } final Document reportDocument = simpleReport.toDocument(); return new SimpleReport(reportDocument); }
signatureNode.setAttribute(ID, signatureId); conclusionNode = new XmlNode(CONCLUSION); try {
final XmlNode xmlNode = new XmlNode(NodeName.WARNING, LABEL_TINTWS, null); final XmlDom xmlDom = xmlNode.toXmlDom(); infoList.add(xmlDom); } else { final XmlNode xmlNode = new XmlNode(NodeName.WARNING, LABEL_TINVTWS, null); final XmlDom xmlDom = xmlNode.toXmlDom(); infoList.add(xmlDom); final XmlNode xmlNode = new XmlNode(NodeName.INFO, errorMessage); final XmlDom xmlDom = xmlNode.toXmlDom(); infoList.add(xmlDom);
/** * This method executes the long term validation processes. The underlying processes are automatically executed. */ @Override public Reports execute() { processParams = new ProcessParameters(); diagnosticData = new DiagnosticData(diagnosticDataDom); processParams.setDiagnosticData(diagnosticData); processParams.setValidationPolicy(validationPolicy); processParams.setCountersignatureValidationPolicy(countersignatureValidationPolicy); processParams.setCurrentTime(currentTime); final XmlDom usedCertificates = diagnosticData.getElement("/DiagnosticData/UsedCertificates"); processParams.setCertPool(usedCertificates); final XmlNode mainNode = new XmlNode(NodeName.VALIDATION_DATA); mainNode.setNameSpace(XmlDom.NAMESPACE); final LongTermValidation ltv = new LongTermValidation(); ltv.run(mainNode, processParams); final Document validationReportDocument = mainNode.toDocument(); detailedReport = new DetailedReport(validationReportDocument); final SimpleReportBuilder simpleReportBuilder = new SimpleReportBuilder(validationPolicy, diagnosticData); simpleReport = simpleReportBuilder.build(processParams); final Reports reports = new Reports(diagnosticData, detailedReport, simpleReport); return reports; }