< prev index next >

src/java.base/share/classes/java/security/DigestInputStream.java

Print this page




  42  * {@link #read() read} methods.
  43  *
  44  * <p>It is possible to turn this stream on or off (see
  45  * {@link #on(boolean) on}). When it is on, a call to one of the
  46  * {@code read} methods
  47  * results in an update on the message digest.  But when it is off,
  48  * the message digest is not updated. The default is for the stream
  49  * to be on.
  50  *
  51  * <p>Note that digest objects can compute only one digest (see
  52  * {@link MessageDigest}),
  53  * so that in order to compute intermediate digests, a caller should
  54  * retain a handle onto the digest object, and clone it for each
  55  * digest to be computed, leaving the original digest untouched.
  56  *
  57  * @see MessageDigest
  58  *
  59  * @see DigestOutputStream
  60  *
  61  * @author Benjamin Renaud

  62  */
  63 
  64 public class DigestInputStream extends FilterInputStream {
  65 
  66     /* NOTE: This should be made a generic UpdaterInputStream */
  67 
  68     /* Are we on or off? */
  69     private boolean on = true;
  70 
  71     /**
  72      * The message digest associated with this stream.
  73      */
  74     protected MessageDigest digest;
  75 
  76     /**
  77      * Creates a digest input stream, using the specified input stream
  78      * and message digest.
  79      *
  80      * @param stream the input stream.
  81      *




  42  * {@link #read() read} methods.
  43  *
  44  * <p>It is possible to turn this stream on or off (see
  45  * {@link #on(boolean) on}). When it is on, a call to one of the
  46  * {@code read} methods
  47  * results in an update on the message digest.  But when it is off,
  48  * the message digest is not updated. The default is for the stream
  49  * to be on.
  50  *
  51  * <p>Note that digest objects can compute only one digest (see
  52  * {@link MessageDigest}),
  53  * so that in order to compute intermediate digests, a caller should
  54  * retain a handle onto the digest object, and clone it for each
  55  * digest to be computed, leaving the original digest untouched.
  56  *
  57  * @see MessageDigest
  58  *
  59  * @see DigestOutputStream
  60  *
  61  * @author Benjamin Renaud
  62  * @since 1.2
  63  */
  64 
  65 public class DigestInputStream extends FilterInputStream {
  66 
  67     /* NOTE: This should be made a generic UpdaterInputStream */
  68 
  69     /* Are we on or off? */
  70     private boolean on = true;
  71 
  72     /**
  73      * The message digest associated with this stream.
  74      */
  75     protected MessageDigest digest;
  76 
  77     /**
  78      * Creates a digest input stream, using the specified input stream
  79      * and message digest.
  80      *
  81      * @param stream the input stream.
  82      *


< prev index next >