no.difi.asic.AsicInputStream Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-asic Show documentation
Show all versions of commons-asic Show documentation
Generic implementation of ASiC-E archives in accordance with ETSI 102 918 v1.3.1.
package no.difi.asic;
import com.google.common.io.ByteStreams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
class AsicInputStream extends ZipInputStream {
public static final Logger logger = LoggerFactory.getLogger(AsicInputStream.class);
public AsicInputStream(InputStream in) {
super(in);
}
@Override
public ZipEntry getNextEntry() throws IOException {
ZipEntry zipEntry = super.getNextEntry();
if (zipEntry != null && zipEntry.getName().equals("mimetype")) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ByteStreams.copy(this, baos);
logger.debug("Content of mimetype: {}", baos.toString());
if (!AsicUtils.MIMETYPE_ASICE.equals(baos.toString()))
throw new IllegalStateException("Content is not ASiC-E container.");
// Fetch next
zipEntry = super.getNextEntry();
}
return zipEntry;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy