Package java.security

Examples of java.security.DigestInputStream


    URLConnection connection = SecurityUtil.openSecureHttpConnection(url);
    InputStream stream = connection.getInputStream();
    MessageDigest digester = null;
    if (getChecksum) {
      digester = MD5Hash.getDigester();
      stream = new DigestInputStream(stream, digester);
    }
    FileOutputStream[] output = null;

    try {
      if (localPath != null) {
View Full Code Here


        for (final File file : files) {
            if (!file.exists()) {
                continue;
            }

            DigestInputStream is = null;
            try {
                is = new DigestInputStream(new FileInputStream(file), digest);
                IO.copy(is, new NoopOutputStream()); // read the stream
            } catch (final IOException e) {
                // no-op: shouldn't occur here
            } finally {
                IO.close(is);
View Full Code Here

                log.error(msg);
                throw new DataStoreException(msg);
            }
            temporaryInUse.add(tempId);
            MessageDigest digest = getDigest();
            DigestInputStream dIn = new DigestInputStream(stream, digest);
            TrackingInputStream in = new TrackingInputStream(dIn);
            StreamWrapper wrapper;
            if (STORE_SIZE_MINUS_ONE.equals(storeStream)) {
                wrapper = new StreamWrapper(in, -1);
            } else if (STORE_SIZE_MAX.equals(storeStream)) {
View Full Code Here

      //
      // Load in bits
      //
      MessageDigest digester = MD5Hash.getDigester();
      DigestInputStream fin = new DigestInputStream(
           new FileInputStream(curFile), digester);

      DataInputStream in = new DataInputStream(fin);
      try {
        // read image version: first appeared in version -1
View Full Code Here

                File src = (File) e.nextElement();
                if (!isCondition) {
                    log("Calculating " + algorithm + " checksum for " + src, Project.MSG_VERBOSE);
                }
                fis = new FileInputStream(src);
                DigestInputStream dis = new DigestInputStream(fis,
                                                              messageDigest);
                while (dis.read(buf, 0, readBufferSize) != -1) {
                    // Empty statement
                }
                dis.close();
                fis.close();
                fis = null;
                byte[] fileDigest = messageDigest.digest ();
                if (totalproperty != null) {
                    allDigests.put(src, fileDigest);
View Full Code Here

            byte[] buf = new byte[readBufferSize];
            try {
                messageDigest.reset();
                fis = new FileInputStream(file);
                DigestInputStream dis = new DigestInputStream(fis,
                                                              messageDigest);
                while (dis.read(buf, 0, readBufferSize) != -1) {
                    // do nothing
                }
                dis.close();
                fis.close();
                fis = null;
                byte[] fileDigest = messageDigest.digest();
                StringBuffer checksumSb = new StringBuffer();
                for (int i = 0; i < fileDigest.length; i++) {
View Full Code Here

        }

        InputStream is = open(connection);

        if (result != null)
            is = new DigestInputStream(is, result);

        FileOutputStream fos = new FileOutputStream(_dest);
        OutputStream os = new BufferedOutputStream(fos);

        byte[] buffer = new byte[100 * 1024];
 
View Full Code Here

     * @throws NoSuchAlgorithmException
     */
    private String md5(InputStream is) throws IOException,
            NoSuchAlgorithmException {
        MessageDigest digest = MessageDigest.getInstance("MD5");
        DigestInputStream dis = new DigestInputStream(is, digest);

        byte[] buffer = new byte[1024];

        int read = dis.read(buffer);
        while (read > -1) {
            read = dis.read(buffer);
        }

        return new String(encodeHex(dis.getMessageDigest().digest()));
    }
View Full Code Here

     *
     * @throws NoSuchAlgorithmException
     *             If the running JVM doesn't support MD5 MessageDigests.
     */
    public ChecksumValidatingInputStream(InputStream in, byte[] expectedChecksum, String sourceObject) throws NoSuchAlgorithmException {
        super(new DigestInputStream(in, MessageDigest.getInstance("MD5")));
        this.expectedChecksum = expectedChecksum;
        this.sourceObject = sourceObject;
        this.digestInputStream = (DigestInputStream)super.in;
    }
View Full Code Here

     * @throws NoSuchAlgorithmException
     */
    private String md5(InputStream is) throws IOException,
            NoSuchAlgorithmException {
        MessageDigest digest = MessageDigest.getInstance("MD5");
        DigestInputStream dis = new DigestInputStream(is, digest);

        byte[] buffer = new byte[1024];

        int read = dis.read(buffer);
        while (read > -1) {
            read = dis.read(buffer);
        }

        return new String(encodeHex(dis.getMessageDigest().digest()));
    }
View Full Code Here

TOP

Related Classes of java.security.DigestInputStream

Copyright © 2018 www.massapicom. 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.