// Copyright 2000-2005 the Contributors, as shown in the revision logs. // Licensed under the Apache Public Source License 2.0 ("the License"). // You may not use this file except in compliance with the License. package org.ibex.net.ssl; import java.io.*; //import org.bouncycastle.asn1.*; //import org.bouncycastle.asn1.x509.*; public class GenCompactCAList { /* public static void main(String[] args) throws Exception { if(args.length < 2) throw new Exception("Usage: GenCAList format file(s)"); String format = args[0]; DER.EncodableVector vec = new DEREncodableVector(); for(int i=1;i>>(7*(7-j)))&0x7f); if(c=='\n') sb.append("\\n"); else if(c=='\r') sb.append("\\r"); else if(c=='\\') sb.append("\\\\"); else if(c=='"') sb.append("\\\""); else if(c >= 32 && c <= 126) sb.append(c); else sb.append("\\" + toOctal3(c)); } } System.out.println("package org.ibex.net.ssl;"); System.out.println("public final class RootCerts {"); System.out.println(" private final static String DATA = \"" + sb.toString() + "\";"); System.out.print( " static {\n" + " try {\n" + " org.ibex.net.SSL.addCompactCAKeys(new java.io.ByteArrayInputStream(unpack(DATA)));\n" + " } catch(Exception e) {\n" + " System.err.println(\"Error loading root CA keys: \" + e.getMessage());\n" + " }\n" + " }\n"); System.out.println(" public static void load() { }"); // force clinit System.out.print( " private static byte[] unpack(String s) {\n" + " int len = s.length();\n" + " if(len % 8 != 0) throw new IllegalArgumentException(\"not a multiple of 8\");\n" + " byte[] ret = new byte[(len / 8) * 7];\n" + " for(int i=0; i=0; j--) {\n" + " ret[base + j] = (byte)(l & 0xff);\n" + " l >>>= 8;\n" + " }\n" + " }\n" + " return ret;\n" + " }"); System.out.println("}"); } else { throw new Error("unknown format"); } } private final static String toOctal3(int n) { char[] buf = new char[3]; for(int i=2;i>=0;i--) { buf[i] = (char) ('0' + (n & 7)); n >>= 3; } return new String(buf); } */ }