org.openadaptor.security
Class AbstractSecurityOutputStreamComponent

java.lang.Object
  extended by java.io.OutputStream
      extended by org.openadaptor.util.PipelineOutputStream
          extended by org.openadaptor.security.AbstractSecurityOutputStreamComponent
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, SecurityComponent, SecurityOutputStreamComponent, OutputStreamComponent
Direct Known Subclasses:
DigestOutputStreamComponent, EncryptionOutputStreamComponent, NullOutputStreamComponent, SignOutputStreamComponent

public abstract class AbstractSecurityOutputStreamComponent
extends PipelineOutputStream
implements SecurityOutputStreamComponent

This is an abstract implementation of the SecurityOutputStreamComponent. It holds a reference to the security manager of the adaptor. Holds the reference to the policy being applied currently.

See Also:
EncryptionOutputStreamComponent, SignOutputStreamComponent, DigestOutputStreamComponent, SecurityOutputStreamComponent, PipelineOutputStream

Field Summary
protected  SecurityAgent _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
AbstractSecurityOutputStreamComponent(OutputStreamComponent output)
          Default constructor for a pipeline.
 
Method Summary
 void finishDataBlock()
          Finish off the current data block being output.
 Policy getPolicy()
          Returns the Policy object being used by the Security Agent - SecurityOutputStream
 OASecurityManager getSecurityManager()
          Returns the SecurityManager object attached to the SecurityOutputStream
 void processWrite(byte[] b)
           
abstract  void processWrite(byte[] b, int off, int len)
          True write method.
protected abstract  void processWrite(int b)
          True write method.
 void setSecurity(Policy policy, OASecurityManager securityManager)
          Initializes the SecurityAgent - SecurityOutputStreamComponent.
protected  void setSecurityOperation(java.lang.String operation)
           
protected  void setUnsetParameters(java.lang.String algoName, java.lang.String providerName)
           
 void startDataBlock()
          Start a new data block.
 void write(byte[] b)
          Writes bb.length bytes from the specified byte array to the output stream.
 void write(byte[] b, int off, int len)
          Writes len bytes from the specified byte array starting at offset off to this output stream.
 void write(int b)
          Writes the Byte[] into the Output Stream - Using Cipher Output Stream
 
Methods inherited from class org.openadaptor.util.PipelineOutputStream
asOutputStream, close, flush, getOutputStream, isInDataBlock, setOutputStream
 
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, setOutputStream
 

Field Detail

_agent

protected SecurityAgent _agent
Constructor Detail

AbstractSecurityOutputStreamComponent

public AbstractSecurityOutputStreamComponent(OutputStreamComponent output)
Default constructor for a pipeline.

Parameters:
output - The next component in the pipeline.
Method Detail

setSecurityOperation

protected void setSecurityOperation(java.lang.String operation)

setSecurity

public void setSecurity(Policy policy,
                        OASecurityManager securityManager)
                 throws java.lang.SecurityException
Initializes the SecurityAgent - SecurityOutputStreamComponent.

Specified by:
setSecurity in interface SecurityComponent
Parameters:
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.
Throws:
java.lang.SecurityException - If there is a problem with the policy or SecurityManager provided.
See Also:
Policy, OASecurityManager

setUnsetParameters

protected void setUnsetParameters(java.lang.String algoName,
                                  java.lang.String providerName)

getPolicy

public Policy getPolicy()
Returns the Policy object being used by the Security Agent - SecurityOutputStream

Specified by:
getPolicy in interface SecurityComponent
Returns:
Policy

getSecurityManager

public OASecurityManager getSecurityManager()
Returns the SecurityManager object attached to the SecurityOutputStream

Specified by:
getSecurityManager in interface SecurityComponent
Returns:
OASecurityManager
See Also:
OASecurityManager

startDataBlock

public void startDataBlock()
                    throws java.io.IOException
Start a new data block. Calls super.startDataBlock() and checks that _out exists, and _agent exists and is initialised

Specified by:
startDataBlock in interface OutputStreamComponent
Overrides:
startDataBlock in class PipelineOutputStream
Throws:
java.io.IOException - If _out or _agent are not usable.

finishDataBlock

public void finishDataBlock()
                     throws java.io.IOException
Finish off the current data block being output.

Specified by:
finishDataBlock in interface OutputStreamComponent
Overrides:
finishDataBlock in class PipelineOutputStream
Throws:
java.io.IOException - If _out is null.

processWrite

protected abstract void processWrite(int b)
                              throws java.io.IOException
True write method. Subclasses override this to perform the byte processing and writing that takes place when in a datablock. Only called when isInDataBlock() is true.

Throws:
java.io.IOException

write

public final void write(int b)
                 throws java.io.IOException
Writes the Byte[] into the Output Stream - Using Cipher Output Stream

Specified by:
write in interface OutputStreamComponent
Specified by:
write in class java.io.OutputStream
Parameters:
b - the byte.
Throws:
java.io.IOException - if an I/O error occurs.

processWrite

public abstract void processWrite(byte[] b,
                                  int off,
                                  int len)
                           throws java.io.IOException
True write method. Subclasses override this to perform the byte processing and writing that takes place when in a datablock.

Throws:
java.io.IOException

write

public final void write(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
Description copied from interface: OutputStreamComponent
Writes len bytes from the specified byte array starting at offset off to this output stream.

Specified by:
write in interface OutputStreamComponent
Overrides:
write in class java.io.OutputStream
off - the start offset in the data.
len - the number of bytes to write.
Throws:
java.io.IOException - if an I/O error occurs.

processWrite

public void processWrite(byte[] b)
                  throws java.io.IOException
Throws:
java.io.IOException

write

public final void write(byte[] b)
                 throws java.io.IOException
Description copied from interface: OutputStreamComponent
Writes bb.length bytes from the specified byte array to the output stream.

Specified by:
write in interface OutputStreamComponent
Overrides:
write in class java.io.OutputStream
Parameters:
b - the bytes.
Throws:
java.io.IOException - if an I/O error occurs.