Top Description Fields Constructors Methods
org.apache.poi.poifs.crypt

public Class EncryptionInfo

extends Object
implements GenericRecord
Class Inheritance
All Implemented Interfaces
org.apache.poi.common.usermodel.GenericRecord
Static Imports
org.apache.poi.poifs.crypt.EncryptionMode.agile, .EncryptionMode.binaryRC4, .EncryptionMode.cryptoAPI, .EncryptionMode.standard, .EncryptionMode.xor, org.apache.poi.util.GenericRecordUtil.getBitsAsString

Wrapper for the EncryptionInfo node of encrypted documents

Field Summary

Modifier and TypeField and Description
private Decryptor
public static final String
ENCRYPTION_INFO_ENTRY

Document entry name for encryption info xml descriptor

private final int
private final EncryptionMode
private Encryptor
public static final BitField
flagAES

A value that MUST be 1 if the protected content is an ECMA-376 document ECMA-376.

public static final BitField
flagCryptoAPI

A flag that specifies whether CryptoAPI RC4 or ECMA-376 encryption ECMA-376 is used.

public static final BitField
flagDocProps

A value that MUST be 0 if document properties are encrypted.

public static final BitField
flagExternal

A value that MUST be 1 if extensible encryption is used.

private static final int[]
private static final String[]
private EncryptionHeader
private EncryptionVerifier
private final int
private final int

Constructor Summary

AccessConstructor and Description
public
EncryptionInfo(POIFSFileSystem fs)

Opens for decryption

public
EncryptionInfo(DirectoryNode dir)

Opens for decryption

public
EncryptionInfo(LittleEndianInput dis, EncryptionMode preferredEncryptionMode)

public
EncryptionInfo(EncryptionMode encryptionMode)

Prepares for encryption, using the given Encryption Mode, and all other parameters as default.

public
EncryptionInfo(EncryptionMode
see EncryptionMode for values, EncryptionMode#cryptoAPI is for internal use only, as its record based
encryptionMode
,
CipherAlgorithm
the cipher algorithm
cipherAlgorithm
,
HashAlgorithm
the hash algorithm
hashAlgorithm
,
int
the bit count of the key
keyBits
,
int
the size of a cipher block
blockSize
,
ChainingMode
the chaining mode
chainingMode
)

Constructs an EncryptionInfo from scratch

public

Method Summary

Modifier and TypeMethod and Description
public EncryptionInfo
copy()

private static EncryptionInfoBuilder

Returns:

an encryption info builder
getBuilder
(EncryptionMode
the encryption mode
encryptionMode
)

Create the builder instance

public Decryptor
public int
public EncryptionMode
public Encryptor
public Map<String, Supplier<?>>
public EncryptionHeader
public EncryptionVerifier
public int
public int
public boolean

Returns:

true, if Document Summary / Summary are encrypted and stored in the EncryptedStream stream, otherwise the Summaries aren't encrypted and located in their usual streams
isDocPropsEncrypted
()

public void
public void
public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

decryptorback to summary
private Decryptor decryptor
ENCRYPTION_INFO_ENTRYback to summary
public static final String ENCRYPTION_INFO_ENTRY

Document entry name for encryption info xml descriptor

encryptionFlagsback to summary
private final int encryptionFlags
encryptionModeback to summary
private final EncryptionMode encryptionMode
encryptorback to summary
private Encryptor encryptor
flagAESback to summary
public static final BitField 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.

flagCryptoAPIback to summary
public static final BitField 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.

flagDocPropsback to summary
public static final BitField 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.

Annotations
@SuppressWarnings:WeakerAccess
flagExternalback to summary
public static final BitField 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.

Annotations
@SuppressWarnings:WeakerAccess
FLAGS_MASKSback to summary
private static final int[] FLAGS_MASKS
FLAGS_NAMESback to summary
private static final String[] FLAGS_NAMES
verifierback to summary
private EncryptionVerifier verifier
versionMajorback to summary
private final int versionMajor
versionMinorback to summary
private final int versionMinor

Constructor Detail

EncryptionInfoback to summary
public EncryptionInfo(POIFSFileSystem fs) throws IOException

Opens for decryption

EncryptionInfoback to summary
public EncryptionInfo(DirectoryNode dir) throws IOException

Opens for decryption

EncryptionInfoback to summary
public EncryptionInfo(LittleEndianInput dis, EncryptionMode preferredEncryptionMode) throws IOException
EncryptionInfoback to summary
public EncryptionInfo(EncryptionMode encryptionMode)

Prepares for encryption, using the given Encryption Mode, and all other parameters as default.

See Also
EncryptionInfo(EncryptionMode, CipherAlgorithm, HashAlgorithm, int, int, ChainingMode)
EncryptionInfoback to summary
public EncryptionInfo(EncryptionMode encryptionMode, CipherAlgorithm cipherAlgorithm, HashAlgorithm hashAlgorithm, int keyBits, int blockSize, ChainingMode chainingMode)

Constructs an EncryptionInfo from scratch

Parameters
encryptionMode:EncryptionMode

see EncryptionMode for values, EncryptionMode#cryptoAPI is for internal use only, as its record based

cipherAlgorithm:CipherAlgorithm

the cipher algorithm

hashAlgorithm:HashAlgorithm

the hash algorithm

keyBits:int

the bit count of the key

blockSize:int

the size of a cipher block

chainingMode:ChainingMode

the chaining mode

Exceptions
EncryptedDocumentException:
if the given parameters mismatch, e.g. only certain combinations of keyBits, blockSize are allowed for a given CipherAlgorithm
EncryptionInfoback to summary
public EncryptionInfo(EncryptionInfo other)

Method Detail

copyback to summary
public EncryptionInfo copy()
getBuilderback to summary
private static EncryptionInfoBuilder getBuilder(EncryptionMode encryptionMode)

Create the builder instance

Parameters
encryptionMode:EncryptionMode

the encryption mode

Returns:EncryptionInfoBuilder

an encryption info builder

getDecryptorback to summary
public Decryptor getDecryptor()
getEncryptionFlagsback to summary
public int getEncryptionFlags()
getEncryptionModeback to summary
public EncryptionMode getEncryptionMode()
getEncryptorback to summary
public Encryptor getEncryptor()
getGenericPropertiesback to summary
public Map<String, Supplier<?>> getGenericProperties()

Implements org.apache.poi.common.usermodel.GenericRecord.getGenericProperties.

Annotations
@Override
getHeaderback to summary
public EncryptionHeader getHeader()
getVerifierback to summary
public EncryptionVerifier getVerifier()
getVersionMajorback to summary
public int getVersionMajor()
getVersionMinorback to summary
public int getVersionMinor()
isDocPropsEncryptedback to summary
public boolean isDocPropsEncrypted()
Returns:boolean

true, if Document Summary / Summary are encrypted and stored in the EncryptedStream stream, otherwise the Summaries aren't encrypted and located in their usual streams

setDecryptorback to summary
public void setDecryptor(Decryptor decryptor)
setEncryptorback to summary
public void setEncryptor(Encryptor encryptor)
setHeaderback to summary
public void setHeader(EncryptionHeader header)
setVerifierback to summary
public void setVerifier(EncryptionVerifier verifier)