usersession.setUserStatus(admin,"ocsptest",UserDataLocal.STATUS_NEW);
usersession.setUserStatus(admin,"ocsptest",UserDataConstants.STATUS_NEW);
    public void test03OcspGood() throws Exception {        log.debug(">test03OcspGood()");        // find a CA (TestCA?) create a user and generate his cert        // send OCSP req to server and get good response        // change status of cert to bad status        // send OCSP req and get bad status        // (send crap message and get good error)        // Make user that we know...        boolean userExists = false;        try {            usersession.addUser(admin,"ocsptest","foo123","C=SE,O=AnaTom,CN=OCSPTest",null,"ocsptest@anatom.se",false,SecConst.EMPTY_ENDENTITYPROFILE,SecConst.CERTPROFILE_FIXED_ENDUSER,SecConst.USER_ENDUSER,SecConst.TOKEN_SOFT_PEM,0,caid);            log.debug("created user: ocsptest, foo123, C=SE, O=AnaTom, CN=OCSPTest");        } catch (RemoteException re) {            if (re.detail instanceof DuplicateKeyException) {                userExists = true;            }        } catch (DuplicateKeyException dke) {            userExists = true;        }        if (userExists) {            log.debug("User ocsptest already exists.");            usersession.setUserStatus(admin,"ocsptest",UserDataLocal.STATUS_NEW);            log.debug("Reset status to NEW");        }        // Generate certificate for the new user        KeyPair keys = genKeys();        // user that we know exists...        ocspTestCert = (X509Certificate) remote.createCertificate(admin, "ocsptest", "foo123", keys.getPublic());        assertNotNull("Misslyckades skapa cert", ocspTestCert);        // And an OCSP request        OCSPReqGenerator gen = new OCSPReqGenerator();        gen.addRequest(new CertificateID(CertificateID.HASH_SHA1, cacert, ocspTestCert.getSerialNumber()));        OCSPReq req = gen.generate();        // POST the OCSP request        WebConversation wc = new WebConversation();        ByteArrayInputStream bais = new ByteArrayInputStream(req.getEncoded());        PostMethodWebRequest request = new PostMethodWebRequest(httpReqPath + '/' + resourceOcsp, bais, "application/ocsp-request");        WebResponse webresponse = wc.getResponse(request);        assertEquals("Response code", 200, webresponse.getResponseCode());        assertEquals("Content-Type", "application/ocsp-response", webresponse.getContentType());        // Extract the response        // BUG in httpunit 1.5.4,webresponse.getInputStream converts binary to ascii on windows-platform.        InputStreamReader in = new InputStreamReader(webresponse.getInputStream());        ByteArrayOutputStream baos = new ByteArrayOutputStream();        // This works for small requests, and OCSP requests are small        int b = in.read();        while (b != -1) {            baos.write(b);            b = in.read();        }        baos.flush();        in.close();        byte[] respBytes = baos.toByteArray();        OCSPResp response = new OCSPResp(new ByteArrayInputStream(respBytes));        assertEquals("Response status not zero.", response.getStatus(), 0);        BasicOCSPResp brep = (BasicOCSPResp) response.getResponseObject();        X509Certificate[] chain = brep.getCerts("BC");        boolean verify = brep.verify(chain[0].getPublicKey(), "BC");        assertTrue("Response failed to verify.", verify);        RespData respData = brep.getResponseData();        SingleResp[] singleResps = respData.getResponses();        assertEquals("No of SingResps shoudl be 1.", singleResps.length, 1);        SingleResp singleResp = singleResps[0];        CertificateID certId = singleResp.getCertID();        assertEquals("Serno in response does not match serno in request.", certId.getSerialNumber(), ocspTestCert.getSerialNumber());        Object status = singleResp.getCertStatus();        assertEquals("Status is not null (good)", status, null);        log.debug("<test03OcspGood()");    }