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


Java X509CertificateObject类代码示例

本文整理汇总了Java中org.bouncycastle.jce.provider.X509CertificateObject的典型用法代码示例。如果您正苦于以下问题:Java X509CertificateObject类的具体用法?Java X509CertificateObject怎么用?Java X509CertificateObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: generateJcaObject

import org.bouncycastle.jce.provider.X509CertificateObject; //导入依赖的package包/类
private X509Certificate generateJcaObject(TBSCertificate tbsCert, byte[] signature)
    throws CertificateEncodingException
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    v.add(tbsCert);
    v.add(sigAlgId);
    v.add(new DERBitString(signature));

    try
    {
        return new X509CertificateObject(Certificate.getInstance(new DERSequence(v)));
    }
    catch (CertificateParsingException e)
    {
        throw new ExtCertificateEncodingException("exception producing certificate object", e);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:19,代码来源:X509V1CertificateGenerator.java

示例2: createSelfSignedCert

import org.bouncycastle.jce.provider.X509CertificateObject; //导入依赖的package包/类
private void createSelfSignedCert(File targetKeystore, String keyName,
    String keystorePassword) {
  if (targetKeystore.exists()) {
    throw new RuntimeException("Keystore already exists: " + targetKeystore);
  }

  try {
    KeyPair kp = generateKeyPair();

    X509CertificateObject cert = generateCert(keyName, kp, true, kp.getPublic(),
        kp.getPrivate());

    char[] password = keystorePassword.toCharArray();
    KeyStore keystore = KeyStore.getInstance("JKS");
    keystore.load(null, null);
    keystore.setCertificateEntry(keyName + "Cert", cert);
    keystore.setKeyEntry(keyName + "Key", kp.getPrivate(), password, new Certificate[] {cert});
    try (FileOutputStream fos = new FileOutputStream(targetKeystore)) {
      keystore.store(fos, password);
    }
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:25,代码来源:SslDriverTest.java

示例3: readDERCertificate

import org.bouncycastle.jce.provider.X509CertificateObject; //导入依赖的package包/类
private java.security.cert.Certificate readDERCertificate(
    ASN1InputStream dIn)
    throws IOException, CertificateParsingException
{
    ASN1Sequence seq = (ASN1Sequence)dIn.readObject();

    if (seq.size() > 1
            && seq.getObjectAt(0) instanceof ASN1ObjectIdentifier)
    {
        if (seq.getObjectAt(0).equals(PKCSObjectIdentifiers.signedData))
        {
            sData = SignedData.getInstance(ASN1Sequence.getInstance(
                (ASN1TaggedObject)seq.getObjectAt(1), true)).getCertificates();

            return getCertificate();
        }
    }

    return new X509CertificateObject(
                        Certificate.getInstance(seq));
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:22,代码来源:CertificateFactory.java

示例4: getCertificate

import org.bouncycastle.jce.provider.X509CertificateObject; //导入依赖的package包/类
private java.security.cert.Certificate getCertificate()
    throws CertificateParsingException
{
    if (sData != null)
    {
        while (sDataObjectCount < sData.size())
        {
            Object obj = sData.getObjectAt(sDataObjectCount++);

            if (obj instanceof ASN1Sequence)
            {
               return new X509CertificateObject(
                                Certificate.getInstance(obj));
            }
        }
    }

    return null;
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:20,代码来源:CertificateFactory.java

示例5: generateJcaObject

import org.bouncycastle.jce.provider.X509CertificateObject; //导入依赖的package包/类
private X509Certificate generateJcaObject(TBSCertificate tbsCert, byte[] signature)
    throws CertificateEncodingException
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    v.add(tbsCert);
    v.add(sigAlgId);
    v.add(new DERBitString(signature));

    try
    {
        return new X509CertificateObject(Certificate.getInstance((new DERSequence(v))));
    }
    catch (CertificateParsingException e)
    {
        throw new ExtCertificateEncodingException("exception producing certificate object", e);
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:19,代码来源:X509V1CertificateGenerator.java

示例6: getEncryptionCredential

import org.bouncycastle.jce.provider.X509CertificateObject; //导入依赖的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

示例7: generateJcaObject

import org.bouncycastle.jce.provider.X509CertificateObject; //导入依赖的package包/类
private X509Certificate generateJcaObject(TBSCertificate tbsCert, byte[] signature)
    throws CertificateParsingException
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    v.add(tbsCert);
    v.add(sigAlgId);
    v.add(new DERBitString(signature));

    return new X509CertificateObject(Certificate.getInstance(new DERSequence(v)));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:12,代码来源:X509V3CertificateGenerator.java

示例8: X509CertificatePair

import org.bouncycastle.jce.provider.X509CertificateObject; //导入依赖的package包/类
/**
 * Constructor from a ASN.1 CertificatePair structure.
 *
 * @param pair The <code>CertificatePair</code> ASN.1 object.
 */
public X509CertificatePair(
    CertificatePair pair)
    throws CertificateParsingException
{
    if (pair.getForward() != null)
    {
        this.forward = new X509CertificateObject(pair.getForward());
    }
    if (pair.getReverse() != null)
    {
        this.reverse = new X509CertificateObject(pair.getReverse());
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:19,代码来源:X509CertificatePair.java

示例9: generateCert

import org.bouncycastle.jce.provider.X509CertificateObject; //导入依赖的package包/类
private X509CertificateObject generateCert(String keyName, KeyPair kp, boolean isCertAuthority,
    PublicKey signerPublicKey, PrivateKey signerPrivateKey) throws IOException,
    CertIOException, OperatorCreationException, CertificateException,
    NoSuchAlgorithmException {
  Calendar startDate = DateTimeUtils.calendar();
  Calendar endDate = DateTimeUtils.calendar();
  endDate.add(Calendar.YEAR, 100);

  BigInteger serialNumber = BigInteger.valueOf(startDate.getTimeInMillis());
  X500Name issuer = new X500Name(
      IETFUtils.rDNsFromString("cn=localhost", RFC4519Style.INSTANCE));
  JcaX509v3CertificateBuilder certGen = new JcaX509v3CertificateBuilder(issuer,
      serialNumber, startDate.getTime(), endDate.getTime(), issuer, kp.getPublic());
  JcaX509ExtensionUtils extensionUtils = new JcaX509ExtensionUtils();
  certGen.addExtension(Extension.subjectKeyIdentifier, false,
      extensionUtils.createSubjectKeyIdentifier(kp.getPublic()));
  certGen.addExtension(Extension.basicConstraints, false,
      new BasicConstraints(isCertAuthority));
  certGen.addExtension(Extension.authorityKeyIdentifier, false,
      extensionUtils.createAuthorityKeyIdentifier(signerPublicKey));
  if (isCertAuthority) {
    certGen.addExtension(Extension.keyUsage, true, new KeyUsage(KeyUsage.keyCertSign));
  }
  X509CertificateHolder cert = certGen.build(
      new JcaContentSignerBuilder(SIGNING_ALGORITHM).build(signerPrivateKey));
  return new X509CertificateObject(cert.toASN1Structure());
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:28,代码来源:SslDriverTest.java

示例10: parsePublicKey

import org.bouncycastle.jce.provider.X509CertificateObject; //导入依赖的package包/类
/**
 * Parses the leaf Certificate PublicKey from the CertificateStructure
 *
 * @param cert
 *            The Certificate from which the PublicKey should be extracted
 * @return The parsed PublicKey
 */
public static PublicKey parsePublicKey(Certificate cert) {
    try {
        X509CertificateObject certObj = new X509CertificateObject(cert.getCertificateAt(0));
        return certObj.getPublicKey();
    } catch (CertificateParsingException | IllegalArgumentException | ClassCastException ex) {
        LOGGER.warn("Could not extract public key from Certificate!");
        LOGGER.debug(ex);
        return null;
    }
}
 
开发者ID:RUB-NDS,项目名称:TLS-Attacker,代码行数:18,代码来源:CertificateUtils.java

示例11: getTestCertificateObject

import org.bouncycastle.jce.provider.X509CertificateObject; //导入依赖的package包/类
public static X509CertificateObject getTestCertificateObject() {
    try {
        X509CertificateObject obj = new X509CertificateObject(getTestCertificate().getCertificateAt(0));
        return obj;
    } catch (CertificateParsingException ex) {
        ex.printStackTrace();
    }
    return null;
}
 
开发者ID:RUB-NDS,项目名称:TLS-Attacker,代码行数:10,代码来源:TestCertificates.java

示例12: readPEMCertificate

import org.bouncycastle.jce.provider.X509CertificateObject; //导入依赖的package包/类
private java.security.cert.Certificate readPEMCertificate(
    InputStream in)
    throws IOException, CertificateParsingException
{
    ASN1Sequence seq = PEM_CERT_PARSER.readPEMObject(in);

    if (seq != null)
    {
        return new X509CertificateObject(
                        Certificate.getInstance(seq));
    }

    return null;
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:15,代码来源:CertificateFactory.java


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