/** * Creates dss document that retains the data in memory * * @param inputStream input stream representing the document * @throws DSSException */ public InMemoryDocument(final InputStream inputStream) throws DSSException { this(DSSUtils.toByteArray(inputStream), null, null); }
/** * Creates dss document that retains the data in memory * * @param inputStream input stream representing the document * @param name the file name if the data originates from a file * @param mimeType the mime type of the file if the data originates from a file * @throws IOException */ public InMemoryDocument(final InputStream inputStream, final String name, final MimeType mimeType) throws DSSException { this(DSSUtils.toByteArray(inputStream), name, mimeType); }
/** * Creates dss document that retains the data in memory * * @param inputStream input stream representing the document * @param name the file name if the data originates from a file * @throws IOException */ public InMemoryDocument(final InputStream inputStream, final String name) throws DSSException { this(DSSUtils.toByteArray(inputStream), name); }
/** * A specific constructor to allow non-file based usage of p12 data * * @param password * @param inputStream */ public Pkcs12SignatureToken(String password, InputStream inputStream) { this.password = password.toCharArray(); if (inputStream == null) { throw new RuntimeException("PKCS12 data not provided"); } this.pkcs12Data = DSSUtils.toByteArray(inputStream); }
/** * This method returns the content of a file referenced by its URL. All exceptions are caught. * * @param url {@code URL} representing a file * @return array of {@code byte}s or null */ public static byte[] toByteArrayQuietly(final URL url) { if (url == null) { return null; } try { final InputStream inputStream = url.openStream(); return DSSUtils.toByteArray(inputStream); } catch (IOException e) { LOG.warn(e.toString(), e); } return null; }
protected byte[] getContent(final HttpEntity responseEntity) throws DSSException { try { final InputStream content = responseEntity.getContent(); final byte[] bytes = DSSUtils.toByteArray(content); return bytes; } catch (IOException e) { throw new DSSException(e); } }
@Override public byte[] getBytes() throws DSSException { final InputStream inputStream = openStream(); final byte[] bytes = DSSUtils.toByteArray(inputStream); return bytes; }
public NonceContainer() { final long currentTimeNonce = System.currentTimeMillis(); nonce = new DEROctetString(DSSUtils.toByteArray(currentTimeNonce)); } }
/** * This method digests the given {@code InputStream} with SHA1 algorithm and encode returned array of bytes as hex string. * * @param inputStream * @return */ public static String getSHA1Digest(final InputStream inputStream) { final byte[] bytes = DSSUtils.toByteArray(inputStream); final byte[] digest = sha1Digester.digest(bytes); return encodeHexString(digest); }
private byte[] getContentUsingNotNetworkProtocol(String url) { final String resourcePath = resourceLoader.getAbsoluteResourceFolder(url.trim()); final File fileResource = new File(resourcePath); final byte[] bytes = DSSUtils.toByteArray(fileResource); return bytes; }
private byte[] getCachedFileContent(final String cacheFileName, final boolean refresh) { final File file = getCacheFile(cacheFileName); final boolean fileExists = file.exists(); if (fileExists && !refresh) { LOG.debug("Cached file was used"); final byte[] bytes = DSSUtils.toByteArray(file); return bytes; } else { if (!fileExists) { LOG.debug("There is no cached file!"); } else { LOG.debug("The refresh is forced!"); } } return null; }
private byte[] toBytes(COSBase val) throws IOException { COSStream cosStream = null; if(val instanceof COSObject) { COSObject o = (COSObject) val; final COSBase object = o.getObject(); if(object instanceof COSStream) { cosStream = (COSStream) object; } } if(cosStream == null) { throw new RuntimeException("Cannot find value for " + val + " of class " + val.getClass()); } final byte[] bytes = DSSUtils.toByteArray(cosStream.getUnfilteredStream()); return bytes; }
/** * Allows to load the file for a given file name from the cache folder. * * @return the content of the file or {@code null} if the file does not exist */ public byte[] loadFileFromCache(final String urlString) { final String fileName = ResourceLoader.getNormalizedFileName(urlString); final File file = getCacheFile(fileName); if (file.exists()) { final byte[] bytes = DSSUtils.toByteArray(file); return bytes; } return null; }
} else { policyBytes = DSSUtils.toByteArray(policyDocument);
final InputStream inputStream = DSSUtils.toInputStream(policyFile); wsPolicyDocument = new WsDocument(); wsPolicyDocument.setBytes(DSSUtils.toByteArray(inputStream));
protected CMSSignedData regenerateCMSSignedData(CMSSignedData cmsSignedData, SignatureParameters parameters, Store certificatesStore, Store attributeCertificatesStore, Store crlsStore, Store otherRevocationInfoFormatStoreBasic, Store otherRevocationInfoFormatStoreOcsp) { try { final CMSSignedDataGenerator cmsSignedDataGenerator = new CMSSignedDataGenerator(); cmsSignedDataGenerator.addSigners(cmsSignedData.getSignerInfos()); cmsSignedDataGenerator.addAttributeCertificates(attributeCertificatesStore); cmsSignedDataGenerator.addCertificates(certificatesStore); cmsSignedDataGenerator.addCRLs(crlsStore); cmsSignedDataGenerator.addOtherRevocationInfo(id_pkix_ocsp_basic, otherRevocationInfoFormatStoreBasic); cmsSignedDataGenerator.addOtherRevocationInfo(id_ri_ocsp_response, otherRevocationInfoFormatStoreOcsp); final boolean encapsulate = cmsSignedData.getSignedContent() != null; if (!encapsulate) { final InputStream inputStream = parameters.getDetachedContent().openStream(); final CMSProcessableByteArray content = new CMSProcessableByteArray(DSSUtils.toByteArray(inputStream)); cmsSignedData = cmsSignedDataGenerator.generate(content, encapsulate); } else { cmsSignedData = cmsSignedDataGenerator.generate(cmsSignedData.getSignedContent(), encapsulate); } return cmsSignedData; } catch (CMSException e) { throw new DSSException(e); } }