gnu.javax.crypto.assembly
Class Transformer
A
Transformer
is an abstract representation of a two-way
transformation that can be chained together with other instances of
this type. Examples of such transformations in this library are:
Cascade
cipher,
IPad
algorithm, and a
ZLib-based deflater/inflater algorithm. A special implementation of a
Transformer
to close a chain is also provided.
A
Transformer
is characterised by the followings:
- It can be chained to other instances, to form an
Assembly
. - When configured in an
Assembly
, it can be set to apply its
internal transformation on the input data stream before (pre-processing) or
after (post-processing) passing the input data to the next element in the
chain. Note that the same type Transformer
can be used as
either in pre-processing or a post-processing modes. - A special transformer --
LoopbackTransformer
-- is used
to close the chain. - A useful type of
Transformer
--one we're interested in--
has internal buffers. The distinction between a casual push (update)
operation and the last one allows to correctly flush any intermediate bytes
that may exist in those buffers.
To allow wiring
Transformer
instances together, a
minimal-output-size in bytes is necessary. The trivial case of a
value of
1
for such attribute practically means that no output
buffering, from the previous element, is needed --which is independant of
buffering the input if the
Transformer
implementation itself
is block-based.
CascadeTransformer
, PaddingTransformer
, DeflateTransformer
int | currentBlockSize() - Returns the block-size of this
Transformer .
|
static Transformer | getCascadeTransformer(Cascade cascade)
|
static Transformer | getDeflateTransformer()
|
static Transformer | getPaddingTransformer(IPad padding)
|
void | init(Map<K,V> attributes) - Initialises the
Transformer for operation with specific
characteristics.
|
boolean | isPostProcessing() - Returns
true if this Transformer was wired in
post-processing mode; false otherwise.
|
boolean | isPreProcessing() - Returns
true if this Transformer was wired in
pre-processing mode; false otherwise.
|
byte[] | lastUpdate() - Convenience method that calls the same method with three arguments.
|
byte[] | lastUpdate(byte b) - Convenience method that calls the method with same name and three
arguments, using a byte array of length
1 whose contents are
the designated byte.
|
byte[] | lastUpdate(byte[] in) - Convenience method that calls the same method with three arguments.
|
byte[] | lastUpdate(byte[] in, int offset, int length) - Processes a designated number of bytes from a given byte array and signals,
at the same time, that this is the last push operation on this
Transformer .
|
void | reset() - Resets the
Transformer for re-initialisation and use with
other characteristics.
|
void | setMode(Operation mode) - Sets the operational mode of this
Transformer .
|
byte[] | update(byte b) - Convenience method that calls the method with same name and three
arguments, using a byte array of length
1 whose contents are
the designated byte.
|
byte[] | update(byte[] in) - Convenience method that calls the same method with three arguments.
|
byte[] | update(byte[] in, int offset, int length) - Processes a designated number of bytes from a given byte array.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
DIRECTION
public static final String DIRECTION
- "gnu.crypto.assembly.transformer.direction"
Transformer
protected Transformer()
Trivial protected constructor.
currentBlockSize
public int currentBlockSize()
Returns the block-size of this Transformer
. A value of
1
indicates that this instance is block-agnostic.
- the current minimal required block size.
init
public void init(Map<K,V> attributes)
throws TransformerException
Initialises the Transformer
for operation with specific
characteristics.
attributes
- a set of name-value pairs that describes the desired
future behaviour of this instance.
isPostProcessing
public boolean isPostProcessing()
Returns true
if this Transformer
was wired in
post-processing mode; false
otherwise.
true
if this Transformer
has been
wired in post-processing mode; false
otherwise.
isPreProcessing
public boolean isPreProcessing()
Returns true
if this Transformer
was wired in
pre-processing mode; false
otherwise.
true
if this Transformer
has been
wired in pre-processing mode; false
otherwise.
lastUpdate
public byte[] lastUpdate()
throws TransformerException
Convenience method that calls the same method with three arguments. A
zero-long byte array is used.
- the result of transformation.
lastUpdate
public byte[] lastUpdate(byte b)
throws TransformerException
Convenience method that calls the method with same name and three
arguments, using a byte array of length 1
whose contents are
the designated byte.
- the result of transformation.
lastUpdate
public byte[] lastUpdate(byte[] in)
throws TransformerException
Convenience method that calls the same method with three arguments. All
bytes in in
, starting from index position 0
are considered.
in
- the input data bytes.
- the result of transformation.
lastUpdate
public byte[] lastUpdate(byte[] in,
int offset,
int length)
throws TransformerException
Processes a designated number of bytes from a given byte array and signals,
at the same time, that this is the last push operation on this
Transformer
.
in
- the input data bytes.offset
- index of in
from which to start considering
data.length
- the count of bytes to process.
- the result of transformation.
reset
public void reset()
Resets the Transformer
for re-initialisation and use with
other characteristics. This method always succeeds.
setMode
public void setMode(Operation mode)
Sets the operational mode of this Transformer
.
mode
- the processing mode this Transformer
is required
to operate in.
update
public byte[] update(byte b)
throws TransformerException
Convenience method that calls the method with same name and three
arguments, using a byte array of length 1
whose contents are
the designated byte.
- the result of transformation.
update
public byte[] update(byte[] in)
throws TransformerException
Convenience method that calls the same method with three arguments. All
bytes in in
, starting from index position 0
are considered.
in
- the input data bytes.
- the result of transformation.
update
public byte[] update(byte[] in,
int offset,
int length)
throws TransformerException
Processes a designated number of bytes from a given byte array.
in
- the input data bytes.offset
- index of in
from which to start considering
data.length
- the count of bytes to process.
- the result of transformation.
Transformer.java --
Copyright (C) 2003, 2006 Free Software Foundation, Inc.
This file is a part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.