public abstract class Decryptor extends java.lang.Object implements GenericRecord
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_PASSWORD |
static java.lang.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 java.io.InputStream |
getDataStream(DirectoryNode dir)
Return a stream with decrypted data.
(返回带有解密数据的流。)
|
java.io.InputStream |
getDataStream(java.io.InputStream stream, int size, int initialPos)
Wraps a stream for decryption
(包装用于解密的流)
|
java.io.InputStream |
getDataStream(POIFSFileSystem fs) |
EncryptionInfo |
getEncryptionInfo() |
java.util.Map<java.lang.String,java.util.function.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) .
(返回可以使用 getDataStream(org.apache.poi.poifs.filesystem.DirectoryNode) 安全读取的加密数据的长度。)
|
javax.crypto.SecretKey |
getSecretKey() |
byte[] |
getVerifier() |
javax.crypto.Cipher |
initCipherForBlock(javax.crypto.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(javax.crypto.SecretKey secretKey) |
protected void |
setVerifier(byte[] verifier) |
abstract boolean |
verifyPassword(java.lang.String password) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getGenericChildren, getGenericRecordType
public static final java.lang.String DEFAULT_PASSWORD
public static final java.lang.String DEFAULT_POIFS_ENTRY
protected EncryptionInfo encryptionInfo
protected Decryptor()
protected Decryptor(Decryptor other)
public abstract java.io.InputStream getDataStream(DirectoryNode dir) throws java.io.IOException, java.security.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 from
(dir - 要读取的节点)
java.io.IOException
(java.io.IOException)
java.security.GeneralSecurityException
(java.security.GeneralSecurityException)
public java.io.InputStream getDataStream(java.io.InputStream stream, int size, int initialPos) throws java.io.IOException, java.security.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 wrapped
(stream - 要包装的流)
initialPos
- initial/current byte position within the stream
(initialPos - 流中的初始/当前字节位置)
java.io.IOException
(java.io.IOException)
java.security.GeneralSecurityException
(java.security.GeneralSecurityException)
public void setChunkSize(int chunkSize)
chunkSize
- the chunk size, i.e. the block size with the same encryption key
(chunkSize - 块大小,即具有相同加密密钥的块大小)
public javax.crypto.Cipher initCipherForBlock(javax.crypto.Cipher cipher, int block) throws java.security.GeneralSecurityException
cipher
- may be null, otherwise the given instance is reset to the new block index
(cipher - 可以为空,否则给定的实例被重置为新的块索引)
block
- the block index, e.g. the persist/slide id (hslf)
(block - 块索引,例如持久化/幻灯片 id (hslf))
java.security.GeneralSecurityException
- if the cipher can't be initialized
(java.security.GeneralSecurityException - 如果密码无法初始化)
public abstract boolean verifyPassword(java.lang.String password) throws java.security.GeneralSecurityException
java.security.GeneralSecurityException
(java.security.GeneralSecurityException)
public 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.
java.lang.IllegalStateException
- if
getDataStream(org.apache.poi.poifs.filesystem.DirectoryNode)
was not called
(java.lang.IllegalStateException - 如果未调用 getDataStream(org.apache.poi.poifs.filesystem.DirectoryNode))
public static Decryptor getInstance(EncryptionInfo info)
public java.io.InputStream getDataStream(POIFSFileSystem fs) throws java.io.IOException, java.security.GeneralSecurityException
java.io.IOException
(java.io.IOException)
java.security.GeneralSecurityException
(java.security.GeneralSecurityException)
public byte[] getVerifier()
public javax.crypto.SecretKey getSecretKey()
public byte[] getIntegrityHmacKey()
public byte[] getIntegrityHmacValue()
protected void setSecretKey(javax.crypto.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 java.util.Map<java.lang.String,java.util.function.Supplier<?>> getGenericProperties()
getGenericProperties
in interface
GenericRecord
(接口 GenericRecord 中的 getGenericProperties)
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.