package org.bouncycastle.ocsp;
import java.io.*;
import org.bouncycastle.asn1.*;
import org.bouncycastle.asn1.ocsp.*;
public class OCSPRespGenerator
{
public static final int SUCCESSFUL = 0;
public static final int MALFORMED_REQUEST = 1;
public static final int INTERNAL_ERROR = 2;
public static final int TRY_LATER = 3;
public static final int SIG_REQUIRED = 5;
public static final int UNAUTHORIZED = 6;
public OCSPResp generate(
int status,
Object response)
throws OCSPException
{
if (response == null)
{
return new OCSPResp(new OCSPResponse(new OCSPResponseStatus(status),null));
}
if (response instanceof BasicOCSPResp)
{
BasicOCSPResp r = (BasicOCSPResp)response;
ASN1OctetString octs;
try
{
octs = new DEROctetString(r.getEncoded());
}
catch (IOException e)
{
throw new OCSPException("can't encode object.", e);
}
ResponseBytes rb = new ResponseBytes(
OCSPObjectIdentifiers.id_pkix_ocsp_basic, octs);
return new OCSPResp(new OCSPResponse(
new OCSPResponseStatus(status), rb));
}
throw new OCSPException("unknown response object");
}
}