From f28e20fa73069848f49581ebb1c805b1031caff4 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Fri, 25 Mar 2011 16:24:34 +0000 Subject: [PATCH] More NPOIFS Constructor updates git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1085451 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/poifs/crypt/Decryptor.java | 17 ++++++++++++++--- .../apache/poi/poifs/crypt/EncryptionInfo.java | 10 +++++++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/java/org/apache/poi/poifs/crypt/Decryptor.java b/src/java/org/apache/poi/poifs/crypt/Decryptor.java index 9e6c430803..e97f41b41d 100644 --- a/src/java/org/apache/poi/poifs/crypt/Decryptor.java +++ b/src/java/org/apache/poi/poifs/crypt/Decryptor.java @@ -29,7 +29,9 @@ import javax.crypto.CipherInputStream; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; +import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.DocumentInputStream; +import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.util.LittleEndian; @@ -148,10 +150,19 @@ public class Decryptor { } public InputStream getDataStream(POIFSFileSystem fs) throws IOException, GeneralSecurityException { - DocumentInputStream dis = fs.createDocumentInputStream("EncryptedPackage"); + return getDataStream(fs.getRoot()); + } + + public InputStream getDataStream(NPOIFSFileSystem fs) throws IOException, GeneralSecurityException { + return getDataStream(fs.getRoot()); + } + + @SuppressWarnings("unused") + public InputStream getDataStream(DirectoryNode dir) throws IOException, GeneralSecurityException { + DocumentInputStream dis = dir.createDocumentInputStream("EncryptedPackage"); - long size = dis.readLong(); + long size = dis.readLong(); - return new CipherInputStream(dis, getCipher()); + return new CipherInputStream(dis, getCipher()); } } diff --git a/src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java b/src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java index 713e9d0543..68ead77428 100644 --- a/src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java +++ b/src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java @@ -16,7 +16,9 @@ ==================================================================== */ package org.apache.poi.poifs.crypt; +import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.DocumentInputStream; +import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import java.io.IOException; @@ -33,7 +35,13 @@ public class EncryptionInfo { private final EncryptionVerifier verifier; public EncryptionInfo(POIFSFileSystem fs) throws IOException { - DocumentInputStream dis = fs.createDocumentInputStream("EncryptionInfo"); + this(fs.getRoot()); + } + public EncryptionInfo(NPOIFSFileSystem fs) throws IOException { + this(fs.getRoot()); + } + public EncryptionInfo(DirectoryNode dir) throws IOException { + DocumentInputStream dis = dir.createDocumentInputStream("EncryptionInfo"); versionMajor = dis.readShort(); versionMinor = dis.readShort(); -- 2.39.5