Codota Logo
DSSDocument.openStream
Code IndexAdd Codota to your IDE (free)

How to use
openStream
method
in
eu.europa.esig.dss.DSSDocument

Best Java code snippets using eu.europa.esig.dss.DSSDocument.openStream (Showing top 13 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
LocalDateTime l =
  • Codota Iconnew LocalDateTime()
  • Codota IconLocalDateTime.now()
  • Codota IconDateTimeFormatter formatter;String text;formatter.parseLocalDateTime(text)
  • Smart code suggestions by Codota
}
origin: open-eid/digidoc4j

/**
 * Gives data file as stream
 *
 * @return data file stream
 */
public InputStream getStream() {
 logger.debug("");
 return document.openStream();
}
origin: open-eid/digidoc4j

private byte[] getDocumentBytes(DSSDocument document) {
 try {
  return IOUtils.toByteArray(document.openStream());
 } catch (IOException e) {
  logger.error("Error getting document content: " + e.getMessage());
  throw new TechnicalException("Error getting document content: " + e.getMessage(), e);
 }
}
origin: esig/dss

/**
 * This method returns the {@link org.w3c.dom.Document} created based on the {@link eu.europa.esig.dss.DSSDocument}.
 *
 * @param dssDocument
 *            The DSS representation of the document from which the dssDocument is created.
 * @return a new {@link org.w3c.dom.Document} from {@link eu.europa.esig.dss.DSSDocument}
 */
public static Document buildDOM(final DSSDocument dssDocument) {
  return buildDOM(dssDocument.openStream());
}
origin: open-eid/digidoc4j

@Override
public byte[] getAdESSignature() {
 logger.debug("Getting full XAdES signature byte array");
 try {
  return IOUtils.toByteArray(signatureDocument.openStream());
 } catch (IOException e) {
  throw new TechnicalException("Error parsing xades signature: " + e.getMessage(), e);
 }
}
origin: open-eid/digidoc4j

/**
 * Gives file bytes
 *
 * @return data as bytes
 */
public byte[] getBytes() {
 logger.debug("");
 try {
  return IOUtils.toByteArray(document.openStream());
 } catch (IOException e) {
  throw new TechnicalException("Error reading document bytes: " + e.getMessage(), e);
 }
}
origin: esig/dss

/**
 * Reads the first byte from the DSSDocument
 * 
 * @param dssDocument
 *            the document
 * @return the first byte
 */
public static byte readFirstByte(final DSSDocument dssDocument) {
  byte[] result = new byte[1];
  try (InputStream inputStream = dssDocument.openStream()) {
    inputStream.read(result, 0, 1);
  } catch (IOException e) {
    throw new DSSException(e);
  }
  return result[0];
}
origin: esig/dss

/**
 * Reads maximum {@code headerLength} bytes from {@code dssDocument} to the given {@code byte} array.
 *
 * @param dssDocument
 *            {@code DSSDocument} to read
 * @param headerLength
 *            {@code int}: maximum number of bytes to read
 * @param destinationByteArray
 *            destination {@code byte} array
 * @return the number of read bytes
 */
public static int readToArray(final DSSDocument dssDocument, final int headerLength, final byte[] destinationByteArray) {
  try (InputStream inputStream = dssDocument.openStream()) {
    return inputStream.read(destinationByteArray, 0, headerLength);
  } catch (IOException e) {
    throw new DSSException(e);
  }
}
origin: esig/dss

public static byte[] digest(DigestAlgorithm digestAlgorithm, DSSDocument document) {
  try (InputStream is = document.openStream()) {
    return digest(digestAlgorithm, is);
  } catch (IOException e) {
    throw new DSSException(e);
  }
}
origin: esig/dss

/**
 * This method create a new document from a sub-part of another document
 * 
 * @param origin
 *            the original document
 * @param start
 *            the start position to retrieve
 * @param end
 *            the end position to retrieve
 * @return a new DSSDocument
 */
public static DSSDocument splitDocument(DSSDocument origin, int start, int end) {
  try (InputStream is = origin.openStream();
      BufferedInputStream bis = new BufferedInputStream(is);
      ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
    int i = 0;
    int r;
    while ((r = bis.read()) != -1) {
      if (i >= start && i <= end) {
        baos.write(r);
      }
      i++;
    }
    baos.flush();
    return new InMemoryDocument(baos.toByteArray());
  } catch (Exception e) {
    throw new DSSException("Unable to split document", e);
  }
}
origin: esig/dss

/**
 * Get the contents of an {@code DSSDocument} as a {@code byte[]}.
 *
 * @param document
 *            the document to read
 * @return the content as byte array
 */
public static byte[] toByteArray(final DSSDocument document) {
  try (InputStream is = document.openStream()) {
    return toByteArray(is);
  } catch (IOException e) {
    throw new DSSException(e);
  }
}
origin: open-eid/digidoc4j

private static boolean parseAsicContainer(BufferedInputStream stream, MimeType mtype) throws IOException {
 stream.mark(stream.available() + 1);
 ZipInputStream zipInputStream = new ZipInputStream(stream);
 try {
  ZipEntry entry;
  while ((entry = zipInputStream.getNextEntry()) != null) {
   if (StringUtils.equalsIgnoreCase("mimetype", entry.getName())) {
    InputStream zipFileInputStream = zipInputStream;
    BOMInputStream bomInputStream = new BOMInputStream(zipFileInputStream);
    DSSDocument document = new InMemoryDocument(bomInputStream);
    String mimeType = StringUtils.trim(IOUtils.toString(IOUtils.toByteArray(document.openStream()), "UTF-8"));
    if (StringUtils.equalsIgnoreCase(mimeType, mtype.getMimeTypeString())) {
     return true;
    }
   }
  }
 } catch (IOException e) {
  logger.error("Error reading asic container stream: " + e.getMessage());
  throw new TechnicalException("Error reading asic container stream: ", e);
 } finally {
  stream.reset();
 }
 return false;
}
origin: open-eid/digidoc4j

/**
 * @param asicEntries list of ASIC entries
 */
public void writeExistingEntries(Collection<AsicEntry> asicEntries) {
 logger.debug("Writing existing zip container entries");
 for (AsicEntry asicEntry : asicEntries) {
  DSSDocument content = asicEntry.getContent();
  ZipEntry zipEntry = asicEntry.getZipEntry();
  if (!StringUtils.equalsIgnoreCase(ZIP_ENTRY_MIMETYPE, zipEntry.getName())) {
   zipOutputStream.setLevel(ZipEntry.DEFLATED);
  }
  new StreamEntryCallback(zipEntry, content.openStream(), false).write();
 }
}
origin: open-eid/SiVa

DSSDocument signedDocument = service.signDocument(documentToBeSigned, parameters, signatureValue);
return IOUtils.toByteArray(signedDocument.openStream());
eu.europa.esig.dssDSSDocumentopenStream

Popular methods of DSSDocument

  • getName
  • setMimeType
  • getAbsolutePath
  • getMimeType
  • save

Popular in Java

  • Parsing JSON documents to java classes using gson
  • addToBackStack (FragmentTransaction)
  • getExternalFilesDir (Context)
  • onRequestPermissionsResult (Fragment)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.This exception may include information for locating the er
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now