Ejemplo n.º 1
0
  /**
   * @param simpleReport
   * @param signature the diagnosticSignature element in the diagnostic data
   * @throws DSSException
   */
  private void addSignature(SimpleReport simpleReport, SignatureWrapper signature)
      throws DSSException {

    totalSignatureCount++;

    String signatureId = signature.getId();
    XmlSignature xmlSignature = new XmlSignature();
    xmlSignature.setId(signatureId);

    addCounterSignature(signature, xmlSignature);
    addSignatureScope(signature, xmlSignature);
    addSigningTime(signature, xmlSignature);
    addSignatureFormat(signature, xmlSignature);
    addSignedBy(signature, xmlSignature);

    XmlConstraintsConclusion constraintsConclusion = null;
    switch (validationLevel) {
      case BASIC_SIGNATURES:
      case TIMESTAMPS:
        constraintsConclusion = getBasicSignatureValidationConclusion(signatureId);
        break;
      case LONG_TERM_DATA:
        constraintsConclusion = getLongTermDataValidationConclusion(signatureId);
        break;
      case ARCHIVAL_DATA:
        constraintsConclusion = getArchivalValidationConclusion(signatureId);
        break;
      default:
        logger.error("Unsupported validation level : " + validationLevel);
        break;
    }

    Indication indication = constraintsConclusion.getConclusion().getIndication();
    SubIndication subIndication = constraintsConclusion.getConclusion().getSubIndication();

    List<String> errorList = xmlSignature.getErrors();

    XmlConclusion conclusion = constraintsConclusion.getConclusion();
    List<XmlName> errors = conclusion.getErrors();
    if (CollectionUtils.isNotEmpty(errors)) {
      for (XmlName error : errors) {
        errorList.add(error.getValue());
      }
    }

    // TODO refactor
    xmlSignature.getWarnings().addAll(getWarnings(signatureId));
    xmlSignature.getInfos().addAll(getInfos(signatureId));

    if (Indication.PASSED.equals(indication)) {
      validSignatureCount++;
      xmlSignature.setIndication(Indication.TOTAL_PASSED);
    } else if (Indication.FAILED.equals(indication)) {
      xmlSignature.setIndication(Indication.TOTAL_FAILED);
    } else {
      xmlSignature.setIndication(indication); // INDERTERMINATE
    }
    xmlSignature.setSubIndication(subIndication);

    addSignatureProfile(signature, xmlSignature);

    simpleReport.getSignature().add(xmlSignature);
  }
Ejemplo n.º 2
0
 private void addStatistics(SimpleReport simpleReport) {
   simpleReport.setValidSignaturesCount(validSignatureCount);
   simpleReport.setSignaturesCount(totalSignatureCount);
 }
Ejemplo n.º 3
0
 private void addValidationTime(SimpleReport report) {
   report.setValidationTime(currentTime);
 }
Ejemplo n.º 4
0
 private void addDocumentName(SimpleReport report) {
   report.setDocumentName(diagnosticData.getDocumentName());
 }
Ejemplo n.º 5
0
 private void addPolicyNode(SimpleReport report) {
   XmlPolicy xmlpolicy = new XmlPolicy();
   xmlpolicy.setPolicyName(policy.getPolicyName());
   xmlpolicy.setPolicyDescription(policy.getPolicyDescription());
   report.setPolicy(xmlpolicy);
 }