Class SecurityHandler
- java.lang.Object
-
- com.itextpdf.kernel.crypto.securityhandler.SecurityHandler
-
- Direct Known Subclasses:
PubKeySecurityHandler,StandardSecurityHandler
public abstract class SecurityHandler extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]extraWork area to prepare the object/generation bytesprivate static IBouncyCastleFactoryFACTORYprivate static org.slf4j.LoggerLOGGERprotected java.security.MessageDigestmd5protected byte[]mkeyThe global encryption keyprotected byte[]nextObjectKeyThe encryption key for a particular object/generation.protected intnextObjectKeySizeThe encryption key length for a particular object/generation It is recalculated withsetHashKeyForNextObject(int, int)for every object individually based in its object/generation.
-
Constructor Summary
Constructors Modifier Constructor Description protectedSecurityHandler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract IDecryptorgetDecryptor()Gets decryptor object.abstract OutputStreamEncryptiongetEncryptionStream(java.io.OutputStream os)Gets a stream wrapper, responsible for encryption.byte[]getMkey()Gets global encryption key.byte[]getNextObjectKey()Gets encryption key for a particular object/generation.protected voidinitMd5MessageDigest()Init md5 message digest.voidsetHashKeyForNextObject(int objNumber, int objGeneration)Note: For most of the supported security handlers algorithm to calculate encryption key for particular object is the same.
-
-
-
Field Detail
-
FACTORY
private static final IBouncyCastleFactory FACTORY
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
mkey
protected byte[] mkey
The global encryption key
-
nextObjectKey
protected byte[] nextObjectKey
The encryption key for a particular object/generation. It is recalculated withsetHashKeyForNextObject(int, int)for every object individually based in its object/generation.
-
nextObjectKeySize
protected int nextObjectKeySize
The encryption key length for a particular object/generation It is recalculated withsetHashKeyForNextObject(int, int)for every object individually based in its object/generation.
-
md5
protected java.security.MessageDigest md5
-
extra
protected byte[] extra
Work area to prepare the object/generation bytes
-
-
Method Detail
-
setHashKeyForNextObject
public void setHashKeyForNextObject(int objNumber, int objGeneration)Note: For most of the supported security handlers algorithm to calculate encryption key for particular object is the same.- Parameters:
objNumber- number of particular object for encryptionobjGeneration- generation of particular object for encryption
-
getEncryptionStream
public abstract OutputStreamEncryption getEncryptionStream(java.io.OutputStream os)
Gets a stream wrapper, responsible for encryption.- Parameters:
os-OutputStreamto be wrapped- Returns:
OutputStreamEncryption, responsible for encryption.
-
getDecryptor
public abstract IDecryptor getDecryptor()
Gets decryptor object.- Returns:
IDecryptor
-
getNextObjectKey
public byte[] getNextObjectKey()
Gets encryption key for a particular object/generation.- Returns:
- encryption key for a particular object/generation.
-
getMkey
public byte[] getMkey()
Gets global encryption key.- Returns:
- global encryption key.
-
initMd5MessageDigest
protected void initMd5MessageDigest()
Init md5 message digest.
-
-