@Override protected MessageTag getErrorMessageTag() { switch (validationTime) { case BEST_SIGNATURE_TIME: return MessageTag.QUAL_FOR_SIGN_AT_ST_ANS; case CERTIFICATE_ISSUANCE_TIME: return MessageTag.QUAL_FOR_SIGN_AT_CC_ANS; case VALIDATION_TIME: return MessageTag.QUAL_FOR_SIGN_AT_VT_ANS; default: throw new DSSException("Unsupported time " + validationTime); } }
protected MimeType getMimeType(String mimeType) { try { MimeType mimeTypeCode = MimeType.fromMimeTypeString(mimeType); logger.debug("Mime type: ", mimeTypeCode); return mimeTypeCode; } catch (DSSException e) { logger.error(e.getMessage()); throw new InvalidDataFileException(e); } }
public SignedDocumentValidator openXadesValidator(DSSDocument signature) { try { logger.debug("Opening signature validator"); SignedDocumentValidator validator = new XMLDocumentValidator(signature); logger.debug("Finished opening signature validator"); validator.setDetachedContents(detachedContents); validator.setCertificateVerifier(certificateVerifier); SignaturePolicyProvider signaturePolicyProvider = Helper.getBdocSignaturePolicyProvider(signature); validator.setSignaturePolicyProvider(signaturePolicyProvider); return validator; } catch (DSSException e) { logger.error("Failed to parse xades signature: " + e.getMessage()); throw new InvalidSignatureException(); } }
@Override protected MessageTag getErrorMessageTag() { switch (validationTime) { case BEST_SIGNATURE_TIME: return MessageTag.QUAL_QSCD_AT_ST_ANS; case CERTIFICATE_ISSUANCE_TIME: return MessageTag.QUAL_QSCD_AT_CC_ANS; case VALIDATION_TIME: return MessageTag.QUAL_QSCD_AT_VT_ANS; default: throw new DSSException("Unsupported time " + validationTime); } }
@Test public void testDontSkipCertificatesWhenMultipleAreFoundInP7c() throws IOException { try { DSSUtils.loadCertificate(new FileInputStream("src/test/resources/certchain.p7c")); fail("Should not load single certificate (first?)"); } catch (DSSException dssEx) { assertEquals("Could not parse certificate", dssEx.getMessage()); } }
@Override public InputStream openStream() { throw new DSSException("Digest document"); }
@Override public void save(String filePath) throws IOException { throw new DSSException("Digest document"); }
@Override public void setContentType(String contentType) { throw new DSSException("Not implemented"); }
@Override protected MessageTag getMessageTag() { switch (validationTime) { case BEST_SIGNATURE_TIME: return MessageTag.QUAL_QSCD_AT_ST; case CERTIFICATE_ISSUANCE_TIME: return MessageTag.QUAL_QSCD_AT_CC; case VALIDATION_TIME: return MessageTag.QUAL_QSCD_AT_VT; default: throw new DSSException("Unsupported time " + validationTime); } }
@Override protected MessageTag getMessageTag() { switch (validationTime) { case BEST_SIGNATURE_TIME: return MessageTag.QUAL_FOR_SIGN_AT_ST; case CERTIFICATE_ISSUANCE_TIME: return MessageTag.QUAL_FOR_SIGN_AT_CC; case VALIDATION_TIME: return MessageTag.QUAL_FOR_SIGN_AT_VT; default: throw new DSSException("Unsupported time " + validationTime); } }
@Override protected MessageTag getMessageTag() { switch (validationTime) { case BEST_SIGNATURE_TIME: return MessageTag.QUAL_QC_AT_ST; case CERTIFICATE_ISSUANCE_TIME: return MessageTag.QUAL_QC_AT_CC; case VALIDATION_TIME: return MessageTag.QUAL_QC_AT_VT; default: throw new DSSException("Unsupported time " + validationTime); } }
@Override protected MessageTag getErrorMessageTag() { switch (validationTime) { case BEST_SIGNATURE_TIME: return MessageTag.QUAL_QC_AT_ST_ANS; case CERTIFICATE_ISSUANCE_TIME: return MessageTag.QUAL_QC_AT_CC_ANS; case VALIDATION_TIME: return MessageTag.QUAL_QC_AT_VT_ANS; default: throw new DSSException("Unsupported time " + validationTime); } }
private static int getInt(Indication indication) { switch (indication) { case FAILED: case TOTAL_FAILED: return 0; case PASSED: case TOTAL_PASSED: return 1; case INDETERMINATE: return 2; default: throw new DSSException("Unsupported indication " + indication); } }
@Override public String getDigest(final DigestAlgorithm digestAlgorithm) { String base64EncodeDigest = base64EncodeDigestMap.get(digestAlgorithm); if (base64EncodeDigest == null) { throw new DSSException("Unknown digest value for algorithm : " + digestAlgorithm); } return base64EncodeDigest; }
private URL getURL(String urlString) { try { return new URL(urlString); } catch (MalformedURLException e) { throw new DSSException("Unable to create URL instance", e); } }
/** * Creates the new empty Document. * * @return a new empty Document */ public static Document buildDOM() { try { return dbFactory.newDocumentBuilder().newDocument(); } catch (ParserConfigurationException e) { throw new DSSException(e); } }
private Provider getProviderJavaGreaterOrEquals9(String configString) { try { Provider provider = Security.getProvider(SUN_PKCS11_PROVIDERNAME); Method configureMethod = provider.getClass().getMethod("configure", String.class); // "--" is permitted in the constructor sun.security.pkcs11.Config return (Provider) configureMethod.invoke(provider, "--" + configString); } catch (Exception e) { throw new DSSException("Unable to instantiate PKCS11 (JDK >= 9)", e); } }
private File getCacheFile(final String fileName) { final String trimmedFileName = fileName.trim(); if ((toIgnored != null) && toIgnored.contains(trimmedFileName)) { throw new DSSException("Part of urls to ignore."); } LOG.debug("Cached file: {}/{}", fileCacheDirectory, trimmedFileName); final File file = new File(fileCacheDirectory, trimmedFileName); return file; }
private Provider getProviderJavaLowerThan9(String configString) { try (ByteArrayInputStream bais = new ByteArrayInputStream(configString.getBytes())) { Class<?> sunPkcs11ProviderClass = Class.forName(SUN_PKCS11_CLASSNAME); Constructor<?> constructor = sunPkcs11ProviderClass.getConstructor(InputStream.class); return (Provider) constructor.newInstance(bais); } catch (Exception e) { throw new DSSException("Unable to instantiate PKCS11 (JDK < 9) ", e); } }
/** * This method returns the {@link org.w3c.dom.Document} created based on the XML * inputStream. * * @param inputStream * The inputStream stream representing the dssDocument to be * created. * @return a new {@link org.w3c.dom.Document} from {@link java.io.InputStream} @ */ public static Document buildDOM(final InputStream inputStream) { try (InputStream is = inputStream) { return dbFactory.newDocumentBuilder().parse(is); } catch (Exception e) { throw new DSSException("Unable to parse content (XML expected)", e); } }