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


Java JcaX509ExtensionUtils.createSubjectKeyIdentifier方法代码示例

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


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

示例1: createCRTSafeBagBuilder

import org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils; //导入方法依赖的package包/类
private static PKCS12SafeBagBuilder createCRTSafeBagBuilder(String alias, X509Certificate crt, boolean addKeyId)
		throws IOException, GeneralSecurityException {
	PKCS12SafeBagBuilder safeBagBuilder = new JcaPKCS12SafeBagBuilder(crt);

	safeBagBuilder.addBagAttribute(PKCSObjectIdentifiers.pkcs_9_at_friendlyName, new DERBMPString(alias));
	if (addKeyId) {
		JcaX509ExtensionUtils extensionUtils = new JcaX509ExtensionUtils();
		SubjectKeyIdentifier subjectKeyIdentifier = extensionUtils.createSubjectKeyIdentifier(crt.getPublicKey());

		safeBagBuilder.addBagAttribute(PKCSObjectIdentifiers.pkcs_9_at_localKeyId, subjectKeyIdentifier);
	}
	return safeBagBuilder;
}
 
开发者ID:hdecarne,项目名称:certmgr,代码行数:14,代码来源:PKCS12CertReaderWriter.java

示例2: createKeySafeBagBuilder

import org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils; //导入方法依赖的package包/类
private static PKCS12SafeBagBuilder createKeySafeBagBuilder(String alias, KeyPair key)
		throws GeneralSecurityException {
	PKCS12SafeBagBuilder safeBagBuilder = new JcaPKCS12SafeBagBuilder(key.getPrivate());

	safeBagBuilder.addBagAttribute(PKCSObjectIdentifiers.pkcs_9_at_friendlyName, new DERBMPString(alias));

	JcaX509ExtensionUtils extensionUtils = new JcaX509ExtensionUtils();
	SubjectKeyIdentifier subjectKeyIdentifier = extensionUtils.createSubjectKeyIdentifier(key.getPublic());

	safeBagBuilder.addBagAttribute(PKCSObjectIdentifiers.pkcs_9_at_localKeyId, subjectKeyIdentifier);
	return safeBagBuilder;
}
 
开发者ID:hdecarne,项目名称:certmgr,代码行数:13,代码来源:PKCS12CertReaderWriter.java

示例3: nullPointerTest

import org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils; //导入方法依赖的package包/类
private void nullPointerTest()
    throws Exception
{
    KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA", "BC");
    keyGen.initialize(1024, new SecureRandom());
    KeyPair pair = keyGen.generateKeyPair();
    JcaX509ExtensionUtils extUtils = new JcaX509ExtensionUtils();

    Extension[] ext = new Extension[] {
        new Extension(Extension.basicConstraints, true, new DEROctetString(new BasicConstraints(true))),
        new Extension(Extension.keyUsage, true, new DEROctetString(new KeyUsage(KeyUsage.keyCertSign | KeyUsage.cRLSign))),
        new Extension(Extension.subjectKeyIdentifier, false, new DEROctetString(extUtils.createSubjectKeyIdentifier(pair.getPublic())))
    };

    PKCS10CertificationRequest p1 = new JcaPKCS10CertificationRequestBuilder(
        new X500Name("cn=csr"),
        pair.getPublic())
        .addAttribute(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest, new Extensions(ext))
        .build(new JcaContentSignerBuilder("SHA1withRSA").setProvider(BC).build(pair.getPrivate()));
    PKCS10CertificationRequest p2 = new JcaPKCS10CertificationRequestBuilder(
        new X500Name("cn=csr"),
        pair.getPublic())
        .addAttribute(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest, new Extensions(ext))
        .build(new JcaContentSignerBuilder("SHA1withRSA").setProvider(BC).build(pair.getPrivate()));

    if (!p1.equals(p2))
    {
        fail("cert request comparison failed");
    }

    Attribute[] attr1 = p1.getAttributes();
    Attribute[] attr2 = p1.getAttributes();

    checkAttrs(1, attr1, attr2);

    attr1 = p1.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest);
    attr2 = p1.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest);

    checkAttrs(1, attr1, attr2);
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:41,代码来源:PKCS10Test.java

示例4: beforeEach

import org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils; //导入方法依赖的package包/类
@Before
public void beforeEach() throws Exception {
  timeProvider = mock(DateTimeProvider.class);
  now = Calendar.getInstance();
  now.setTimeInMillis(1493066824);
  later = (Calendar) now.clone();
  later.add(Calendar.DAY_OF_YEAR, expectedDurationInDays);
  when(timeProvider.getNow()).thenReturn(now);
  serialNumberGenerator = mock(RandomSerialNumberGenerator.class);
  when(serialNumberGenerator.generate()).thenReturn(BigInteger.valueOf(1337));
  jcaX509ExtensionUtils = new JcaX509ExtensionUtils();

  generator = KeyPairGenerator
      .getInstance("RSA", BouncyCastleProvider.PROVIDER_NAME);
  generator.initialize(1024); // doesn't matter for testing
  issuerKey = generator.generateKeyPair();

  issuerDn = new X500Principal(caName);
  generatedCertificateKeyPair = generator.generateKeyPair();
  certificateGenerationParameters = defaultCertificateParameters();

  subject = new SignedCertificateGenerator(timeProvider,
      serialNumberGenerator,
      jcaContentSignerBuilder,
      jcaX509CertificateConverter,
      getBouncyCastleProvider()
  );

  caSubjectKeyIdentifier =
      jcaX509ExtensionUtils.createSubjectKeyIdentifier(issuerKey.getPublic());

  caSerialNumber = BigInteger.valueOf(42l);
  JcaX509v3CertificateBuilder x509v3CertificateBuilder = new JcaX509v3CertificateBuilder(
      issuerDn,
      caSerialNumber,
      Date.from(now.toInstant()),
      Date.from(later.toInstant()),
      issuerDn,
      issuerKey.getPublic()
  );

  certificateAuthority = createCertificateAuthority(x509v3CertificateBuilder);

  x509v3CertificateBuilder.addExtension(Extension.subjectKeyIdentifier, false, caSubjectKeyIdentifier);
  certificateAuthorityWithSubjectKeyId = createCertificateAuthority(x509v3CertificateBuilder);
  expectedSubjectKeyIdentifier = certificateAuthorityWithSubjectKeyId.getExtensionValue(Extension.subjectKeyIdentifier.getId());
}
 
开发者ID:cloudfoundry-incubator,项目名称:credhub,代码行数:48,代码来源:SignedCertificateGeneratorTest.java


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