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


Java X509CertParser.engineRead方法代码示例

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


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

示例1: parse

import org.bouncycastle.jce.provider.X509CertParser; //导入方法依赖的package包/类
public static X509CertificateWrapper parse(final RpslObject rpslObject) {
    if (!looksLikeX509Key(rpslObject)) {
        throw new IllegalArgumentException("The supplied object has no key");
    }

    try {
        final byte[] bytes = RpslObjectFilter.getCertificateFromKeyCert(rpslObject).getBytes(Charsets.ISO_8859_1);

        X509CertParser parser = new X509CertParser();
        parser.engineInit(new ByteArrayInputStream(bytes));
        X509Certificate result = (X509Certificate) parser.engineRead();

        if (result == null) {
            throw new IllegalArgumentException("Invalid X509 Certificate");
        }

        return new X509CertificateWrapper(result);

    } catch (StreamParsingException e) {
        throw new IllegalArgumentException("Error parsing X509 certificate from key-cert object", e);
    }
}
 
开发者ID:RIPE-NCC,项目名称:whois,代码行数:23,代码来源:X509CertificateWrapper.java

示例2: getEncryptionCredential

import org.bouncycastle.jce.provider.X509CertParser; //导入方法依赖的package包/类
private Credential getEncryptionCredential(final WsFederationConfiguration config) {
    try {
        // This will need to contain the private keypair in PEM format
        final BufferedReader br = new BufferedReader(new InputStreamReader(config.getEncryptionPrivateKey().getInputStream()));
        Security.addProvider(new BouncyCastleProvider());
        final PEMParser pemParser = new PEMParser(br);

        final Object privateKeyPemObject = pemParser.readObject();
        final JcaPEMKeyConverter converter = new JcaPEMKeyConverter().setProvider(new BouncyCastleProvider());

        final KeyPair kp;
        if (privateKeyPemObject instanceof PEMEncryptedKeyPair) {
            final PEMEncryptedKeyPair ckp = (PEMEncryptedKeyPair) privateKeyPemObject;
            final PEMDecryptorProvider decProv = new JcePEMDecryptorProviderBuilder()
                    .build(config.getEncryptionPrivateKeyPassword().toCharArray());
            kp = converter.getKeyPair(ckp.decryptKeyPair(decProv));
        } else {
            kp = converter.getKeyPair((PEMKeyPair) privateKeyPemObject);
        }

        final X509CertParser certParser = new X509CertParser();
        // This is the certificate shared with ADFS in DER format, i.e certificate.crt
        certParser.engineInit(config.getEncryptionCertificate().getInputStream());
        final X509CertificateObject cert = (X509CertificateObject) certParser.engineRead();
        return new BasicX509Credential(cert, kp.getPrivate());
    } catch (final Exception e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:30,代码来源:WsFederationHelper.java

示例3: createCerts

import org.bouncycastle.jce.provider.X509CertParser; //导入方法依赖的package包/类
private Set createCerts(List list, X509CertStoreSelector xselector)
    throws StoreException
{
    Set certSet = new HashSet();

    Iterator it = list.iterator();
    X509CertParser parser = new X509CertParser();
    while (it.hasNext())
    {
        try
        {
            parser.engineInit(new ByteArrayInputStream((byte[])it
                .next()));
            X509Certificate cert = (X509Certificate)parser
                .engineRead();
            if (xselector.match((Object)cert))
            {
                certSet.add(cert);
            }

        }
        catch (Exception e)
        {

        }
    }

    return certSet;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:30,代码来源:LDAPStoreHelper.java

示例4: extractCertificate

import org.bouncycastle.jce.provider.X509CertParser; //导入方法依赖的package包/类
private X509Certificate extractCertificate(final String[] domains, InputStream inputStream)
		throws StreamParsingException {
	X509CertParser certParser = new X509CertParser();
	certParser.engineInit(inputStream);
	X509Certificate certificate = (X509Certificate) certParser.engineRead();
	certificateStorage.saveCertificate(domains, certificate);
	return certificate;
}
 
开发者ID:zero11it,项目名称:acme-client,代码行数:9,代码来源:Acme.java

示例5: apply

import org.bouncycastle.jce.provider.X509CertParser; //导入方法依赖的package包/类
@Override
public Object apply(Object input) {
  if (input instanceof String && input.toString().contains("BEGIN CERTIFICATE")) {
    try {
      X509CertParser x509CertParser = new X509CertParser();
      x509CertParser.engineInit(new ByteArrayInputStream(input.toString().getBytes()));
      return x509CertParser.engineRead();
    } catch (Exception ex) {
      return input;
    }
  }
  return input;
}
 
开发者ID:Netflix,项目名称:denominator,代码行数:14,代码来源:Denominator.java

示例6: getEncryptionCredential

import org.bouncycastle.jce.provider.X509CertParser; //导入方法依赖的package包/类
private static Credential getEncryptionCredential(final WsFederationConfiguration config) {
    try {
        // This will need to contain the private keypair in PEM format
        LOGGER.debug("Locating encryption credential private key [{}]", config.getEncryptionPrivateKey());
        final BufferedReader br = new BufferedReader(new InputStreamReader(
                config.getEncryptionPrivateKey().getInputStream(), StandardCharsets.UTF_8));
        Security.addProvider(new BouncyCastleProvider());

        LOGGER.debug("Parsing credential private key");
        final PEMParser pemParser = new PEMParser(br);
        final Object privateKeyPemObject = pemParser.readObject();
        
        final JcaPEMKeyConverter converter = new JcaPEMKeyConverter().setProvider(new BouncyCastleProvider());

        final KeyPair kp;
        if (privateKeyPemObject instanceof PEMEncryptedKeyPair) {
            LOGGER.debug("Encryption private key is an encrypted keypair");
            final PEMEncryptedKeyPair ckp = (PEMEncryptedKeyPair) privateKeyPemObject;
            final PEMDecryptorProvider decProv = new JcePEMDecryptorProviderBuilder()
                    .build(config.getEncryptionPrivateKeyPassword().toCharArray());

            LOGGER.debug("Attempting to decrypt the encrypted keypair based on the provided encryption private key password");
            kp = converter.getKeyPair(ckp.decryptKeyPair(decProv));
        } else {
            LOGGER.debug("Extracting a keypair from the private key");
            kp = converter.getKeyPair((PEMKeyPair) privateKeyPemObject);
        }

        final X509CertParser certParser = new X509CertParser();
        // This is the certificate shared with ADFS in DER format, i.e certificate.crt
        LOGGER.debug("Locating encryption certificate [{}]", config.getEncryptionCertificate());
        certParser.engineInit(config.getEncryptionCertificate().getInputStream());

        LOGGER.debug("Invoking certificate engine to parse the certificate [{}]", config.getEncryptionCertificate());
        final X509CertificateObject cert = (X509CertificateObject) certParser.engineRead();
        LOGGER.debug("Creating final credential based on the certificate [{}] and the private key", cert.getIssuerDN());
        return new BasicX509Credential(cert, kp.getPrivate());
    } catch (final Exception e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:42,代码来源:WsFederationHelper.java

示例7: getCertificate

import org.bouncycastle.jce.provider.X509CertParser; //导入方法依赖的package包/类
private X509Certificate getCertificate(String certificate) throws StreamParsingException {
    X509CertParser parser = new X509CertParser();
    parser.engineInit(new ByteArrayInputStream(certificate.getBytes()));
    return (X509Certificate) parser.engineRead();
}
 
开发者ID:RIPE-NCC,项目名称:whois,代码行数:6,代码来源:X509SignedMessageTest.java


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