org.apache.poi.poifs.crypt.cryptoapi
Class CryptoAPIEncryptor

java.lang.Object
  extended by org.apache.poi.poifs.crypt.Encryptor
      extended by org.apache.poi.poifs.crypt.cryptoapi.CryptoAPIEncryptor
All Implemented Interfaces:
java.lang.Cloneable

public class CryptoAPIEncryptor
extends Encryptor
implements java.lang.Cloneable


Nested Class Summary
protected  class CryptoAPIEncryptor.CryptoAPICipherOutputStream
           
 
Field Summary
 
Fields inherited from class org.apache.poi.poifs.crypt.Encryptor
DEFAULT_POIFS_ENTRY
 
Constructor Summary
protected CryptoAPIEncryptor()
           
 
Method Summary
 CryptoAPIEncryptor clone()
           
 void confirmPassword(java.lang.String password)
           
 void confirmPassword(java.lang.String password, byte[] keySpec, byte[] keySalt, byte[] verifier, byte[] verifierSalt, byte[] integritySalt)
           
protected  void createEncryptionInfoEntry(DirectoryNode dir)
           
 ChunkedCipherOutputStream getDataStream(DirectoryNode dir)
          Return a output stream for encrypted data.
 CryptoAPIEncryptor.CryptoAPICipherOutputStream getDataStream(java.io.OutputStream stream, int initialOffset)
           
protected  int getKeySizeInBytes()
           
 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 setSummaryEntries(DirectoryNode dir, java.lang.String encryptedStream, NPOIFSFileSystem entries)
          Encrypt the Document-/SummaryInformation and other optionally streams.
 
Methods inherited from class org.apache.poi.poifs.crypt.Encryptor
getDataStream, getDataStream, getDataStream, getEncryptionInfo, getInstance, getSecretKey, setEncryptionInfo, setSecretKey
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CryptoAPIEncryptor

protected CryptoAPIEncryptor()
Method Detail

confirmPassword

public void confirmPassword(java.lang.String password)
Specified by:
confirmPassword in class Encryptor

confirmPassword

public void confirmPassword(java.lang.String password,
                            byte[] keySpec,
                            byte[] keySalt,
                            byte[] verifier,
                            byte[] verifierSalt,
                            byte[] integritySalt)
Specified by:
confirmPassword in class Encryptor

initCipherForBlock

public javax.crypto.Cipher initCipherForBlock(javax.crypto.Cipher cipher,
                                              int block)
                                       throws java.security.GeneralSecurityException
Initializes a cipher object for a given block index for encryption

Parameters:
cipher - may be null, otherwise the given instance is reset to the new block index
block - the block index, e.g. the persist/slide id (hslf)
Returns:
a new cipher object, if cipher was null, otherwise the reinitialized cipher
Throws:
java.security.GeneralSecurityException

getDataStream

public ChunkedCipherOutputStream getDataStream(DirectoryNode dir)
                                        throws java.io.IOException,
                                               java.security.GeneralSecurityException
Description copied from class: Encryptor
Return a output stream for encrypted data.

Specified by:
getDataStream in class Encryptor
Parameters:
dir - the node to write to
Returns:
encrypted stream
Throws:
java.io.IOException
java.security.GeneralSecurityException

getDataStream

public CryptoAPIEncryptor.CryptoAPICipherOutputStream getDataStream(java.io.OutputStream stream,
                                                                    int initialOffset)
                                                             throws java.io.IOException,
                                                                    java.security.GeneralSecurityException
Overrides:
getDataStream in class Encryptor
Throws:
java.io.IOException
java.security.GeneralSecurityException

setSummaryEntries

public void setSummaryEntries(DirectoryNode dir,
                              java.lang.String encryptedStream,
                              NPOIFSFileSystem entries)
                       throws java.io.IOException,
                              java.security.GeneralSecurityException
Encrypt the Document-/SummaryInformation and other optionally streams. Opposed to other crypto modes, cryptoapi is record based and can't be used to stream-encrypt a whole file

Throws:
java.io.IOException
java.security.GeneralSecurityException
See Also:
2.3.5.4 RC4 CryptoAPI Encrypted Summary Stream

getKeySizeInBytes

protected int getKeySizeInBytes()

setChunkSize

public void setChunkSize(int chunkSize)
Description copied from class: Encryptor
Sets the chunk size of the data stream. Needs to be set before the data stream is requested. When not set, the implementation uses method specific default values

Overrides:
setChunkSize in class Encryptor
Parameters:
chunkSize - the chunk size, i.e. the block size with the same encryption key

createEncryptionInfoEntry

protected void createEncryptionInfoEntry(DirectoryNode dir)
                                  throws java.io.IOException
Throws:
java.io.IOException

clone

public CryptoAPIEncryptor clone()
                         throws java.lang.CloneNotSupportedException
Overrides:
clone in class Encryptor
Throws:
java.lang.CloneNotSupportedException