/** * This method returns the status of the associated TSP service. * * @param cert The certificate * @return */ public static String getStatus(final XmlDom cert) { final String status = cert.getValue("./TrustedServiceProvider/Status/text()"); return status; }
/** * This method returns the TSPName. * * @param trustedAnchor The trust anchor belonging to the service. * @return */ public static String getTSPName(final XmlDom trustedAnchor) { final String tspName = trustedAnchor.getValue("./TrustedServiceProvider/TSPName/text()"); return tspName; }
/** * This method returns the ServiceTypeIdentifier related to the certificate . * * @param cert The certificate. * @return */ public static String getServiceTypeIdentifier(final XmlDom cert) { final String serviceTypeIdentifier = cert.getValue("./TrustedServiceProvider/TSPServiceType/text()"); return serviceTypeIdentifier; }
/** * This method returns the ServiceName related to the certificate. * * @param cert The certificate * @return */ public static String getServiceName(final XmlDom cert) { final String serviceName = cert.getValue("./TrustedServiceProvider/TSPServiceName/text()"); return serviceName; }
private String getValue(final XmlDom xmlDom, final String xPath) { return xmlDom == null ? "" : xmlDom.getValue(xPath); }
public boolean getBoolValue(final String xPath, final Object... params) { String value = getValue(xPath, params); if (value.equals("true")) { return true; } else if (value.isEmpty() || value.equals("false")) { return false; } throw new DSSException("Expected values are: true, false and not '" + value + "'."); }
public int getIntValue(final String xPath, final Object... params) { String value = getValue(xPath, params); try { return Integer.parseInt(value); } catch (Exception e) { throw new DSSException(e); } }
public long getLongValue(final String xPath, final Object... params) { String value = getValue(xPath, params); try { value = value.trim(); return Long.parseLong(value); } catch (Exception e) { throw new DSSException(e); } }
public Date getTimeValueOrNull(final String xPath, final Object... params) { String value = getValue(xPath, params); if (value.isEmpty()) { return null; } return DSSUtils.parseDate(value); }
private void addSigningTime(final XmlDom diagnosticSignature, final XmlNode signatureNode) { signatureNode.addChild(NodeName.SIGNING_TIME, diagnosticSignature.getValue("./DateTime/text()")); }
public Date getTimeValue(final String xPath, final Object... params) { String value = getValue(xPath, params); return DSSUtils.parseDate(value); }
private void addSignatureFormat(final XmlDom diagnosticSignature, final XmlNode signatureNode) { signatureNode.setAttribute(NodeName.SIGNATURE_FORMAT, diagnosticSignature.getValue("./SignatureFormat/text()")); }
private Date getEarliestTimestampProductionTime(final List<XmlDom> timestamps, final TimestampType selectedTimestampType) { Date earliestProductionTime = null; for (final XmlDom timestamp : timestamps) { final String timestampType = timestamp.getValue("./@Type"); if (!selectedTimestampType.name().equals(timestampType)) { continue; } final Date productionTime = timestamp.getTimeValue("./ProductionTime/text()"); if (earliestProductionTime == null || earliestProductionTime.after(productionTime)) { earliestProductionTime = productionTime; } } return earliestProductionTime; }
private void addCounterSignature(XmlDom diagnosticSignature, XmlNode signatureNode, String type) { if (AttributeValue.COUNTERSIGNATURE.equals(type)) { signatureNode.setAttribute(AttributeName.TYPE, AttributeValue.COUNTERSIGNATURE); final String parentId = diagnosticSignature.getValue("./ParentId/text()"); signatureNode.setAttribute(AttributeName.PARENT_ID, parentId); } }
private Date getLatestTimestampProductionDate(final List<XmlDom> timestamps, final TimestampType selectedTimestampType) { Date latestProductionTime = null; for (final XmlDom timestamp : timestamps) { final String timestampType = timestamp.getValue("./@Type"); if (!selectedTimestampType.name().equals(timestampType)) { continue; } final Date productionTime = timestamp.getTimeValue("./ProductionTime/text()"); if (latestProductionTime == null || latestProductionTime.before(productionTime)) { latestProductionTime = productionTime; } } return latestProductionTime; }
protected boolean isTrustedProspectiveCertificateChain(final ProcessParameters params) { final String lastChainCertId = contextElement.getValue("./CertificateChain/ChainCertificate[last()]/@Id"); final XmlDom lastChainCertificate = params.getCertificate(lastChainCertId); boolean lastChainCertificateTrusted = false; if (lastChainCertificate != null) { lastChainCertificateTrusted = lastChainCertificate.getBoolValue("./Trusted/text()"); } return lastChainCertificateTrusted; }
private void checkEncryptionAlgoExpirationDate(final XmlDom token, final XmlNode infoContainerNode, final String message) { String encryptionAlgo = token.getValue(XP_ENCRYPTION_ALGO_USED_TO_SIGN_THIS_TOKEN); encryptionAlgo = RuleUtils.canonicalizeEncryptionAlgo(encryptionAlgo); final String encryptionKeyLength = token.getValue(XP_KEY_LENGTH_USED_TO_SIGN_THIS_TOKEN); final String algoWithKeyLength = encryptionAlgo + encryptionKeyLength; final Date algoExpirationDate = constraintData.getAlgorithmExpirationDate(algoWithKeyLength); if (algoExpirationDate != null && controlTime.after(algoExpirationDate)) { controlTime = algoExpirationDate; final String formatedCertAlgoExpirationDate = DSSUtils.formatDate(algoExpirationDate); infoContainerNode.addChild(INFO, message); infoContainerNode.addChild(INFO).setAttribute(ALGORITHM_EXPIRATION_DATE, formatedCertAlgoExpirationDate); } }
/** * This method adds the POE for a given signature and for the given list of certificates. * * @param signature * @param certificates * @param date */ public void initialisePOE(final XmlDom signature, final List<XmlDom> certificates, Date date) { String signatureId = signature.getValue("./@Id"); addSignaturePoe(signatureId, date); for (final XmlDom certificate : certificates) { Integer certificateId = certificate.getIntValue("./@Id"); addCertificatePoe(certificateId, date); } }
private void checkDigestAlgoExpirationDate(final XmlDom token, final XmlNode infoContainerNode, final String message) { String digestAlgo = token.getValue(XP_DIGEST_ALGO_USED_TO_SIGN_THIS_TOKEN); digestAlgo = RuleUtils.canonicalizeSignatureAlgo(digestAlgo); final Date algoExpirationDate = constraintData.getAlgorithmExpirationDate(digestAlgo); if (algoExpirationDate != null && controlTime.after(algoExpirationDate)) { controlTime = algoExpirationDate; final String formatedCertAlgoExpirationDate = DSSUtils.formatDate(algoExpirationDate); infoContainerNode.addChild(INFO, message); infoContainerNode.addChild(INFO).setAttribute(ALGORITHM_EXPIRATION_DATE, formatedCertAlgoExpirationDate); } } }
/** * @param timestamp * @return * @throws eu.europa.ec.markt.dss.exception.DSSException */ private boolean extractPOEs(final XmlDom timestamp) throws DSSException { final String digestAlgorithm = RuleUtils.canonicalizeDigestAlgo(timestamp.getValue("./SignedDataDigestAlgo/text()")); final Date algorithmExpirationDate = params.getCurrentValidationPolicy().getAlgorithmExpirationDate(digestAlgorithm); final Date timestampProductionTime = timestamp.getTimeValue("./ProductionTime/text()"); if (algorithmExpirationDate == null || timestampProductionTime.before(algorithmExpirationDate)) { poe.addPOE(timestamp, params.getCertPool()); return true; } return false; }