Esempio n. 1
0
 private String getCertificateIdByDigest(
     XmlDigestAlgAndValueType digestAlgoValue, DiagnosticData diagnosticData) {
   List<CertificateWrapper> certificates = diagnosticData.getUsedCertificates();
   if (CollectionUtils.isNotEmpty(certificates)) {
     for (CertificateWrapper certificate : certificates) {
       List<XmlDigestAlgAndValueType> digestAlgAndValues = certificate.getDigestAlgAndValue();
       if (CollectionUtils.isNotEmpty(digestAlgAndValues)) {
         for (XmlDigestAlgAndValueType certificateDigestAndValue : digestAlgAndValues) {
           if (StringUtils.equals(
                   certificateDigestAndValue.getDigestMethod(), digestAlgoValue.getDigestMethod())
               && StringUtils.equals(
                   certificateDigestAndValue.getDigestValue(), digestAlgoValue.getDigestValue())) {
             return certificate.getId();
           }
         }
       }
     }
   }
   return null;
 }
Esempio n. 2
0
  public void extractPOE(TimestampWrapper timestamp, DiagnosticData diagnosticData) {

    Date productionTime = timestamp.getProductionTime();

    XmlSignedObjectsType signedObjects = timestamp.getSignedObjects();
    if (signedObjects != null) {
      if (CollectionUtils.isNotEmpty(signedObjects.getSignedSignature())) {
        // SIGNATURES and TIMESTAMPS
        for (XmlSignedSignature signedSignature : signedObjects.getSignedSignature()) {
          addPOE(signedSignature.getId(), productionTime);
        }
        for (XmlTimestampedTimestamp timstampedTimastamp :
            signedObjects.getTimestampedTimestamp()) {
          addPOE(timstampedTimastamp.getId(), productionTime);
        }
      }

      if (CollectionUtils.isNotEmpty(signedObjects.getDigestAlgAndValue())) {
        for (XmlDigestAlgAndValueType digestAlgoAndValue : signedObjects.getDigestAlgAndValue()) {
          if (StringUtils.equals(
              TimestampReferenceCategory.CERTIFICATE.name(), digestAlgoAndValue.getCategory())) {
            String certificateId = getCertificateIdByDigest(digestAlgoAndValue, diagnosticData);
            if (certificateId != null) {
              addPOE(certificateId, productionTime);
            }
          } else if (StringUtils.equals(
              TimestampReferenceCategory.REVOCATION.name(), digestAlgoAndValue.getCategory())) {
            String revocationId = getRevocationIdByDigest(digestAlgoAndValue, diagnosticData);
            if (revocationId != null) {
              addPOE(revocationId, productionTime);
            }
          }
        }
      }
    }
  }
Esempio n. 3
0
 private String getRevocationIdByDigest(
     XmlDigestAlgAndValueType digestAlgoValue, DiagnosticData diagnosticData) {
   List<CertificateWrapper> certificates = diagnosticData.getUsedCertificates();
   if (CollectionUtils.isNotEmpty(certificates)) {
     for (CertificateWrapper certificate : certificates) {
       Set<RevocationWrapper> revocations = certificate.getRevocationData();
       if (CollectionUtils.isNotEmpty(revocations)) {
         for (RevocationWrapper revocationData : revocations) {
           List<XmlDigestAlgAndValueType> digestAlgAndValues =
               revocationData.getDigestAlgAndValue();
           for (XmlDigestAlgAndValueType revocDigestAndValue : digestAlgAndValues) {
             if (StringUtils.equals(
                     revocDigestAndValue.getDigestMethod(), digestAlgoValue.getDigestMethod())
                 && StringUtils.equals(
                     revocDigestAndValue.getDigestValue(), digestAlgoValue.getDigestValue())) {
               return revocationData.getId();
             }
           }
         }
       }
     }
   }
   return null;
 }