public abstract class Decryptor extends Object implements GenericRecord
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_PASSWORD |
static String |
DEFAULT_POIFS_ENTRY |
protected EncryptionInfo |
encryptionInfo |
| Modifier | Constructor and Description |
|---|---|
protected |
Decryptor() |
protected |
Decryptor(Decryptor other) |
| Modifier and Type | Method and Description |
|---|---|
abstract Decryptor |
copy() |
protected int |
getBlockSizeInBytes() |
abstract InputStream |
getDataStream(DirectoryNode dir)
Return a stream with decrypted data.
|
InputStream |
getDataStream(InputStream stream,
int size,
int initialPos)
Wraps a stream for decryption
|
InputStream |
getDataStream(POIFSFileSystem fs) |
EncryptionInfo |
getEncryptionInfo() |
Map<String,Supplier<?>> |
getGenericProperties() |
static Decryptor |
getInstance(EncryptionInfo info) |
byte[] |
getIntegrityHmacKey() |
byte[] |
getIntegrityHmacValue() |
protected int |
getKeySizeInBytes() |
abstract long |
getLength()
Returns the length of the encrypted data that can be safely read with
getDataStream(org.apache.poi.poifs.filesystem.DirectoryNode). |
SecretKey |
getSecretKey() |
byte[] |
getVerifier() |
Cipher |
initCipherForBlock(Cipher cipher,
int block)
Initializes a cipher object for a given block index for encryption
|
void |
setChunkSize(int chunkSize)
Sets the chunk size of the data stream.
|
void |
setEncryptionInfo(EncryptionInfo encryptionInfo) |
protected void |
setIntegrityHmacKey(byte[] integrityHmacKey) |
protected void |
setIntegrityHmacValue(byte[] integrityHmacValue) |
protected void |
setSecretKey(SecretKey secretKey) |
protected void |
setVerifier(byte[] verifier) |
abstract boolean |
verifyPassword(String password) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetGenericChildren, getGenericRecordTypepublic static final String DEFAULT_PASSWORD
public static final String DEFAULT_POIFS_ENTRY
protected EncryptionInfo encryptionInfo
protected Decryptor()
protected Decryptor(Decryptor other)
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 fromIOExceptionGeneralSecurityExceptionpublic InputStream getDataStream(InputStream stream, int size, int initialPos) throws IOException, GeneralSecurityException
As we are handling streams and don't know the total length beforehand, it's the callers duty to care for the length of the entries.
stream - the stream to be wrappedinitialPos - initial/current byte position within the streamIOExceptionGeneralSecurityExceptionpublic void setChunkSize(int chunkSize)
chunkSize - the chunk size, i.e. the block size with the same encryption keypublic Cipher initCipherForBlock(Cipher cipher, int block) throws GeneralSecurityException
cipher - may be null, otherwise the given instance is reset to the new block indexblock - the block index, e.g. the persist/slide id (hslf)GeneralSecurityException - if the cipher can't be initializedpublic abstract boolean verifyPassword(String password) throws GeneralSecurityException
GeneralSecurityExceptionpublic abstract long getLength()
getDataStream(org.apache.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.apache.poi.poifs.filesystem.DirectoryNode),
an attempt to call getLength() prior to getDataStream() will result in IllegalStateException.
IllegalStateException - if getDataStream(org.apache.poi.poifs.filesystem.DirectoryNode)
was not calledpublic static Decryptor getInstance(EncryptionInfo info)
public InputStream getDataStream(POIFSFileSystem fs) throws IOException, GeneralSecurityException
IOExceptionGeneralSecurityExceptionpublic byte[] getVerifier()
public SecretKey getSecretKey()
public byte[] getIntegrityHmacKey()
public byte[] getIntegrityHmacValue()
protected void setSecretKey(SecretKey secretKey)
protected void setVerifier(byte[] verifier)
protected void setIntegrityHmacKey(byte[] integrityHmacKey)
protected void setIntegrityHmacValue(byte[] integrityHmacValue)
protected int getBlockSizeInBytes()
protected int getKeySizeInBytes()
public EncryptionInfo getEncryptionInfo()
public void setEncryptionInfo(EncryptionInfo encryptionInfo)
public abstract Decryptor copy()
public Map<String,Supplier<?>> getGenericProperties()
getGenericProperties in interface GenericRecord