1 package org.cacert.gigi.api;
3 import java.io.IOException;
5 import javax.servlet.http.HttpServletRequest;
6 import javax.servlet.http.HttpServletResponse;
8 import org.cacert.gigi.dbObjects.CertificateOwner;
9 import org.cacert.gigi.dbObjects.Organisation;
10 import org.cacert.gigi.dbObjects.User;
12 public class CATSResolve extends APIPoint {
14 public static final String PATH = "/cats/resolve";
17 public void process(HttpServletRequest req, HttpServletResponse resp, CertificateOwner u) throws IOException {
18 if ( !(u instanceof Organisation)) {
19 resp.sendError(500, "Error, invalid cert");
22 if ( !((Organisation) u).isSelfOrganisation()) {
23 resp.sendError(500, "Error, invalid cert");
26 String target = req.getParameter("serial");
28 resp.sendError(500, "Error, requires a serial parameter");
32 CertificateOwner o = CertificateOwner.getByEnabledSerial(target.toLowerCase());
33 if ( !(o instanceof User)) {
34 resp.sendError(500, "Error, requires valid serial");
37 resp.setContentType("text/plain; charset=UTF-8");
38 resp.getWriter().print(o.getId());