public abstract class Decryptor extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_PASSWORD |
Constructor and Description |
---|
Decryptor() |
Modifier and Type | Method and Description |
---|---|
protected static int |
getBlockSize(int algorithm) |
abstract InputStream |
getDataStream(DirectoryNode dir)
Return a stream with decrypted data.
|
InputStream |
getDataStream(NPOIFSFileSystem fs) |
InputStream |
getDataStream(POIFSFileSystem fs) |
static Decryptor |
getInstance(EncryptionInfo info) |
abstract long |
getLength()
Returns the length of the encytpted data that can be safely read with
getDataStream(org.zkoss.poi.poifs.filesystem.DirectoryNode) . |
protected byte[] |
hashPassword(EncryptionInfo info,
String password) |
abstract boolean |
verifyPassword(String password) |
public static final String DEFAULT_PASSWORD
public abstract InputStream getDataStream(DirectoryNode dir) throws IOException, GeneralSecurityException
Use getLength()
to get the size of that data that can be safely read from the stream.
Just reading to the end of the input stream is not sufficient because there are
normally padding bytes that must be discarded
dir
- the node to read fromIOException
GeneralSecurityException
public abstract boolean verifyPassword(String password) throws GeneralSecurityException
GeneralSecurityException
public abstract long getLength()
getDataStream(org.zkoss.poi.poifs.filesystem.DirectoryNode)
.
Just reading to the end of the input stream is not sufficient because there are
normally padding bytes that must be discarded
The length variable is initialized in getDataStream(org.zkoss.poi.poifs.filesystem.DirectoryNode)
,
an attempt to call getLength() prior to getDataStream() will result in IllegalStateException.
IllegalStateException
- if getDataStream(org.zkoss.poi.poifs.filesystem.DirectoryNode)
was not calledpublic static Decryptor getInstance(EncryptionInfo info)
public InputStream getDataStream(NPOIFSFileSystem fs) throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
public InputStream getDataStream(POIFSFileSystem fs) throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
protected static int getBlockSize(int algorithm)
protected byte[] hashPassword(EncryptionInfo info, String password) throws NoSuchAlgorithmException
NoSuchAlgorithmException
Copyright © 2020. All rights reserved.