javax.swing.ProgressMonitorInputStream Java Examples

The following examples show how to use javax.swing.ProgressMonitorInputStream. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProvingKeyFetcher.java    From zencash-swing-wallet-ui with MIT License 6 votes vote down vote up
private static boolean checkSHA256(File provingKey, Component parent) throws IOException {
    MessageDigest sha256;
    try {
        sha256 = MessageDigest.getInstance("SHA-256");
    } catch (NoSuchAlgorithmException impossible) {
        throw new IOException(impossible);
    }
    try (InputStream is = new BufferedInputStream(new FileInputStream(provingKey))) {
        ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(parent,
                LanguageUtil.instance().getString("proving.key.fetcher.option.pane.verify.progress.monitor.text"),
                is);
        pmis.getProgressMonitor().setMaximum(PROVING_KEY_SIZE);
        pmis.getProgressMonitor().setMillisToPopup(10);
        DigestInputStream dis = new DigestInputStream(pmis, sha256);
        byte [] temp = new byte[0x1 << 13];
        while(dis.read(temp) >= 0);
        byte [] digest = sha256.digest();

        return SHA256.equalsIgnoreCase(Util.bytesToHex(digest));
    }
}
 
Example #2
Source File: ProvingKeyFetcher.java    From zencash-swing-wallet-ui with MIT License 6 votes vote down vote up
private static boolean checkSHA256SG(File sproutGroth, Component parent) throws IOException {
    MessageDigest sha256;
    try {
        sha256 = MessageDigest.getInstance("SHA-256");
    } catch (NoSuchAlgorithmException impossible) {
        throw new IOException(impossible);
    }
    try (InputStream is = new BufferedInputStream(new FileInputStream(sproutGroth))) {
        ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(parent,
                LanguageUtil.instance().getString("sprout.groth.fetcher.option.pane.verify.progress.monitor.text"),
                is);
        pmis.getProgressMonitor().setMaximum(SPROUT_GROTH_SIZE);
        pmis.getProgressMonitor().setMillisToPopup(10);
        DigestInputStream dis = new DigestInputStream(pmis, sha256);
        byte [] temp = new byte[0x1 << 13];
        while(dis.read(temp) >= 0);
        byte [] digest = sha256.digest();
        
        return SHA256SG.equalsIgnoreCase(Util.bytesToHex(digest));
    }
}
 
Example #3
Source File: ProvingKeyFetcher.java    From zencash-swing-wallet-ui with MIT License 6 votes vote down vote up
private static boolean checkSHA256SS(File saplingSpend, Component parent) throws IOException {
    MessageDigest sha256;
    try {
        sha256 = MessageDigest.getInstance("SHA-256");
    } catch (NoSuchAlgorithmException impossible) {
        throw new IOException(impossible);
    }
    try (InputStream is = new BufferedInputStream(new FileInputStream(saplingSpend))) {
        ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(parent,
                LanguageUtil.instance().getString("sapling.spend.fetcher.option.pane.verify.progress.monitor.text"),
                is);
        pmis.getProgressMonitor().setMaximum(SAPLING_SPEND_SIZE);
        pmis.getProgressMonitor().setMillisToPopup(10);
        DigestInputStream dis = new DigestInputStream(pmis, sha256);
        byte [] temp = new byte[0x1 << 13];
        while(dis.read(temp) >= 0);
        byte [] digest = sha256.digest();

        return SHA256SS.equalsIgnoreCase(Util.bytesToHex(digest));
    }
}
 
Example #4
Source File: AbstractSwingGuiCallback.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public InputStream getProgressMonitorInputStream(InputStream in, int length, String msg) {
    ProgressMonitorInputStream pmin = new ProgressMonitorInputStream(parent, msg, in);
    ProgressMonitor pm = pmin.getProgressMonitor();

    if (length > 0) {
        pm.setMaximum(length);
    }
    return pmin;
}
 
Example #5
Source File: FileUtils.java    From swift-explorer with Apache License 2.0 5 votes vote down vote up
public static InputStream getInputStreamWithProgressMonitor(InputStream input, Component parentComponent, String message)
{
	if (input == null)
		return null ;
	Frame owner = null;
	if (parentComponent == null) 
		owner = SwingUtils.tryFindSuitableFrameOwner () ;
	InputStream in = new BufferedInputStream(
			new ProgressMonitorInputStream(
					(parentComponent == null) ? (owner) : (parentComponent),
					message, input));
	return in;
}