Class FixityCheckChannel

    • Constructor Detail

      • FixityCheckChannel

        public FixityCheckChannel​(ByteChannel delegate,
                                  DigestAlgorithm digestAlgorithm,
                                  String expectedDigestValue)
        Constructs a new FixityCheckChannel
        Parameters:
        delegate - the channel to wrap
        digestAlgorithm - the digest algorithm to use
        expectedDigestValue - the expected digest value
      • FixityCheckChannel

        public FixityCheckChannel​(ByteChannel delegate,
                                  String digestAlgorithm,
                                  String expectedDigestValue)
        Constructs a new FixityCheckChannel
        Parameters:
        delegate - the channel to wrap
        digestAlgorithm - the digest algorithm to use
        expectedDigestValue - the expected digest value
    • Method Detail

      • checkFixity

        public void checkFixity()
        Performs a fixity check and throws an exception if the check fails. This should only be called after the entire contents of the stream has been read.

        If the check is disabled, nothing happens

        Throws:
        FixityCheckException - when the actual digest value does not match the expected value
      • getExpectedDigestValue

        public String getExpectedDigestValue()
        Returns:
        the expected digest value
      • enableFixityCheck

        public FixityCheckChannel enableFixityCheck​(boolean enabled)
        By default fixity checking is enabled. Use this method to disable it, and prevent needless digest computation
        Parameters:
        enabled - if fixity should be checked
        Returns:
        this stream
      • isOpen

        public boolean isOpen()
        Specified by:
        isOpen in interface Channel