Package org.apache.poi.poifs.crypt
Class EncryptionInfo
java.lang.Object
org.apache.poi.poifs.crypt.EncryptionInfo
- All Implemented Interfaces:
Cloneable
This class may require
poi-ooxml to be on the classpath to load
some EncryptionModes.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BitFieldA value that MUST be 1 if the protected content is an ECMA-376 document ECMA-376.static final BitFieldA flag that specifies whether CryptoAPI RC4 or ECMA-376 encryption ECMA-376 is used.static final BitFieldA value that MUST be 0 if document properties are encrypted.static final BitFieldA value that MUST be 1 if extensible encryption is used. -
Constructor Summary
ConstructorsConstructorDescriptionEncryptionInfo(EncryptionMode encryptionMode) Prepares for encryption, using the given Encryption Mode, and all other parameters as default.EncryptionInfo(EncryptionMode encryptionMode, CipherAlgorithm cipherAlgorithm, HashAlgorithm hashAlgorithm, int keyBits, int blockSize, ChainingMode chainingMode) Constructs an EncryptionInfo from scratchOpens for decryptionOpens for decryptionEncryptionInfo(LittleEndianInput dis, EncryptionMode preferredEncryptionMode) -
Method Summary
Modifier and TypeMethodDescriptionclone()protected static EncryptionInfoBuildergetBuilder(EncryptionMode encryptionMode) This method loads the builder class with reflection, which may generate aClassNotFoundExceptionif the class is not on the classpath.intintintbooleanvoidsetDecryptor(Decryptor decryptor) voidsetEncryptor(Encryptor encryptor) voidsetHeader(EncryptionHeader header) voidsetVerifier(EncryptionVerifier verifier)
-
Field Details
-
flagCryptoAPI
A flag that specifies whether CryptoAPI RC4 or ECMA-376 encryption ECMA-376 is used. It MUST be 1 unless flagExternal is 1. If flagExternal is 1, it MUST be 0. -
flagDocProps
A value that MUST be 0 if document properties are encrypted. The encryption of document properties is specified in section 2.3.5.4. -
flagExternal
A value that MUST be 1 if extensible encryption is used. If this value is 1, the value of every other field in this structure MUST be 0. -
flagAES
A value that MUST be 1 if the protected content is an ECMA-376 document ECMA-376. If the fAES bit is 1, the fCryptoAPI bit MUST also be 1.
-
-
Constructor Details
-
EncryptionInfo
Opens for decryption- Throws:
IOException
-
EncryptionInfo
Opens for decryption- Throws:
IOException
-
EncryptionInfo
public EncryptionInfo(LittleEndianInput dis, EncryptionMode preferredEncryptionMode) throws IOException - Throws:
IOException
-
EncryptionInfo
Prepares for encryption, using the given Encryption Mode, and all other parameters as default. -
EncryptionInfo
public EncryptionInfo(EncryptionMode encryptionMode, CipherAlgorithm cipherAlgorithm, HashAlgorithm hashAlgorithm, int keyBits, int blockSize, ChainingMode chainingMode) Constructs an EncryptionInfo from scratch- Parameters:
encryptionMode- seeEncryptionModefor values,EncryptionMode.cryptoAPIis for internal use only, as it's record basedcipherAlgorithm- the cipher algorithmhashAlgorithm- the hash algorithmkeyBits- the bit count of the keyblockSize- the size of a cipher blockchainingMode- the chaining mode- Throws:
EncryptedDocumentException- if the given parameters mismatch, e.g. only certain combinations of keyBits, blockSize are allowed for a givenCipherAlgorithm
-
-
Method Details
-
getBuilder
protected static EncryptionInfoBuilder getBuilder(EncryptionMode encryptionMode) throws ClassNotFoundException, IllegalAccessException, InstantiationException This method loads the builder class with reflection, which may generate aClassNotFoundExceptionif the class is not on the classpath. For example,AgileEncryptionInfoBuilderis contained in thepoi-ooxmlpackage since the class makes use of some OOXML classes rather than using thepoipackage and plain XML DOM calls. As such, you may need to includepoi-ooxmlandpoi-ooxml-schemasto load some encryption mode builders. See bug #60021 for more information. https://bz.apache.org/bugzilla/show_bug.cgi?id=60021- Parameters:
encryptionMode- the encryption mode- Returns:
- an encryption info builder
- Throws:
ClassNotFoundException- if the builder class is not on the classpathIllegalAccessException- if the builder class can't be loadedInstantiationException- if the builder class can't be loaded
-
getVersionMajor
public int getVersionMajor() -
getVersionMinor
public int getVersionMinor() -
getEncryptionFlags
public int getEncryptionFlags() -
getHeader
-
getVerifier
-
getDecryptor
-
getEncryptor
-
setHeader
-
setVerifier
-
setDecryptor
-
setEncryptor
-
getEncryptionMode
-
isDocPropsEncrypted
public boolean isDocPropsEncrypted()- Returns:
- true, if Document Summary / Summary are encrypted and stored in the
EncryptedStreamstream, otherwise the Summaries aren't encrypted and located in their usual streams
-
clone
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-