public int readWrappedStream()

in encryption/src/main/java/org/apache/solr/encryption/crypto/DecryptingChannelInputStream.java [115:141]


  public int readWrappedStream(byte[] target, int offset, int length) throws IOException {
    assert offset >= 0 && length >= 0;
    assert offset + length <= target.length;
    int numDecrypted = 0;
    while (length > 0) {
      // Transfer decrypted bytes from outBuffer.
      int outRemaining = outSize - outPos;
      if (outRemaining > 0) {
        if (length <= outRemaining) {
          System.arraycopy(outBuffer, outPos, target, offset, length);
          outPos += length;
          numDecrypted += length;
          return numDecrypted;
        }
        System.arraycopy(outBuffer, outPos, target, offset, outRemaining);
        outPos += outRemaining;
        numDecrypted += outRemaining;
        offset += outRemaining;
        length -= outRemaining;
      }
      if (!readToFillBuffer(length)) {
        return numDecrypted == 0 ? -1 : numDecrypted;
      }
      decryptBuffer();
    }
    return numDecrypted;
  }