package qz.auth;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;

/**
 * Wrapper class for the Certificate Revocation List
 * Created by Steven on 2/4/2015. Package: qz.auth Project: qz-print
 */
public class CRL {
    /**
     * The URL to the QZ CRL. Should not be changed except for dev tests
     */
    public static final String CRL_URL = "http://hosted.kd8rho.net/crl-temp.txt";

    ArrayList<String> revokedHashes = new ArrayList<String>();


    public static CRL getQzCrl() throws IOException {
        ArrayList<String> httpResult = new ArrayList<String>();
        BufferedReader theReader = null;

        try {
            URL qzCRL = new URL(CRL_URL);
            String line;
            theReader = new BufferedReader(new InputStreamReader(qzCRL.openStream()));
            while((line = theReader.readLine()) != null) {
                //Ignore 0 length lines, more efficient memory usage.
                if (line.length() != 0) {
                    //Ignore comments
                    if (line.charAt(0) != '#') {
                        httpResult.add(line);
                    }
                }
            }

            CRL theNewCRL = new CRL();
            theNewCRL.revokedHashes = httpResult;
            return theNewCRL;
        }
        catch(MalformedURLException e) {
            e.printStackTrace();
        }
        finally {
            if (theReader != null) {
                try { theReader.close(); } catch(Exception ignore) {}
            }
        }

        return null;
    }

    public boolean isRevoked(String fingerprint)
    {
        return revokedHashes.contains(fingerprint);
    }
}

@@ -484,38 +484,28 @@
 p://
-hosted.kd8rho.net/crl-temp.txt
+crl.qzindustries.com
 %22;%0A%0A

Change CRL path to use qzindustries.com