当前位置: 首页>>代码示例>>Java>>正文


Java Base64OutputStream.flush方法代码示例

本文整理汇总了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
}
 
开发者ID:jscep,项目名称:jester,代码行数:25,代码来源:EnrollmentServlet.java

示例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));
    }
}
 
开发者ID:jscep,项目名称:jester,代码行数:28,代码来源:EstClient.java

示例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();
}
 
开发者ID:jscep,项目名称:jester,代码行数:10,代码来源:CaDistributionServlet.java


注:本文中的org.apache.commons.codec.binary.Base64OutputStream.flush方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。