/** Here we determine the type of the signature. */ private void addSignatureProfile(SignatureWrapper signature, XmlSignature xmlSignature) { SignatureType signatureType = SignatureType.NA; String certificateId = signature.getSigningCertificateId(); if (certificateId != null) { signatureType = getSignatureType(certificateId); } xmlSignature.setSignatureLevel(signatureType.name()); }
private void addSignatureScope( final SignatureWrapper diagnosticSignature, final XmlSignature xmlSignature) { XmlSignatureScopes signatureScopes = diagnosticSignature.getSignatureScopes(); if (signatureScopes != null && CollectionUtils.isNotEmpty(signatureScopes.getSignatureScope())) { for (XmlSignatureScopeType scopeType : signatureScopes.getSignatureScope()) { XmlSignatureScope scope = new XmlSignatureScope(); scope.setName(scopeType.getName()); scope.setScope(scopeType.getScope()); scope.setValue(scopeType.getValue()); xmlSignature.getSignatureScope().add(scope); } } }
private void addSignedBy( final SignatureWrapper diagnosticSignature, final XmlSignature xmlSignature) { String unknown = "?"; String signedBy = unknown; String certificateId = diagnosticSignature.getSigningCertificateId(); if (StringUtils.isNotEmpty(certificateId)) { signedBy = diagnosticData.getUsedCertificateById(certificateId).getCommonName(); if (signedBy.equals(StringUtils.EMPTY)) { signedBy = diagnosticData.getUsedCertificateById(certificateId).getGivenName(); if (signedBy.equals(StringUtils.EMPTY)) { signedBy = diagnosticData.getUsedCertificateById(certificateId).getSurname(); if (signedBy.equals(StringUtils.EMPTY)) { signedBy = diagnosticData.getUsedCertificateById(certificateId).getPseudo(); if (signedBy.equals(StringUtils.EMPTY)) { signedBy = unknown; } } } } } xmlSignature.setSignedBy(signedBy); }
private void addSignatureFormat( final SignatureWrapper diagnosticSignature, final XmlSignature xmlSignature) { xmlSignature.setSignatureFormat(diagnosticSignature.getSignatureFormat()); }
private void addSigningTime( final SignatureWrapper diagnosticSignature, final XmlSignature xmlSignature) { xmlSignature.setSigningTime(diagnosticSignature.getDateTime()); }
private void addCounterSignature(SignatureWrapper signature, XmlSignature xmlSignature) { if (AttributeValue.COUNTERSIGNATURE.equals(signature.getType())) { xmlSignature.setType(AttributeValue.COUNTERSIGNATURE); xmlSignature.setParentId(signature.getParentId()); } }
/** * @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); }