diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2016-08-03 23:54:01 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2016-08-03 23:54:01 +0000 |
commit | e84c6152dde07a48b2982f9e9ce016529548e11d (patch) | |
tree | 7892c3e19a24f2bb414300b2a821db8bfd89b157 /src/java/org/apache/poi/POIDocument.java | |
parent | 05aad13deda70afd7d8d6cc93fe9a8c1fba29457 (diff) | |
download | poi-e84c6152dde07a48b2982f9e9ce016529548e11d.tar.gz poi-e84c6152dde07a48b2982f9e9ce016529548e11d.zip |
Preparations for hssf_cryptoapi:
- Add cloneable
- Change existing hslf cryptoapi to streaming
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/hssf_cryptoapi@1755127 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/POIDocument.java')
-rw-r--r-- | src/java/org/apache/poi/POIDocument.java | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/java/org/apache/poi/POIDocument.java b/src/java/org/apache/poi/POIDocument.java index 87c6a14f66..d742c5572a 100644 --- a/src/java/org/apache/poi/POIDocument.java +++ b/src/java/org/apache/poi/POIDocument.java @@ -32,6 +32,7 @@ import org.apache.poi.hpsf.PropertySet; import org.apache.poi.hpsf.PropertySetFactory; import org.apache.poi.hpsf.SummaryInformation; import org.apache.poi.poifs.crypt.EncryptionInfo; +import org.apache.poi.poifs.crypt.cryptoapi.CryptoAPIDecryptor; import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.DocumentInputStream; import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; @@ -59,6 +60,8 @@ public abstract class POIDocument implements Closeable { /* Have the property streams been read yet? (Only done on-demand) */ private boolean initialized = false; + + private static final String[] encryptedStreamNames = { "EncryptedSummary" }; /** * Constructs a POIDocument with the given directory node. @@ -195,13 +198,18 @@ public abstract class POIDocument implements Closeable { try { if (encryptionInfo != null) { step = "getting encrypted"; - InputStream is = encryptionInfo.getDecryptor().getDataStream(directory); - try { - encPoifs = new NPOIFSFileSystem(is); - dirNode = encPoifs.getRoot(); - } finally { - is.close(); + String encryptedStream = null; + for (String s : encryptedStreamNames) { + if (dirNode.hasEntry(s)) { + encryptedStream = s; + } + } + if (encryptedStream == null) { + throw new EncryptedDocumentException("can't find matching encrypted property stream"); } + CryptoAPIDecryptor dec = (CryptoAPIDecryptor)encryptionInfo.getDecryptor(); + encPoifs = dec.getSummaryEntries(dirNode, encryptedStream); + dirNode = encPoifs.getRoot(); } //directory can be null when creating new documents |