예제 #1
0
  @Override
  public List<TimestampToken> getArchiveTimestamps() {
    final List<TimestampToken> archiveTimestampTokenList = new ArrayList<TimestampToken>();
    final List<String> timestampedTimestamps = new ArrayList<String>();
    final Set<PdfSignatureOrDocTimestampInfo> outerSignatures =
        pdfSignatureInfo.getOuterSignatures();
    usedCertificatesDigestAlgorithms.add(DigestAlgorithm.SHA1);
    for (final PdfSignatureOrDocTimestampInfo outerSignature : outerSignatures) {

      if (outerSignature.isTimestamp()) {

        PdfDocTimestampInfo pdfBoxTimestampInfo = (PdfDocTimestampInfo) outerSignature;
        // return this timestamp if it's an archive timestamp
        final TimestampToken timestampToken = pdfBoxTimestampInfo.getTimestampToken();
        if (timestampToken.getTimeStampType() == TimestampType.ARCHIVE_TIMESTAMP) {

          final List<TimestampReference> references =
              cadesSignature.getSignatureTimestampedReferences();
          for (final String timestampId : timestampedTimestamps) {

            final TimestampReference signatureReference_ = new TimestampReference(timestampId);
            references.add(signatureReference_);
          }
          final List<CertificateToken> certificates = getCertificates();
          for (final CertificateToken certificate : certificates) {
            references.add(createCertificateTimestampReference(certificate));
          }
          timestampToken.setTimestampedReferences(references);
          archiveTimestampTokenList.add(timestampToken);
        }
        timestampedTimestamps.add(String.valueOf(timestampToken.getDSSId()));
      }
    }
    return Collections.unmodifiableList(archiveTimestampTokenList);
  }
예제 #2
0
  @Override
  public List<TimestampToken> getSignatureTimestamps() {

    final List<TimestampToken> result = new ArrayList<TimestampToken>();
    result.addAll(cadesSignatureTimestamps);
    final Set<PdfSignatureOrDocTimestampInfo> outerSignatures =
        pdfSignatureInfo.getOuterSignatures();
    for (final PdfSignatureOrDocTimestampInfo outerSignature : outerSignatures) {

      if (outerSignature.isTimestamp() && (outerSignature instanceof PdfDocTimestampInfo)) {

        final PdfDocTimestampInfo pdfBoxTimestampInfo = (PdfDocTimestampInfo) outerSignature;
        // do not return this timestamp if it's an archive timestamp
        final TimestampToken timestampToken = pdfBoxTimestampInfo.getTimestampToken();
        if (timestampToken.getTimeStampType() == TimestampType.SIGNATURE_TIMESTAMP) {

          timestampToken.setTimestampedReferences(
              cadesSignature.getSignatureTimestampedReferences());
          result.add(timestampToken);
        }
      }
    }
    return Collections.unmodifiableList(result);
  }