|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
org.openadaptor.util.PipelineOutputStream
org.openadaptor.security.AbstractSecurityOutputStreamComponent
org.openadaptor.security.EncryptionOutputStreamComponent
public class EncryptionOutputStreamComponent
Implements a 'Encrypt' OutputStreamComponent which writes out a line of header information, Then encrypts the byte[] passed through it and passes the encrypted bytes[] onto the down stream component. The header information is passed when the StartDataBlock() is called The byte[] array passed are encrypted until the finishDataBlock is called EncryptionOutputStreamComponent - Implements a 'Encrypt' OutputStreamComponent This component encrypts all the bytes flowing through it until the finishDataBlock() call is made. The encryption is done using the Cipher object created at start. The algorithm and provider to be used to create the Cipher is read by this component from the policy passed to it. This component also creates a header packet in which it stores the information like the Algorithm and the Provider used. Additionally it stores the ID of the SecureKey which it has used to do the encryption This Key is stored in the security server from which the counterpart object EncryptionInputStream retrieves it.
EncryptionInputStreamComponent
,
Cipher
,
CipherOutputStream
,
Header
,
Footer
Field Summary | |
---|---|
protected javax.crypto.Cipher |
_cipher
Cipher Algoritm Implementation |
protected javax.crypto.CipherOutputStream |
_cos
Cipher Encrypting OutputStream |
protected javax.crypto.spec.IvParameterSpec |
_iv
|
protected java.security.AlgorithmParameters |
_params
Cipher Algorithm parameters |
protected SecureKey |
_secureKey
Key to be used for encryption obtained from Security Server |
static java.lang.String |
CHUNK_SIZE
|
(package private) static org.apache.log4j.Logger |
log
|
static byte[] |
TRAILER
|
Fields inherited from class org.openadaptor.security.AbstractSecurityOutputStreamComponent |
---|
_agent |
Fields inherited from class org.openadaptor.util.PipelineOutputStream |
---|
_inDataBlock, _out |
Fields inherited from interface org.openadaptor.security.interfaces.SecurityComponent |
---|
ALGORITHM_HD_ATTR, CIPHER_DECRYPT_OPERATION, CIPHER_ENCRYPT_OPERATION, DEFAULT_CIPHER_ALGO, DEFAULT_CIPHER_PROVIDER, DEFAULT_DIGEST_ALGO, DEFAULT_DIGEST_PROVIDER, DEFAULT_KEY_EXPIRY, DEFAULT_SIGN_ALGO, DEFAULT_SIGN_PROVIDER, DIGEST_FT_ATTR, DIGEST_SECURITY_OPERATION, KEYID_HD_ATTR, PARAMS_DATA_HD_ATTR, PARAMS_TYPE_HD_ATTR, PROVIDER_HD_ATTR, SIGN_FT_ATTR, SIGN_SECURITY_OPERATION |
Constructor Summary | |
---|---|
EncryptionOutputStreamComponent(OutputStreamComponent output)
Default constructor for a pipeline. |
Method Summary | |
---|---|
protected java.lang.String |
base64Encode(byte[] data)
Base64 encode a byte[] array in a String. |
void |
finishDataBlock()
Finish off the current data block being output. |
static void |
main(java.lang.String[] args)
|
void |
processWrite(byte[] b,
int off,
int len)
True write method. |
void |
processWrite(int b)
Writes the Byte[] into the Output Stream - Using Cipher Output Stream |
protected void |
reInitCipher()
Re-initialize the Cipher. |
protected void |
setCipherParameters()
Determines the Cipher parameters, such as an IV, by performing a test encryption. |
void |
setOutputStream(OutputStreamComponent output)
Sets the output component. |
void |
setSecurity(Policy policy,
OASecurityManager securityManager)
Initializes the Encryption - SecurityAgent. |
protected byte[] |
simpleEncrypt(byte[] data)
Try encrypting data with fixed algorithm that does not require IV or other parameters. |
void |
startDataBlock()
Start processing a new data block. |
Methods inherited from class org.openadaptor.security.AbstractSecurityOutputStreamComponent |
---|
getPolicy, getSecurityManager, processWrite, setSecurityOperation, setUnsetParameters, write, write, write |
Methods inherited from class org.openadaptor.util.PipelineOutputStream |
---|
asOutputStream, close, flush, getOutputStream, isInDataBlock |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.openadaptor.util.OutputStreamComponent |
---|
asOutputStream, close, flush, getOutputStream, isInDataBlock |
Field Detail |
---|
static org.apache.log4j.Logger log
public static final byte[] TRAILER
public static final java.lang.String CHUNK_SIZE
protected javax.crypto.Cipher _cipher
protected java.security.AlgorithmParameters _params
protected javax.crypto.spec.IvParameterSpec _iv
protected javax.crypto.CipherOutputStream _cos
protected SecureKey _secureKey
Constructor Detail |
---|
public EncryptionOutputStreamComponent(OutputStreamComponent output) throws java.io.IOException
output
- The next component in the pipeline.
java.io.IOException
Method Detail |
---|
public void setOutputStream(OutputStreamComponent output)
This method wraps the outputStream in
setOutputStream
in interface OutputStreamComponent
setOutputStream
in class PipelineOutputStream
output
- The output component.public void setSecurity(Policy policy, OASecurityManager securityManager) throws java.lang.SecurityException
setSecurity
in interface SecurityComponent
setSecurity
in class AbstractSecurityOutputStreamComponent
policy
- is used to get various properties like algorithm,
provider, etc. required for actual low-level operation.securityManager
- used to interact with SecurityServer to get
various information like key, policy, etc. if required.
java.lang.SecurityException
- If there is a problem with the policy
or SecurityManager provided.Cipher
public void startDataBlock() throws java.lang.SecurityException, java.io.IOException
write()
method which precede a startDataBlock()
should pass the bytes through unprocessed. This allows upstream
components to write out header information for the decoding process
on the other side.
startDataBlock
in interface OutputStreamComponent
startDataBlock
in class AbstractSecurityOutputStreamComponent
java.io.IOException
- if an I/O error occurs.
java.lang.SecurityException
Cipher
,
CipherOutputStream
protected void setCipherParameters() throws java.security.InvalidKeyException, javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException, java.io.IOException
java.security.InvalidKeyException
javax.crypto.IllegalBlockSizeException
javax.crypto.BadPaddingException
java.io.IOException
protected void reInitCipher() throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
java.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException
protected java.lang.String base64Encode(byte[] data) throws java.io.IOException
java.io.IOException
protected byte[] simpleEncrypt(byte[] data)
data
- The data to encrypt
public void processWrite(int b) throws java.io.IOException
processWrite
in class AbstractSecurityOutputStreamComponent
java.io.IOException
public void processWrite(byte[] b, int off, int len) throws java.io.IOException
AbstractSecurityOutputStreamComponent
processWrite
in class AbstractSecurityOutputStreamComponent
java.io.IOException
public final void finishDataBlock() throws java.io.IOException
finishDataBlock
in interface OutputStreamComponent
finishDataBlock
in class AbstractSecurityOutputStreamComponent
java.io.IOException
- If _out is null.public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |