edu.berkeley.psi.tagged.api
Class DigestFactory

java.lang.Object
  extended by org.acplt.oncrpc.XdrEncodingStream
      extended by edu.berkeley.psi.tagged.api.TaggedEncodingStream
          extended by edu.berkeley.psi.tagged.api.DigestFactory
Direct Known Subclasses:
MD2DigestFactory, MD5DigestFactory, SHA1DigestFactory, SHA256DigestFactory, SHA384DigestFactory, SHA512DigestFactory

public abstract class DigestFactory
extends TaggedEncodingStream

Generates Digests (cryptographic hashes) for Tagged objects. A Digest is computed relative to a digest algorithm. TaggedConst determines how the object classes are rendered as integer tags and the algorithm determines the cryptographic hash function that is used to compute the digest. The object data is rendered using Xdr.


Field Summary
protected  java.security.MessageDigest md
           
 
Constructor Summary
DigestFactory()
           
 
Method Summary
abstract  Digest digest()
           
 Digest digest(TaggedIF tobj)
           
 java.lang.String getAlgorithm()
           
 int getDigestLength()
           
static DigestFactory newFactory()
           
static DigestFactory newFactory(java.lang.String alg)
           
 void reset()
           
 void update(TaggedIF obj)
           
 void xdrEncodeInt(int n)
          Encodes (aka "serializes") a "XDR int" value and writes it down a XDR stream.
 void xdrEncodeOpaque(byte[] buf, int offset, int len)
          Encodes (aka "serializes") a XDR opaque value, which is represented by a vector of byte values, and starts at offset with a length of length.
 
Methods inherited from class edu.berkeley.psi.tagged.api.TaggedEncodingStream
put
 
Methods inherited from class org.acplt.oncrpc.XdrEncodingStream
beginEncoding, close, endEncoding, getCharacterEncoding, setCharacterEncoding, xdrEncodeBoolean, xdrEncodeBooleanFixedVector, xdrEncodeBooleanVector, xdrEncodeByte, xdrEncodeByteFixedVector, xdrEncodeByteVector, xdrEncodeDouble, xdrEncodeDoubleFixedVector, xdrEncodeDoubleVector, xdrEncodeDynamicOpaque, xdrEncodeFloat, xdrEncodeFloatFixedVector, xdrEncodeFloatVector, xdrEncodeIntFixedVector, xdrEncodeIntVector, xdrEncodeLong, xdrEncodeLongFixedVector, xdrEncodeLongVector, xdrEncodeOpaque, xdrEncodeOpaque, xdrEncodeShort, xdrEncodeShortFixedVector, xdrEncodeShortVector, xdrEncodeString, xdrEncodeStringFixedVector, xdrEncodeStringVector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

md

protected java.security.MessageDigest md
Constructor Detail

DigestFactory

public DigestFactory()
Method Detail

digest

public abstract Digest digest()

newFactory

public static final DigestFactory newFactory()
                                      throws java.security.NoSuchAlgorithmException
Throws:
java.security.NoSuchAlgorithmException

newFactory

public static DigestFactory newFactory(java.lang.String alg)
                                throws java.security.NoSuchAlgorithmException
Throws:
java.security.NoSuchAlgorithmException

update

public final void update(TaggedIF obj)
                  throws OncRpcException,
                         java.io.IOException,
                         TaggedException
Throws:
OncRpcException
java.io.IOException
TaggedException

digest

public final Digest digest(TaggedIF tobj)
                    throws OncRpcException,
                           java.io.IOException,
                           TaggedException
Throws:
OncRpcException
java.io.IOException
TaggedException

getAlgorithm

public final java.lang.String getAlgorithm()

getDigestLength

public final int getDigestLength()

reset

public final void reset()

xdrEncodeInt

public void xdrEncodeInt(int n)
                  throws OncRpcException,
                         java.io.IOException
Description copied from class: XdrEncodingStream
Encodes (aka "serializes") a "XDR int" value and writes it down a XDR stream. A XDR int is 32 bits wide -- the same width Java's "int" data type has. This method is one of the basic methods all other methods can rely on. Because it's so basic, derived classes have to implement it.

Specified by:
xdrEncodeInt in class XdrEncodingStream
Parameters:
n - The int value to be encoded.
Throws:
OncRpcException - if an ONC/RPC error occurs.
java.io.IOException - if an I/O error occurs.

xdrEncodeOpaque

public void xdrEncodeOpaque(byte[] buf,
                            int offset,
                            int len)
                     throws OncRpcException,
                            java.io.IOException
Description copied from class: XdrEncodingStream
Encodes (aka "serializes") a XDR opaque value, which is represented by a vector of byte values, and starts at offset with a length of length. Only the opaque value is encoded, but no length indication is preceeding the opaque value, so the receiver has to know how long the opaque value will be. The encoded data is always padded to be a multiple of four. If the given length is not a multiple of four, zero bytes will be used for padding.

Derived classes must ensure that the proper semantic is maintained.

Specified by:
xdrEncodeOpaque in class XdrEncodingStream
Parameters:
buf - The opaque value to be encoded in the form of a series of bytes.
offset - Start offset in the data.
len - the number of bytes to encode.
Throws:
OncRpcException - if an ONC/RPC error occurs.
java.io.IOException - if an I/O error occurs.