FileDocCategorySizeDatePackage
DummyCA.javaAPI DocphoneME MR2 API (J2ME)2655Wed May 02 18:00:40 BST 2007None

DummyCA

public class DummyCA extends HttpServlet

Fields Summary
String
Status
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("<html><head><title>Last request result</title></head>");
        out.println("<body>" + Status + "</body></html>");
    
public voiddoPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)


       
                          

        InputStream is = request.getInputStream();

        byte[] data = new byte[request.getContentLength()];
        is.read(data, 0, data.length);

        Authority.init(this);
        Authority CA = new Authority();

        if (! CA.createCertificate(data)) {
            Status = CA.getStatus();
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                    Status);
            return;
        }

        Status = "<pre><code>" + CA.getStatus() + "</pre></code>";

        response.setContentType("application/octet-stream");
        OutputStream os = response.getOutputStream();

        data = CA.getPkiPath();
        os.write((byte) (data.length >> 8));
        os.write((byte) data.length);
        os.write(data);

        data = CA.getIssuerAndSerialNumber();
        os.write((byte) (data.length >> 8));
        os.write((byte) data.length);
        os.write(data);

        os.flush();