X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2FDevelLauncher.java;h=e83ae4145f3d47d955c5b087a9e23b27479eb882;hp=3a78d6286f8902af29099f6fe0d4e0216c65e228;hb=943d8e7ed0ea5a9d56e7e694a3cbd849c52bad16;hpb=05e8bb67c3407cbecbb528db16b1608d8534907e diff --git a/src/org/cacert/gigi/DevelLauncher.java b/src/org/cacert/gigi/DevelLauncher.java index 3a78d628..e83ae414 100644 --- a/src/org/cacert/gigi/DevelLauncher.java +++ b/src/org/cacert/gigi/DevelLauncher.java @@ -19,66 +19,66 @@ import org.kamranzafar.jtar.TarHeader; import org.kamranzafar.jtar.TarOutputStream; public class DevelLauncher { - public static final boolean DEVEL = true; - public static void main(String[] args) throws Exception { - Properties mainProps = new Properties(); - mainProps.load(new FileInputStream("config/gigi.properties")); - for (int i = 0; i < args.length; i++) { - if (args[i].equals("--port")) { - mainProps.setProperty("port", args[i + 1]); - } - i++; - } + public static final boolean DEVEL = true; - ByteArrayOutputStream chunkConfig = new ByteArrayOutputStream(); - DataOutputStream dos = new DataOutputStream(chunkConfig); - byte[] cacerts = Files.readAllBytes(Paths.get("config/cacerts.jks")); - byte[] keystore = Files.readAllBytes(Paths.get("config/keystore.pkcs12")); + public static void main(String[] args) throws Exception { + Properties mainProps = new Properties(); + mainProps.load(new FileInputStream("config/gigi.properties")); + for (int i = 0; i < args.length; i++) { + if (args[i].equals("--port")) { + mainProps.setProperty("port", args[i + 1]); + } + i++; + } - DevelLauncher.writeGigiConfig(dos, "changeit".getBytes(), "changeit".getBytes(), mainProps, cacerts, keystore); - dos.flush(); - InputStream oldin = System.in; - System.setIn(new ByteArrayInputStream(chunkConfig.toByteArray())); - Launcher.main(args); - System.setIn(oldin); - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - System.out.println("Cacert-gigi system sucessfully started."); - System.out.println("Press enter to shutdown."); - br.readLine(); - System.exit(0); - } + ByteArrayOutputStream chunkConfig = new ByteArrayOutputStream(); + DataOutputStream dos = new DataOutputStream(chunkConfig); + byte[] cacerts = Files.readAllBytes(Paths.get("config/cacerts.jks")); + byte[] keystore = Files.readAllBytes(Paths.get("config/keystore.pkcs12")); - public static void writeGigiConfig(OutputStream target, byte[] keystorepw, byte[] truststorepw, - Properties mainprop, byte[] cacerts, byte[] keystore) throws IOException { - TarOutputStream tos = new TarOutputStream(target); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - mainprop.store(baos, ""); + DevelLauncher.writeGigiConfig(dos, "changeit".getBytes(), "changeit".getBytes(), mainProps, cacerts, keystore); + dos.flush(); + InputStream oldin = System.in; + System.setIn(new ByteArrayInputStream(chunkConfig.toByteArray())); + Launcher.main(args); + System.setIn(oldin); + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + System.out.println("Cacert-gigi system sucessfully started."); + System.out.println("Press enter to shutdown."); + br.readLine(); + System.exit(0); + } - putTarEntry(baos.toByteArray(), tos, "gigi.properties"); - putTarEntry(keystorepw, tos, "keystorepw"); - putTarEntry(truststorepw, tos, "truststorepw"); - putTarEntry(keystore, tos, "keystore.pkcs12"); - putTarEntry(cacerts, tos, "cacerts.jks"); - tos.close(); + public static void writeGigiConfig(OutputStream target, byte[] keystorepw, byte[] truststorepw, Properties mainprop, byte[] cacerts, byte[] keystore) throws IOException { + TarOutputStream tos = new TarOutputStream(target); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + mainprop.store(baos, ""); - } + putTarEntry(baos.toByteArray(), tos, "gigi.properties"); + putTarEntry(keystorepw, tos, "keystorepw"); + putTarEntry(truststorepw, tos, "truststorepw"); + putTarEntry(keystore, tos, "keystore.pkcs12"); + putTarEntry(cacerts, tos, "cacerts.jks"); + tos.close(); - private static void putTarEntry(byte[] data, TarOutputStream tos, String name) throws IOException { - TarHeader th = new TarHeader(); - th.name = new StringBuffer(name); - th.size = data.length; - tos.putNextEntry(new TarEntry(th)); - tos.write(data); - } + } - public static void writeChunk(DataOutputStream dos, byte[] chunk) throws IOException { - dos.writeInt(chunk.length); - dos.write(chunk); - } + private static void putTarEntry(byte[] data, TarOutputStream tos, String name) throws IOException { + TarHeader th = new TarHeader(); + th.name = new StringBuffer(name); + th.size = data.length; + tos.putNextEntry(new TarEntry(th)); + tos.write(data); + } - public static void launch(Properties props, File cacerts, File keystore) throws IOException { - ByteArrayOutputStream config = new ByteArrayOutputStream(); - props.store(config, ""); - } + public static void writeChunk(DataOutputStream dos, byte[] chunk) throws IOException { + dos.writeInt(chunk.length); + dos.write(chunk); + } + + public static void launch(Properties props, File cacerts, File keystore) throws IOException { + ByteArrayOutputStream config = new ByteArrayOutputStream(); + props.store(config, ""); + } }