// We're screwed if this thing has more than one CRL, because
// the "indeOf( (char) 65533 )" below isn't going to work.
public static List getCRLs(X509Extension cert) {
        // What follows is a poor man's CRL extractor, for those lacking
        // a BouncyCastle "bcprov.jar" in their classpath.
        // It's a very basic state-machine:  look for a standard URL scheme
        // (such as http), and then start looking for a terminator.  After
        // running hexdump a few times on these things, it looks to me like
        // the UTF-8 value "65533" seems to happen near where these things
        // terminate.  (Of course this stuff is ASN.1 and not UTF-8, but
        // I happen to like some of the functions available to the String
        // object).    - juliusdavies@cucbc.com, May 10th, 2006
        byte[] bytes = cert.getExtensionValue(CRL_EXTENSION);
        LinkedList httpCRLS = new LinkedList();
        LinkedList ftpCRLS = new LinkedList();
        LinkedList otherCRLS = new LinkedList();
        if (bytes == null) {
            // just return empty list
            return httpCRLS;
        } else {
            String s;
            try {
                s = new String(bytes, "UTF-8");
            }
            catch (UnsupportedEncodingException uee) {
                // We're screwed if this thing has more than one CRL, because
                // the "indeOf( (char) 65533 )" below isn't going to work.
                s = new String(bytes);
            }
            int pos = 0;
            while (pos >= 0) {
                int x = -1, y;
                int[] indexes = new int[4];
                indexes[0] = s.indexOf("http", pos);
                indexes[1] = s.indexOf("ldap", pos);
                indexes[2] = s.indexOf("file", pos);
                indexes[3] = s.indexOf("ftp", pos);
                Arrays.sort(indexes);
                for (int i = 0; i < indexes.length; i++) {
                    if (indexes[i] >= 0) {
                        x = indexes[i];
                        break;
                    }
                }
                if (x >= 0) {
                    y = s.indexOf((char) 65533, x);
                    String crl = y > x ? s.substring(x, y - 1) : s.substring(x);
                    if (y > x && crl.endsWith("0")) {
                        crl = crl.substring(0, crl.length() - 1);
                    }
                    String crlTest = crl.trim().toLowerCase();
                    if (crlTest.startsWith("http")) {
                        httpCRLS.add(crl);
                    } else if (crlTest.startsWith("ftp")) {
                        ftpCRLS.add(crl);
                    } else {
                        otherCRLS.add(crl);
                    }
                    pos = y;
                } else {
                    pos = -1;
                }
            }
        }
        httpCRLS.addAll(ftpCRLS);
        httpCRLS.addAll(otherCRLS);
        return httpCRLS;
    }
}
catch (UnsupportedEncodingException uee) {
// We're screwed if this thing has more than one CRL, because
// the "indeOf( (char) 65533 )" below isn't going to work.
s = new String(bytes);
}
LinkedList otherCRLS = new LinkedList();
if (bytes == null) {
// just return empty list
return httpCRLS;
} else {
String s;
try {
s = new String(bytes, "UTF-8");
}
catch (UnsupportedEncodingException uee) {
// We're screwed if this thing has more than one CRL, because
// the "indeOf( (char) 65533 )" below isn't going to work.
s = new String(bytes);
}
int pos = 0;
while (pos >= 0) {
int x = -1, y;
int[] indexes = new int[4];
indexes[0] = s.indexOf("http", pos);
indexes[1] = s.indexOf("ldap", pos);
indexes[2] = s.indexOf("file", pos);
indexes[3] = s.indexOf("ftp", pos);
// It's a very basic state-machine: look for a standard URL scheme
// (such as http), and then start looking for a terminator. After
// running hexdump a few times on these things, it looks to me like
// the UTF-8 value "65533" seems to happen near where these things
// terminate. (Of course this stuff is ASN.1 and not UTF-8, but
// I happen to like some of the functions available to the String
// object). - juliusdavies@cucbc.com, May 10th, 2006
byte[] bytes = cert.getExtensionValue(CRL_EXTENSION);
LinkedList httpCRLS = new LinkedList();
LinkedList ftpCRLS = new LinkedList();
LinkedList otherCRLS = new LinkedList();
if (bytes == null) {
// just return empty list
return httpCRLS;
} else {
String s;
try {
s = new String(bytes, "UTF-8");
}
catch (UnsupportedEncodingException uee) {
// We're screwed if this thing has more than one CRL, because
// the "indeOf( (char) 65533 )" below isn't going to work.
s = new String(bytes);
}
int pos = 0;
while (pos >= 0) {
int x = -1, y;
int[] indexes = new int[4];
indexes[0] = s.indexOf("http", pos);
indexes[1] = s.indexOf("ldap", pos);
indexes[2] = s.indexOf("file", pos);
indexes[3] = s.indexOf("ftp", pos);
Arrays.sort(indexes);
for (int i = 0; i < indexes.length; i++) {
if (indexes[i] >= 0) {
x = indexes[i];
break;
}
}
if (x >= 0) {
y = s.indexOf((char) 65533, x);
String crl = y > x ? s.substring(x, y - 1) : s.substring(x);