X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Fapi%2FAPIPoint.java;fp=src%2Forg%2Fcacert%2Fgigi%2Fapi%2FAPIPoint.java;h=0000000000000000000000000000000000000000;hp=72a555b1539a5a89ba51f2bb564c9d1453877f68;hb=bccd4cc0dba0f89aa045b113bac46eb8cc1dab4e;hpb=c9ed09f0007fc2c813815be927a5a24b23dab83c diff --git a/src/org/cacert/gigi/api/APIPoint.java b/src/org/cacert/gigi/api/APIPoint.java deleted file mode 100644 index 72a555b1..00000000 --- a/src/org/cacert/gigi/api/APIPoint.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.cacert.gigi.api; - -import java.io.IOException; -import java.security.cert.X509Certificate; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.cacert.gigi.dbObjects.Certificate; -import org.cacert.gigi.dbObjects.CertificateOwner; -import org.cacert.gigi.dbObjects.User; -import org.cacert.gigi.pages.LoginPage; - -public abstract class APIPoint { - - public void process(HttpServletRequest req, HttpServletResponse resp) throws IOException { - X509Certificate cert = LoginPage.getCertificateFromRequest(req); - if (cert == null) { - resp.sendError(403, "Error, cert authing required. No cert found."); - return; - } - String serial = LoginPage.extractSerialFormCert(cert); - Certificate clientCert = Certificate.getBySerial(serial); - CertificateOwner u = CertificateOwner.getByEnabledSerial(serial); - if (u == null || clientCert == null) { - resp.sendError(403, "Error, cert authing required. Serial not found: " + serial); - return; - } - if (req.getMethod().equals("GET")) { - if (u instanceof User) { - processGet(req, resp, (User) u); - return; - } else { - resp.sendError(500, "Error, requires a User certificate."); - return; - } - } - - if ( !req.getMethod().equals("POST")) { - resp.sendError(500, "Error, POST required."); - return; - } - if (req.getQueryString() != null) { - resp.sendError(500, "Error, no query String allowed."); - return; - } - process(req, resp, u, clientCert); - } - - protected void process(HttpServletRequest req, HttpServletResponse resp, CertificateOwner u, Certificate clientCert) throws IOException { - process(req, resp, u); - } - - protected void process(HttpServletRequest req, HttpServletResponse resp, CertificateOwner u) throws IOException { - if (u instanceof User) { - process(req, resp, (User) u); - } else { - resp.sendError(500, "Error, requires a User certificate."); - return; - } - } - - protected void process(HttpServletRequest req, HttpServletResponse resp, User u) throws IOException { - resp.sendError(500, "Error, Post not allowed."); - } - - protected void processGet(HttpServletRequest req, HttpServletResponse resp, User u) throws IOException { - resp.sendError(500, "Error, Get not allowed."); - } -}