@Override protected void addAdditionalInfo() { result.setId(timestamp.getId()); result.setType(timestamp.getType()); result.setProductionTime(timestamp.getProductionTime()); }
public List<TimestampWrapper> getTimestampList() { List<TimestampWrapper> tsps = new ArrayList<TimestampWrapper>(); List<XmlTimestamp> timestamps = signature.getTimestamps(); if (Utils.isCollectionNotEmpty(timestamps)) { for (XmlTimestamp timestamp : timestamps) { tsps.add(new TimestampWrapper(timestamp)); } } return tsps; }
private boolean isTimestampValid(List<TimestampWrapper> timestampList) { for (final TimestampWrapper timestamp : timestampList) { final boolean signatureValid = timestamp.isSignatureValid(); final XmlDigestMatcher messageImprint = timestamp.getMessageImprint(); final boolean messageImprintIntact = messageImprint.isDataFound() && messageImprint.isDataIntact(); if (signatureValid && messageImprintIntact) { return true; } } return false; }
private Date getEarliestTimestampProductionTime(List<TimestampWrapper> timestamps, TimestampType... selectedTimestampTypes) { Date earliestProductionTime = null; for (TimestampWrapper timestamp : timestamps) { if (isInSelectedTypes(selectedTimestampTypes, timestamp.getType())) { Date productionTime = timestamp.getProductionTime(); if ((earliestProductionTime == null) || earliestProductionTime.after(productionTime)) { earliestProductionTime = productionTime; } } } return earliestProductionTime; }
@Override public int compare(TimestampWrapper t1, TimestampWrapper t2) { return t2.getProductionTime().compareTo(t1.getProductionTime()); }
private Set<TimestampWrapper> filterValidSignatureTimestamps(List<TimestampWrapper> allTimestamps) { Set<TimestampWrapper> result = new HashSet<TimestampWrapper>(); for (TimestampWrapper timestampWrapper : allTimestamps) { if (!TimestampType.SIGNATURE_TIMESTAMP.name().equals(timestampWrapper.getType())) { break; } boolean foundValidationTSP = false; for (XmlValidationProcessTimestamps timestampValidation : timestampValidations) { List<XmlConstraint> constraints = timestampValidation.getConstraint(); for (XmlConstraint tspValidation : constraints) { if (Utils.areStringsEqual(timestampWrapper.getId(), tspValidation.getId())) { foundValidationTSP = true; // PVA : if OK message imprint is validated in SVA of timestamp (depending of constraint.xml) if (XmlStatus.OK.equals(tspValidation.getStatus())) { result.add(timestampWrapper); break; } } } } if (!foundValidationTSP) { LOG.warn("Cannot find tsp validation info for tsp {}", timestampWrapper.getId()); } } return result; }
/** * This method returns the timestamp type of the given timestamp * * @param timestampId * the timestamp id * @return the related timestamp type */ public String getTimestampType(String timestampId) { TimestampWrapper timestamp = getTimestampByIdNullSafe(timestampId); return timestamp.getType(); }
public void extractPOE(TimestampWrapper timestamp, DiagnosticData diagnosticData) { Date productionTime = timestamp.getProductionTime(); List<XmlTimestampedObject> timestampedObjects = timestamp.getTimestampedObjects(); if (Utils.isCollectionNotEmpty(timestampedObjects)) { for (XmlTimestampedObject xmlTimestampedObject : timestampedObjects) { if (Utils.isStringNotEmpty(xmlTimestampedObject.getId())) { // SIGNATURES and TIMESTAMPS addPOE(xmlTimestampedObject.getId(), productionTime); } else if (TimestampedObjectType.CERTIFICATE == xmlTimestampedObject.getCategory()) { String certificateId = getCertificateIdByDigest(xmlTimestampedObject.getDigestAlgoAndValue(), diagnosticData); if (certificateId != null) { addPOE(certificateId, productionTime); } } else if (TimestampedObjectType.REVOCATION == xmlTimestampedObject.getCategory()) { String revocationId = getRevocationIdByDigest(xmlTimestampedObject.getDigestAlgoAndValue(), diagnosticData); if (revocationId != null) { addPOE(revocationId, productionTime); } } } } }
@Override public List<XmlDigestMatcher> getDigestMatchers() { return Collections.singletonList(getMessageImprint()); }
/** * Returns the identifier of the timestamp signing certificate. * * @param timestampId * timestamp id * @return signing certificate id */ public String getTimestampSigningCertificateId(final String timestampId) { TimestampWrapper timestamp = getTimestampByIdNullSafe(timestampId); return timestamp.getSigningCertificateId(); }
private Set<RevocationWrapper> getLinkedRevocationData() { Set<RevocationWrapper> result = new HashSet<RevocationWrapper>(); extractRevocationDataFromCertificateChain(result, currentSignature.getCertificateChainIds()); List<TimestampWrapper> timestampList = currentSignature.getTimestampList(); for (TimestampWrapper timestamp : timestampList) { extractRevocationDataFromCertificateChain(result, timestamp.getCertificateChainIds()); } return result; }
private Date getLatestTimestampProductionDate(List<TimestampWrapper> timestamps, TimestampType... selectedTimestampTypes) { Date latestProductionTime = null; for (TimestampWrapper timestamp : timestamps) { if (isInSelectedTypes(selectedTimestampTypes, timestamp.getType())) { Date productionTime = timestamp.getProductionTime(); if ((latestProductionTime == null) || latestProductionTime.before(productionTime)) { latestProductionTime = productionTime; } } } return latestProductionTime; }
private boolean isRevocationFreshnessCheckInvalid(CertificateWrapper certificateWrapper, TimestampWrapper timeStampWrapper) { return certificateWrapper.getRevocationData().stream().anyMatch( r -> { if (CRL_REVOCATION_SOURCE.equals(r.getSource())) { return !(timeStampWrapper.getProductionTime().after(r.getThisUpdate()) && timeStampWrapper.getProductionTime().before(r.getNextUpdate())); } return isInRangeMillis(r.getProductionDate(), timeStampWrapper.getProductionTime(), REVOCATION_FRESHNESS_DAY_DIFFERENCE); }); }
public List<String> getTimestampIdsList() { List<String> result = new ArrayList<String>(); List<TimestampWrapper> timestamps = getTimestampList(); if (Utils.isCollectionNotEmpty(timestamps)) { for (TimestampWrapper tsp : timestamps) { result.add(tsp.getId()); } } return result; }
public List<TimestampWrapper> getTimestampListByType(final TimestampType timestampType) { List<TimestampWrapper> result = new ArrayList<TimestampWrapper>(); List<TimestampWrapper> all = getTimestampList(); for (TimestampWrapper tsp : all) { if (timestampType.name().equals(tsp.getType())) { result.add(tsp); } } return result; }
public boolean isMessageImprintDataFound() { return getMessageImprint().isDataFound(); }
private Date getBestSignatureTime(String signatureFormat, String signatureId) { SignatureWrapper signature = dssReports.getDiagnosticData().getSignatureById(signatureId); if (signatureFormat.equals(LT_TM_XAdES_SIGNATURE_FORMAT)) { for (RevocationWrapper revocationData : dssReports.getDiagnosticData().getAllRevocationData()) { return revocationData.getProductionDate(); } } else { List<TimestampWrapper> timeStamps = signature.getTimestampList(); return timeStamps.isEmpty() ? null : timeStamps.get(0).getProductionTime(); } return null; }
private XmlConstraintsConclusion getTimestampValidation(TimestampWrapper newestTimestamp) { for (XmlValidationProcessTimestamps tspValidation : validationProcessTimestamps) { if (Utils.areStringsEqual(tspValidation.getId(), newestTimestamp.getId())) { return tspValidation; } } return null; }
@Override protected boolean process() { List<TimestampWrapper> timestampsBySignature = diagnosticData.getTimestampList(signature.getId()); for (TimestampWrapper timestampWrapper : timestampsBySignature) { if (TimestampType.CONTENT_TIMESTAMP.name().equals(timestampWrapper.getType()) || TimestampType.ALL_DATA_OBJECTS_TIMESTAMP.name().equals(timestampWrapper.getType()) || TimestampType.INDIVIDUAL_DATA_OBJECTS_TIMESTAMP.name().equals(timestampWrapper.getType())) { return true; } } return false; }