use of org.xipki.qa.BenchmarkHttpClient in project xipki by xipki.
the class OcspBenchRequestor method init.
public void init(ResponseHandler responseHandler, String responderUrl, X509Cert issuerCert, RequestOptions requestOptions, int queueSize) throws OcspRequestorException, IOException, URISyntaxException {
notNull(issuerCert, "issuerCert");
notNull(responseHandler, "responseHandler");
this.requestOptions = notNull(requestOptions, "requestOptions");
this.issuerhashAlg = requestOptions.getHashAlgorithm();
this.issuerNameHash = new DEROctetString(issuerhashAlg.hash(issuerCert.getSubject().getEncoded()));
this.issuerKeyHash = new DEROctetString(issuerhashAlg.hash(issuerCert.getSubjectPublicKeyInfo().getPublicKeyData().getOctets()));
List<SignAlgo> prefSigAlgs = requestOptions.getPreferredSignatureAlgorithms();
if (prefSigAlgs == null || prefSigAlgs.size() == 0) {
this.extensions = null;
} else {
ASN1EncodableVector vec = new ASN1EncodableVector();
for (SignAlgo algId : prefSigAlgs) {
ASN1Sequence prefSigAlgObj = new DERSequence(algId.getAlgorithmIdentifier());
vec.add(prefSigAlgObj);
}
ASN1Sequence extnValue = new DERSequence(vec);
Extension extn;
try {
extn = new Extension(ObjectIdentifiers.Extn.id_pkix_ocsp_prefSigAlgs, false, new DEROctetString(extnValue));
} catch (IOException ex) {
throw new OcspRequestorException(ex.getMessage(), ex);
}
this.extensions = new Extension[] { extn };
}
URI uri = new URI(responderUrl);
this.responderRawPathPost = uri.getRawPath();
if (this.responderRawPathPost.endsWith("/")) {
this.responderRawPathGet = this.responderRawPathPost;
} else {
this.responderRawPathGet = this.responderRawPathPost + "/";
}
int port = uri.getPort();
if (port == -1) {
final String scheme = uri.getScheme();
if ("http".equalsIgnoreCase(scheme)) {
port = 80;
} else if ("https".equalsIgnoreCase(scheme)) {
port = 443;
} else {
throw new OcspRequestorException("unknown scheme " + scheme);
}
}
this.httpClient = new BenchmarkHttpClient(uri.getHost(), port, null, responseHandler, queueSize);
this.httpClient.start();
}
Aggregations