Examples of BoundedInputStream


Examples of org.apache.commons.io.input.BoundedInputStream

      final long streamlength = Long.parseLong(cl);
      fileLength = startPos + streamlength;

      // Java has a bug with >2GB request streams.  It won't bounds check
      // the reads so the transfer blocks until the server times out
      in = new BoundedInputStream(in, streamlength);
    }

    return in;
  }
View Full Code Here

Examples of org.apache.jackrabbit.mk.remote.util.BoundedInputStream

                }
            }
            if (contentLength == -1) {
                contentLength = 0;
            }
            reqIn = new BoundedInputStream(socketIn, contentLength);
        }
       
        String connectionState = headers.get("Connection");
        if ("close".equalsIgnoreCase(connectionState)) {
            connectionClosed = true;
View Full Code Here

Examples of org.apache.jackrabbit.mk.remote.util.BoundedInputStream

            } else {
                int contentLength = getContentLength();
                if (contentLength == -1) {
                    contentLength = 0;
                }
                reqIn = new BoundedInputStream(in, contentLength);
            }
        }
        return reqIn;
    }
View Full Code Here

Examples of org.apache.jackrabbit.mk.remote.util.BoundedInputStream

            } else {
                int contentLength = getContentLength();
                if (contentLength == -1) {
                    contentLength = 0;
                }
                reqIn = new BoundedInputStream(in, contentLength);
            }
        }
        return reqIn;
    }
View Full Code Here

Examples of org.apache.jackrabbit.mk.remote.util.BoundedInputStream

                }
            }
            if (contentLength == -1) {
                contentLength = 0;
            }
            reqIn = new BoundedInputStream(socketIn, contentLength);
        }
       
        String connectionState = headers.get("Connection");
        if ("close".equalsIgnoreCase(connectionState)) {
            connectionClosed = true;
View Full Code Here

Examples of org.apache.jackrabbit.mk.util.BoundedInputStream

            } else {
                int contentLength = getContentLength();
                if (contentLength == -1) {
                    contentLength = 0;
                }
                reqIn = new BoundedInputStream(in, contentLength);
            }
        }
        return reqIn;
    }
View Full Code Here

Examples of org.apache.jackrabbit.mk.util.BoundedInputStream

                }
            }
            if (contentLength == -1) {
                contentLength = 0;
            }
            reqIn = new BoundedInputStream(socketIn, contentLength);
        }
       
        String connectionState = headers.get("Connection");
        if ("close".equalsIgnoreCase(connectionState)) {
            connectionClosed = true;
View Full Code Here

Examples of org.apache.poi.util.BoundedInputStream

    public InputStream getData() {
        if (isCompressed()) {
            int size = LittleEndian.getInt(_data);

            InputStream compressedStream = new ByteArrayInputStream(_data, 4, _data.length);
            return new BoundedInputStream(new InflaterInputStream(compressedStream), size);
        } else {
            return new ByteArrayInputStream(_data, 0, _data.length);
        }
    }
View Full Code Here

Examples of org.apache.poi.util.BoundedInputStream

    public InputStream getDataStream(DirectoryNode dir) throws IOException {
        DocumentInputStream dis = dir.createDocumentInputStream("EncryptedPackage");

        _length = dis.readLong();

        return new BoundedInputStream(new CipherInputStream(dis, getCipher(getSecretKey())), _length);
    }
View Full Code Here

Examples of org.apache.poi.util.BoundedInputStream

        long decPackLenExpected = decExpected.getLength();
        assertEquals(decPackLenExpected, payloadExpected.length);

        is = nfs.getRoot().createDocumentInputStream("EncryptedPackage");
        is = new BoundedInputStream(is, is.available()-16); // ignore padding block
        byte encPackExpected[] = IOUtils.toByteArray(is);
        is.close();
       
        // listDir(nfs.getRoot(), "orig", "");
       
        nfs.close();

        // check that same verifier/salt lead to same hashes
        byte verifierSaltExpected[] = infoExpected.getVerifier().getSalt();
        byte verifierExpected[] = decExpected.getVerifier();
        byte keySalt[] = infoExpected.getHeader().getKeySalt();
        byte keySpec[] = decExpected.getSecretKey().getEncoded();
        byte integritySalt[] = decExpected.getIntegrityHmacKey();
        // the hmacs of the file always differ, as we use PKCS5-padding to pad the bytes
        // whereas office just uses random bytes
        // byte integrityHash[] = d.getIntegrityHmacValue();
       
        POIFSFileSystem fs = new POIFSFileSystem();
        EncryptionInfo infoActual = new EncryptionInfo(
              fs, EncryptionMode.agile
            , infoExpected.getVerifier().getCipherAlgorithm()
            , infoExpected.getVerifier().getHashAlgorithm()
            , infoExpected.getHeader().getKeySize()
            , infoExpected.getHeader().getBlockSize()
            , infoExpected.getVerifier().getChainingMode()
        );       

        Encryptor e = Encryptor.getInstance(infoActual);
        e.confirmPassword(pass, keySpec, keySalt, verifierExpected, verifierSaltExpected, integritySalt);
   
        OutputStream os = e.getDataStream(fs);
        IOUtils.copy(new ByteArrayInputStream(payloadExpected), os);
        os.close();

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        fs.writeFilesystem(bos);
       
        nfs = new NPOIFSFileSystem(new ByteArrayInputStream(bos.toByteArray()));
        infoActual = new EncryptionInfo(nfs.getRoot());
        Decryptor decActual = Decryptor.getInstance(infoActual);
        passed = decActual.verifyPassword(pass);       
        assertTrue("Unable to process: document is encrypted", passed);
       
        // extract the payload
        is = decActual.getDataStream(nfs);
        byte payloadActual[] = IOUtils.toByteArray(is);
        is.close();
       
        long decPackLenActual = decActual.getLength();
       
        is = nfs.getRoot().createDocumentInputStream("EncryptedPackage");
        is = new BoundedInputStream(is, is.available()-16); // ignore padding block
        byte encPackActual[] = IOUtils.toByteArray(is);
        is.close();
       
        // listDir(nfs.getRoot(), "copy", "");
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.