All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.digidoc4j.ddoc.factory.SignatureInputStream Maven / Gradle / Ivy

Go to download

DDoc4J is Java Library for validating DDOC documents. It's not recommended to use it directly but rather through DigiDoc4J's API.

The newest version!
package org.digidoc4j.ddoc.factory;

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * Special input stream used to filter out BOM
 * (byte-order-marks) from the beginning of xml signature
 * or signed doc xml file.
 * @author Veiko Sinivee
 */
public class SignatureInputStream
        extends FilterInputStream
{
    boolean bXml;

    /**
     * Constructor for SignatureInputStream
     * @param in real input stream to be filtered
     */
    public SignatureInputStream(InputStream in)
    {
        super(in);
        bXml = false;
    }

    public int read() throws IOException
    {
        int b = super.read();
        if(!bXml) {
            while(b != '<' && b != -1)
                b = super.read();
            bXml = true;
        }
        return b;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy