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


Java PemWriter.flush方法代码示例

本文整理汇总了Java中org.bouncycastle.util.io.pem.PemWriter.flush方法的典型用法代码示例。如果您正苦于以下问题:Java PemWriter.flush方法的具体用法?Java PemWriter.flush怎么用?Java PemWriter.flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.util.io.pem.PemWriter的用法示例。


在下文中一共展示了PemWriter.flush方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertToPresentation

import org.bouncycastle.util.io.pem.PemWriter; //导入方法依赖的package包/类
@Override
public String convertToPresentation(String value, Class<? extends String> targetType, Locale locale) throws ConversionException {
    if (value == null) {
        return null;
    } else {
        try {
            final CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
            final InputStream in = new ByteArrayInputStream(Base64.decodeBase64(value));
            final Certificate certificate = certFactory.generateCertificate(in);
            final StringWriter stringWriter = new StringWriter();
            final PemWriter pemWriter = new PemWriter(stringWriter);
            final PemObject pemObject = new PemObject("CERTIFICATE", certificate.getEncoded());
            pemWriter.writeObject(pemObject);
            pemWriter.flush();
            return stringWriter.toString();
        } catch (final Exception e) {
            throw new ConversionException("Error generating X509 certificate from database byte array.", e);
        }
    }
}
 
开发者ID:bubblecloud,项目名称:ilves,代码行数:21,代码来源:CertificateConverter.java

示例2: writeX509Certificate

import org.bouncycastle.util.io.pem.PemWriter; //导入方法依赖的package包/类
private static void writeX509Certificate(X509Certificate certificate, Writer sw) {
    if (certificate == null) {
        throw new IllegalArgumentException("certificate must be defined.");
    }
    if (sw == null) {
        throw new IllegalArgumentException("sw must be defined.");
    }
    try {
        PemWriter writer = new PemWriter(sw);
        writer.writeObject(new PemObject("CERTIFICATE", certificate.getEncoded()));
        writer.flush();
    } catch (CertificateEncodingException | IOException e) {
        throw new RuntimeException("Unable to write a certificate in output stream", e);
    }
}
 
开发者ID:kodokojo,项目名称:kodokojo,代码行数:16,代码来源:SSLUtils.java

示例3: writeRsaPrivateKey

import org.bouncycastle.util.io.pem.PemWriter; //导入方法依赖的package包/类
public static void writeRsaPrivateKey(RSAPrivateKey privateKey, Writer sw) {
    try {
        PemWriter writer = new PemWriter(sw);
        writer.writeObject(new PemObject("RSA PRIVATE KEY", privateKey.getEncoded()));
        writer.flush();
        //outputStream.write(pkcs8EncodedKeySpec.getEncoded());

    } catch (IOException e) {
        throw new RuntimeException("Unable to write a private rsa key in output stream", e);
    }
}
 
开发者ID:kodokojo,项目名称:kodokojo,代码行数:12,代码来源:RSAUtils.java

示例4: toPEM

import org.bouncycastle.util.io.pem.PemWriter; //导入方法依赖的package包/类
public static byte[] toPEM(PKCS10CertificationRequest csr) throws IOException {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    PemWriter pemWriter = new PemWriter(new OutputStreamWriter(os, StandardCharsets.UTF_8));
    try {
        pemWriter.writeObject(new JcaMiscPEMGenerator(csr));
        pemWriter.flush();
    } finally {
        pemWriter.close();
    }
    return os.toByteArray();
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:12,代码来源:PEMUtils.java

示例5: toPEM

import org.bouncycastle.util.io.pem.PemWriter; //导入方法依赖的package包/类
public static String toPEM(String type, byte[] data) {
    try{
        StringWriter writer = new StringWriter();
        PemWriter pemWriter = new PemWriter(writer);
        pemWriter.writeObject(new PemObject(type, data));
        pemWriter.flush();
        pemWriter.close();
        return writer.toString();
    }catch (Exception e){
        return "";
    }

}
 
开发者ID:aykutalparslan,项目名称:Telegram-Server,代码行数:14,代码来源:Utilities.java

示例6: certificateAsPem

import org.bouncycastle.util.io.pem.PemWriter; //导入方法依赖的package包/类
private String certificateAsPem(X509Certificate x509) throws CertificateEncodingException, IOException {
    StringWriter sw = new StringWriter();
    PemWriter writer = new PemWriter(sw);
    PemObject pemObject = new PemObject("CERTIFICATE", x509.getEncoded());
    try {
        writer.writeObject(pemObject);
        writer.flush();
    } catch (IOException e) {
        throw new RuntimeException(e);
    } finally {
        writer.close();
    }
    return sw.toString();
}
 
开发者ID:apiman,项目名称:apiman-plugins,代码行数:15,代码来源:KeycloakOauthPolicyTest.java


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