org.apache.poi.poifs.crypt
Class Encryptor

java.lang.Object
  extended by org.apache.poi.poifs.crypt.Encryptor
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
BinaryRC4Encryptor, CryptoAPIEncryptor, StandardEncryptor, XOREncryptor

public abstract class Encryptor
extends java.lang.Object
implements java.lang.Cloneable


Field Summary
protected static java.lang.String DEFAULT_POIFS_ENTRY
           
 
Constructor Summary
Encryptor()
           
 
Method Summary
 Encryptor clone()
           
abstract  void confirmPassword(java.lang.String password)
           
abstract  void confirmPassword(java.lang.String password, byte[] keySpec, byte[] keySalt, byte[] verifier, byte[] verifierSalt, byte[] integritySalt)
           
abstract  java.io.OutputStream getDataStream(DirectoryNode dir)
          Return a output stream for encrypted data.
 java.io.OutputStream getDataStream(NPOIFSFileSystem fs)
           
 java.io.OutputStream getDataStream(OPOIFSFileSystem fs)
           
 ChunkedCipherOutputStream getDataStream(java.io.OutputStream stream, int initialOffset)
           
 java.io.OutputStream getDataStream(POIFSFileSystem fs)
           
 EncryptionInfo getEncryptionInfo()
           
static Encryptor getInstance(EncryptionInfo info)
           
 javax.crypto.SecretKey getSecretKey()
           
 void setChunkSize(int chunkSize)
          Sets the chunk size of the data stream.
 void setEncryptionInfo(EncryptionInfo encryptionInfo)
           
 void setSecretKey(javax.crypto.SecretKey secretKey)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_POIFS_ENTRY

protected static final java.lang.String DEFAULT_POIFS_ENTRY
See Also:
Constant Field Values
Constructor Detail

Encryptor

public Encryptor()
Method Detail

getDataStream

public abstract java.io.OutputStream getDataStream(DirectoryNode dir)
                                            throws java.io.IOException,
                                                   java.security.GeneralSecurityException
Return a output stream for encrypted data.

Parameters:
dir - the node to write to
Returns:
encrypted stream
Throws:
java.io.IOException
java.security.GeneralSecurityException

confirmPassword

public abstract void confirmPassword(java.lang.String password,
                                     byte[] keySpec,
                                     byte[] keySalt,
                                     byte[] verifier,
                                     byte[] verifierSalt,
                                     byte[] integritySalt)

confirmPassword

public abstract void confirmPassword(java.lang.String password)

getInstance

public static Encryptor getInstance(EncryptionInfo info)

getDataStream

public java.io.OutputStream getDataStream(NPOIFSFileSystem fs)
                                   throws java.io.IOException,
                                          java.security.GeneralSecurityException
Throws:
java.io.IOException
java.security.GeneralSecurityException

getDataStream

public java.io.OutputStream getDataStream(OPOIFSFileSystem fs)
                                   throws java.io.IOException,
                                          java.security.GeneralSecurityException
Throws:
java.io.IOException
java.security.GeneralSecurityException

getDataStream

public java.io.OutputStream getDataStream(POIFSFileSystem fs)
                                   throws java.io.IOException,
                                          java.security.GeneralSecurityException
Throws:
java.io.IOException
java.security.GeneralSecurityException

getDataStream

public ChunkedCipherOutputStream getDataStream(java.io.OutputStream stream,
                                               int initialOffset)
                                        throws java.io.IOException,
                                               java.security.GeneralSecurityException
Throws:
java.io.IOException
java.security.GeneralSecurityException

getSecretKey

public javax.crypto.SecretKey getSecretKey()

setSecretKey

public void setSecretKey(javax.crypto.SecretKey secretKey)

getEncryptionInfo

public EncryptionInfo getEncryptionInfo()

setEncryptionInfo

public void setEncryptionInfo(EncryptionInfo encryptionInfo)

setChunkSize

public void setChunkSize(int chunkSize)
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

Parameters:
chunkSize - the chunk size, i.e. the block size with the same encryption key

clone

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