X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Fapi%2FCATSImport.java;h=c5745d689de9171e0c3883d09a2e3c76c06ec043;hb=b4221f255f068ae7c47aecad62301e8ad12b5d22;hp=507a4a000f0e822134f38a400e16dc0576960385;hpb=50b8341607e23812216349ef37711e5a85d957c3;p=gigi.git diff --git a/src/org/cacert/gigi/api/CATSImport.java b/src/org/cacert/gigi/api/CATSImport.java index 507a4a00..c5745d68 100644 --- a/src/org/cacert/gigi/api/CATSImport.java +++ b/src/org/cacert/gigi/api/CATSImport.java @@ -13,7 +13,7 @@ import org.cacert.gigi.dbObjects.User; public class CATSImport extends APIPoint { - public static final String PATH = "/cats_import"; + public static final String PATH = "/cats/import"; @Override public void process(HttpServletRequest req, HttpServletResponse resp, CertificateOwner u) throws IOException { @@ -21,22 +21,28 @@ public class CATSImport extends APIPoint { resp.sendError(500, "Error, invalid cert"); return; } - if ( !"CAcert".equals(((Organisation) u).getName())) { + if ( !((Organisation) u).isSelfOrganisation()) { resp.sendError(500, "Error, invalid cert"); return; } - String target = req.getParameter("serial"); + String target = req.getParameter("mid"); String testType = req.getParameter("variant"); String date = req.getParameter("date"); if (target == null || testType == null || date == null) { - resp.sendError(500, "Error, requires serial, variant and date"); + resp.sendError(500, "Error, requires mid, variant and date"); return; } - // TODO is "byEnabledSerial" desired? - CertificateOwner o = CertificateOwner.getByEnabledSerial(target); + int id; + try { + id = Integer.parseInt(target); + } catch (NumberFormatException e) { + resp.sendError(500, "Error, requires mid to be integer."); + return; + } + CertificateOwner o = CertificateOwner.getById(id); if ( !(o instanceof User)) { - resp.sendError(500, "Error, requires valid serial"); + resp.sendError(500, "Error, requires valid userid"); return; } System.out.println("CATS: " + target + ": " + testType);