org.eclipse.webdav.internal.authentication
Class DigestOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by org.eclipse.webdav.internal.authentication.DigestOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class DigestOutputStream
extends FilterOutputStream

An OutputStream that filters its data through a MessageDigest to compute a hash value over the data.


Field Summary
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
DigestOutputStream(OutputStream out, String algorithm)
          Creates a new DigestOutputStream that filters its data through a MessageDigest that hashes its input using the given algorithm.
DigestOutputStream(String algorithm)
          Creates a new DigestOutputStream that filters its data through a MessageDigest that hashes its input using the given algorithm.
 
Method Summary
 byte[] digest()
          Completes the hash computation and resets the digest.
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.io.FilterOutputStream
close, flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DigestOutputStream

public DigestOutputStream(OutputStream out,
                          String algorithm)
                   throws NoSuchAlgorithmException
Creates a new DigestOutputStream that filters its data through a MessageDigest that hashes its input using the given algorithm.

Parameters:
out - the data is also written to the given output stream
algorithm - a hashing algorithm, for example: "MD5"
Throws:
NoSuchAlgorithmException

DigestOutputStream

public DigestOutputStream(String algorithm)
                   throws NoSuchAlgorithmException
Creates a new DigestOutputStream that filters its data through a MessageDigest that hashes its input using the given algorithm.

Parameters:
algorithm - a hashing algorithm, for example: "MD5"
Throws:
NoSuchAlgorithmException
Method Detail

digest

public byte[] digest()
Completes the hash computation and resets the digest.


write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Overrides:
write in class FilterOutputStream
Throws:
IOException
See Also:
OutputStream.write(byte[], int, int)

write

public void write(int b)
           throws IOException
Overrides:
write in class FilterOutputStream
Throws:
IOException
See Also:
OutputStream.write(int)


Copyright © 2001-2014 JBoss by Red Hat. All Rights Reserved.