import java.io.IOException;
import java.io.InputStreamReader;
+import java.util.HashMap;
import javax.servlet.ServletException;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.cacert.gigi.database.DatabaseConnection;
+import org.cacert.gigi.database.DatabaseConnection.Link;
+
public class GigiAPI extends HttpServlet {
+ private static final long serialVersionUID = 659963677032635817L;
+
+ HashMap<String, APIPoint> api = new HashMap<>();
+
+ public GigiAPI() {
+ api.put(CreateCertificate.PATH, new CreateCertificate());
+ api.put(RevokeCertificate.PATH, new RevokeCertificate());
+ api.put(CATSImport.PATH, new CATSImport());
+ api.put(CATSResolve.PATH, new CATSResolve());
+ }
+
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String pi = req.getPathInfo();
strB.append(buffer, 0, len);
}
System.out.println(strB);
+ return;
+ }
+
+ APIPoint p = api.get(pi);
+ try (Link l = DatabaseConnection.newLink(false)) {
+ if (p != null) {
+ p.process(req, resp);
+ }
+ } catch (InterruptedException e) {
+ throw new Error(e);
}
}
}