This is necessary to support socket activation (Java only supports a
single "inherited channel", which must be file descriptor 0), and also
makes it simpler to run gigi when the configuration is just a regular
file.
It also simplifies the DevelLauncher a bit.
Change-Id: I8bf03317ea549bd17f5b61e50808f48314a06803
package org.cacert.gigi;
import java.io.ByteArrayInputStream;
package org.cacert.gigi;
import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
public static void main(String[] args) throws Exception {
System.setProperty("jdk.tls.ephemeralDHKeySize", "4096");
public static void main(String[] args) throws Exception {
System.setProperty("jdk.tls.ephemeralDHKeySize", "4096");
+ InputStream in;
+ if (args.length >= 1) {
+ in = new FileInputStream(new File(args[0]));
+ } else {
+ in = System.in;
+ }
+ new Launcher().boot(in);
}
Server s;
GigiConfig conf;
}
Server s;
GigiConfig conf;
- public synchronized void boot() throws Exception {
+ public synchronized void boot(InputStream in) throws Exception {
Locale.setDefault(Locale.ENGLISH);
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
HttpURLConnection.setFollowRedirects(false);
Locale.setDefault(Locale.ENGLISH);
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
HttpURLConnection.setFollowRedirects(false);
- conf = GigiConfig.parse(System.in);
+ conf = GigiConfig.parse(in);
ServerConstants.init(conf.getMainProps());
initEmails(conf);
ServerConstants.init(conf.getMainProps());
initEmails(conf);
DevelLauncher.writeGigiConfig(dos, "changeit".getBytes("UTF-8"), "changeit".getBytes("UTF-8"), mainProps, cacerts, keystore);
dos.flush();
DevelLauncher.writeGigiConfig(dos, "changeit".getBytes("UTF-8"), "changeit".getBytes("UTF-8"), mainProps, cacerts, keystore);
dos.flush();
- InputStream oldin = System.in;
- System.setIn(new ByteArrayInputStream(chunkConfig.toByteArray()));
- new Launcher().boot();
+ new Launcher().boot(new ByteArrayInputStream(chunkConfig.toByteArray()));
addDevelPage(true);
new Thread("ticket awaiter") {
addDevelPage(true);
new Thread("ticket awaiter") {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in, "UTF-8"));
System.out.println("Cacert-gigi system sucessfully started.");
System.out.println("Press enter to shutdown.");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in, "UTF-8"));
System.out.println("Cacert-gigi system sucessfully started.");
System.out.println("Press enter to shutdown.");