本文整理汇总了Java中org.apache.commons.codec.binary.Base64OutputStream.flush方法的典型用法代码示例。如果您正苦于以下问题:Java Base64OutputStream.flush方法的具体用法?Java Base64OutputStream.flush怎么用?Java Base64OutputStream.flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.codec.binary.Base64OutputStream
的用法示例。
在下文中一共展示了Base64OutputStream.flush方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doPost
import org.apache.commons.codec.binary.Base64OutputStream; //导入方法依赖的package包/类
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
CertificationRequest csr = decoder.decode(new Base64InputStream(request.getInputStream()));
try {
response.setContentType(APPLICATION_PKCS7_MIME);
response.addHeader("Content-Transfer-Encoding", "base64");
X509Certificate certificate = est.enroll(csr);
Base64OutputStream bOut = new Base64OutputStream(response.getOutputStream());
encoder.encode(bOut, certificate);
bOut.flush();
bOut.close();
} catch (IOException e) {
response.sendError(500);
response.getWriter().write(e.getMessage());
response.getWriter().close();
}
// 202
// Retry-After
// 400
}
示例2: enroll
import org.apache.commons.codec.binary.Base64OutputStream; //导入方法依赖的package包/类
private EnrollmentResponse enroll(CertificationRequest csr, String command) throws IOException {
HttpPost post = new HttpPost(buildUrl(command));
post.addHeader("Content-Type", "application/pkcs10");
post.addHeader("Content-Transfer-Encoding", "base64");
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
Base64OutputStream base64Out = new Base64OutputStream(bOut);
csrEncoder.encode(base64Out, csr);
base64Out.flush();
base64Out.close();
post.setEntity(new ByteArrayEntity(bOut.toByteArray()));
HttpResponse response = httpClient.execute(post);
int statusCode = response.getStatusLine().getStatusCode();
checkStatusCode(statusCode, 200, 202);
if (statusCode == 200) {
checkContentType(response);
checkContentTransferEncoding(response);
HttpEntity entity = response.getEntity();
X509Certificate[] certs = certDecoder.decode(new Base64InputStream(entity.getContent()));
return new EnrollmentResponse(certs[0]);
} else {
String retryAfter = response.getFirstHeader("Retry-After").getValue();
return new EnrollmentResponse(RetryAfterParser.parse(retryAfter));
}
}
示例3: doGet
import org.apache.commons.codec.binary.Base64OutputStream; //导入方法依赖的package包/类
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(APPLICATION_PKCS7_MIME);
response.addHeader("Content-Transfer-Encoding", "base64");
Base64OutputStream bOut = new Base64OutputStream(response.getOutputStream());
encoder.encode(bOut, est.getCaCertificates());
bOut.flush();
bOut.close();
}