com.sun.grizzly.ssl
Class SSLEncoderTransformer

java.lang.Object
  extended by com.sun.grizzly.ssl.SSLEncoderTransformer
All Implemented Interfaces:
Transformer<Buffer,Buffer>

public class SSLEncoderTransformer
extends Object
implements Transformer<Buffer,Buffer>

Transformer, which encrypts plain data, contained in the input Buffer, into SSL/TLS data and puts the result to the output Buffer.

Author:
Alexey Stashok

Field Summary
static int BUFFER_OVERFLOW_ERROR
           
static int BUFFER_UNDERFLOW_ERROR
           
static int NEED_HANDSHAKE_ERROR
           
 
Constructor Summary
SSLEncoderTransformer()
           
 
Method Summary
 Buffer getInput(AttributeStorage state)
          Gets the input data, which Transformer will work with.
 TransformationResult<Buffer> getLastResult(AttributeStorage state)
          Gets the last returned Transformer result.
 Buffer getOutput(AttributeStorage state)
          Gets the output, which Transformer will use for transformed data.
 AttributeHolder getProperties(AttributeStorage state)
          Gets the property storage, using which it's possible to read or update Transformer properties.
 void hibernate(AttributeStorage state)
          Method could be called by framework to let Transformer know, that transformation will be postponed and probably continued in separate Thread, so all resources, which are associated with the current Thread should be detached and stored internally or in the external storage.
 void release(AttributeStorage state)
          The Transformer has done its work and can release all associated resource.
 void setInput(AttributeStorage state, Buffer input)
          Sets the input data, which Transformer will work with.
 void setOutput(AttributeStorage state, Buffer outputTarget)
          Gets the output, which Transformer will use for transformed data.
 TransformationResult<Buffer> transform(AttributeStorage state)
          Transforms an input data to some custom representation.
 TransformationResult<Buffer> transform(AttributeStorage state, Buffer originalMessage, Buffer targetMessage)
          Transforms an input data to some custom representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NEED_HANDSHAKE_ERROR

public static final int NEED_HANDSHAKE_ERROR
See Also:
Constant Field Values

BUFFER_UNDERFLOW_ERROR

public static final int BUFFER_UNDERFLOW_ERROR
See Also:
Constant Field Values

BUFFER_OVERFLOW_ERROR

public static final int BUFFER_OVERFLOW_ERROR
See Also:
Constant Field Values
Constructor Detail

SSLEncoderTransformer

public SSLEncoderTransformer()
Method Detail

transform

public TransformationResult<Buffer> transform(AttributeStorage state)
                                       throws TransformationException
Description copied from interface: Transformer
Transforms an input data to some custom representation. Input and output are not passed implicitly, which means that Transformer is able to retrieve input and output from its internal state or from external storage (AttributeStorage).

Specified by:
transform in interface Transformer<Buffer,Buffer>
Parameters:
state - the external state storage, where Transformer could get/put a state.
Returns:
the result TransformationResult
Throws:
TransformationException

transform

public TransformationResult<Buffer> transform(AttributeStorage state,
                                              Buffer originalMessage,
                                              Buffer targetMessage)
                                       throws TransformationException
Description copied from interface: Transformer
Transforms an input data to some custom representation.

Specified by:
transform in interface Transformer<Buffer,Buffer>
Parameters:
state - the external state storage, where Transformer could retrieve or store its state.
Returns:
the result TransformationResult
Throws:
TransformationException

getInput

public Buffer getInput(AttributeStorage state)
Description copied from interface: Transformer
Gets the input data, which Transformer will work with. Very often Transformers are used together with I/O operations. When Transformer is used with read operation, this method may return a Buffer, where "reader" will read the data to. But note, the returned Buffer should always represent READY data.In other words, if there is no data to be transformed - the Buffer should have 0 remaining bytes.

Specified by:
getInput in interface Transformer<Buffer,Buffer>
Parameters:
state - the external state storage, where Transformer could retrieve or store its state.
Returns:
the Transformer input.

setInput

public void setInput(AttributeStorage state,
                     Buffer input)
Description copied from interface: Transformer
Sets the input data, which Transformer will work with. Very often Transformers are used together with I/O operations. When Transformer is used with read operation, the input Buffer will be used by "reader" to read the data to. But note, the input Buffer should always represent READY data.In other words, if there is no data to be transformed - the Buffer should have 0 remaining bytes.

Specified by:
setInput in interface Transformer<Buffer,Buffer>
Parameters:
state - the external state storage, where Transformer could retrieve or store its state.
input - Input data

getOutput

public Buffer getOutput(AttributeStorage state)
Description copied from interface: Transformer
Gets the output, which Transformer will use for transformed data. Although output could be used to get a result of transformation, it is recommended to return transformation result directly from transform method within TransformationResult.

Specified by:
getOutput in interface Transformer<Buffer,Buffer>
Parameters:
state - the external state storage, where Transformer could retrieve or store its state.
Returns:
the Transformer output.

setOutput

public void setOutput(AttributeStorage state,
                      Buffer outputTarget)
Description copied from interface: Transformer
Gets the output, which Transformer will use for transformed data. Although output could be used to get a result of transformation, it is recommended to return transformation result directly from transform method within TransformationResult.

Specified by:
setOutput in interface Transformer<Buffer,Buffer>
Parameters:
state - the external state storage, where Transformer could retrieve or store its state.
outputTarget - Output

getLastResult

public TransformationResult<Buffer> getLastResult(AttributeStorage state)
Description copied from interface: Transformer
Gets the last returned Transformer result. Last result could be either retrieved from internal state, or external storage, which is passed as the parameter.

Specified by:
getLastResult in interface Transformer<Buffer,Buffer>
Parameters:
state - the external state storage, where Transformer could retrieve or store its state.
Returns:
the last returned Transformer result.

getProperties

public AttributeHolder getProperties(AttributeStorage state)
Description copied from interface: Transformer
Gets the property storage, using which it's possible to read or update Transformer properties.

Specified by:
getProperties in interface Transformer<Buffer,Buffer>
Parameters:
state - the external state storage, where Transformer could retrieve or store its state.
Returns:
the property storage.

hibernate

public void hibernate(AttributeStorage state)
Description copied from interface: Transformer
Method could be called by framework to let Transformer know, that transformation will be postponed and probably continued in separate Thread, so all resources, which are associated with the current Thread should be detached and stored internally or in the external storage.

Specified by:
hibernate in interface Transformer<Buffer,Buffer>
Parameters:
state - the external state storage, where Transformer could retrieve or store its state.

release

public void release(AttributeStorage state)
Description copied from interface: Transformer
The Transformer has done its work and can release all associated resource.

Specified by:
release in interface Transformer<Buffer,Buffer>
Parameters:
state - the external state storage, where Transformer could retrieve or store its state.


Copyright © 2009 SUN Microsystems. All Rights Reserved.