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


Java RFC4519Style类代码示例

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


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

示例1: checkCRLsNotEmpty

import org.bouncycastle.asn1.x500.style.RFC4519Style; //导入依赖的package包/类
static void checkCRLsNotEmpty(Set crls, Object cert)
    throws AnnotatedException
{
    if (crls.isEmpty())
    {
        if (cert instanceof X509AttributeCertificate)
        {
            X509AttributeCertificate aCert = (X509AttributeCertificate)cert;

            throw new AnnotatedException("No CRLs found for issuer \"" + aCert.getIssuer().getPrincipals()[0] + "\"");
        }
        else
        {
            X509Certificate xCert = (X509Certificate)cert;

            throw new AnnotatedException("No CRLs found for issuer \"" + RFC4519Style.INSTANCE.toString(PrincipalUtils.getIssuerPrincipal(xCert)) + "\"");
        }
    }
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:20,代码来源:CertPathValidatorUtilities.java

示例2: getName

import org.bouncycastle.asn1.x500.style.RFC4519Style; //导入依赖的package包/类
public static String getName(ASN1ObjectIdentifier type) {
    ParamUtil.requireNonNull("type", type);
    String name = oidNameMap.get(type);

    if (StringUtil.isBlank(name)) {
        try {
            name = RFC4519Style.INSTANCE.oidToDisplayName(type);
        } catch (IllegalArgumentException ex) { // CHECKSTYLE:SKIP
        }
    }
    return name;
}
 
开发者ID:xipki,项目名称:xitk,代码行数:13,代码来源:ObjectIdentifiers.java

示例3: nameToOid

import org.bouncycastle.asn1.x500.style.RFC4519Style; //导入依赖的package包/类
public static ASN1ObjectIdentifier nameToOid(String name) {
    ParamUtil.requireNonNull("name", name);
    for (ASN1ObjectIdentifier oid : oidNameMap.keySet()) {
        if (oidNameMap.get(oid).equalsIgnoreCase(name)) {
            return oid;
        }
    }

    try {
        return RFC4519Style.INSTANCE.attrNameToOID(name);
    } catch (IllegalArgumentException ex) {
        return null;
    }
}
 
开发者ID:xipki,项目名称:xitk,代码行数:15,代码来源:ObjectIdentifiers.java

示例4: generateCert

import org.bouncycastle.asn1.x500.style.RFC4519Style; //导入依赖的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

示例5: performTest

import org.bouncycastle.asn1.x500.style.RFC4519Style; //导入依赖的package包/类
public void performTest()
    throws Exception
{
    X500NameStyle style = RFC4519Style.INSTANCE;

    for (int i = 0; i != attributeTypes.length; i++)
    {
        if (!attributeTypeOIDs[i].equals(style.attrNameToOID(attributeTypes[i])))
        {
            fail("mismatch for " + attributeTypes[i]);
        }
    }

    byte[] enc = Hex.decode("305e310b300906035504061302415531283026060355040a0c1f546865204c6567696f6e206f662074686520426f756e637920436173746c653125301006035504070c094d656c626f75726e653011060355040b0c0a4173636f742056616c65");

    X500Name n = X500Name.getInstance(style, X500Name.getInstance(enc));

    if (!n.toString().equals("l=Melbourne+ou=Ascot Vale,o=The Legion of the Bouncy Castle,c=AU"))
    {
        fail("Failed composite to string test got: " + n.toString());
    }

    n = new X500Name(style, "l=Melbourne+ou=Ascot Vale,o=The Legion of the Bouncy Castle,c=AU");

    if (!Arrays.areEqual(n.getEncoded(), enc))
    {
        fail("re-encoding test after parse failed");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:30,代码来源:RFC4519Test.java

示例6: createRootCert

import org.bouncycastle.asn1.x500.style.RFC4519Style; //导入依赖的package包/类
private static JcaX509v3CertificateBuilder createRootCert(KeyPair keypair) throws Exception {
    X500NameBuilder ib = new X500NameBuilder(RFC4519Style.INSTANCE);
    ib.addRDN(RFC4519Style.c, "AQ");
    ib.addRDN(RFC4519Style.o, "Test");
    ib.addRDN(RFC4519Style.l, "Vostok Station");
    ib.addRDN(PKCSObjectIdentifiers.pkcs_9_at_emailAddress, "[email protected]");
    X500Name issuer = ib.build();
    return createCert(keypair, issuer, issuer);
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:10,代码来源:CertificateGeneratorTest.java

示例7: createStdBuilder

import org.bouncycastle.asn1.x500.style.RFC4519Style; //导入依赖的package包/类
private X500NameBuilder createStdBuilder()
{
    X500NameBuilder builder = new X500NameBuilder(RFC4519Style.INSTANCE);

    builder.addRDN(RFC4519Style.c, "AU");
    builder.addRDN(RFC4519Style.o, "The Legion of the Bouncy Castle");
    builder.addRDN(RFC4519Style.l, "Melbourne");
    builder.addRDN(RFC4519Style.st, "Victoria");
    builder.addRDN(PKCSObjectIdentifiers.pkcs_9_at_emailAddress, "[email protected]");

    return builder;
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:13,代码来源:BcCertTest.java

示例8: performTest

import org.bouncycastle.asn1.x500.style.RFC4519Style; //导入依赖的package包/类
public void performTest()
    throws Exception
{
    X500NameStyle style = RFC4519Style.INSTANCE;

    for (int i = 0; i != attributeTypes.length; i++)
    {
        if (!attributeTypeOIDs[i].equals(style.attrNameToOID(attributeTypes[i])))
        {
            fail("mismatch for " + attributeTypes[i]);
        }
    }

    byte[] enc = Hex.decode("305e310b300906035504061302415531283026060355040a0c1f546865204c6567696f6e206f662074686520426f756e637920436173746c653125301006035504070c094d656c626f75726e653011060355040b0c0a4173636f742056616c65");

    X500Name n = new X500Name(style, X500Name.getInstance(enc));

    if (!n.toString().equals("l=Melbourne+ou=Ascot Vale,o=The Legion of the Bouncy Castle,c=AU"))
    {
        fail("Failed composite to string test got: " + n.toString());
    }

    n = new X500Name(style, "l=Melbourne+ou=Ascot Vale,o=The Legion of the Bouncy Castle,c=AU");

    if (!Arrays.areEqual(n.getEncoded(), enc))
    {
        fail("re-encoding test after parse failed");
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:30,代码来源:RFC4519Test.java

示例9: getRfc4519Name

import org.bouncycastle.asn1.x500.style.RFC4519Style; //导入依赖的package包/类
public static String getRfc4519Name(X500Name name) {
    ParamUtil.requireNonNull("name", name);
    return RFC4519Style.INSTANCE.toString(name);
}
 
开发者ID:xipki,项目名称:xitk,代码行数:5,代码来源:X509Util.java

示例10: createKeystores

import org.bouncycastle.asn1.x500.style.RFC4519Style; //导入依赖的package包/类
private static void createKeystores() throws Exception {
    // Create KeyPair
    KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
    keyPairGenerator.initialize(1024, new SecureRandom());
    KeyPair keyPair = keyPairGenerator.generateKeyPair();

    Date currentDate = new Date();
    Date expiryDate = new Date(currentDate.getTime() + 365L * 24L * 60L * 60L * 1000L);

    // Create X509Certificate
    String issuerName = "CN=Issuer";
    String subjectName = "CN=Subject";
    BigInteger serial = new BigInteger("123456");
    X509v3CertificateBuilder certBuilder =
            new X509v3CertificateBuilder(new X500Name(RFC4519Style.INSTANCE, issuerName), serial, currentDate,
                    expiryDate,
                    new X500Name(RFC4519Style.INSTANCE, subjectName),
                    SubjectPublicKeyInfo.getInstance(keyPair.getPublic().getEncoded()));
    ContentSigner contentSigner = new JcaContentSignerBuilder("SHA256WithRSAEncryption").build(keyPair.getPrivate());
    X509Certificate certificate = new JcaX509CertificateConverter().getCertificate(certBuilder.build(contentSigner));

    // Store Private Key + Certificate in Keystore
    KeyStore keystore = KeyStore.getInstance("JKS");
    keystore.load(null, "security".toCharArray());
    keystore.setKeyEntry("subject", keyPair.getPrivate(), "security".toCharArray(),
            new Certificate[] { certificate });

    File keystoreFile = File.createTempFile("samlkeystore", ".jks");
    try (OutputStream output = Files.newOutputStream(keystoreFile.toPath())) {
        keystore.store(output, "security".toCharArray());
    }
    keystorePath = keystoreFile.toPath();

    // Now store the Certificate in the truststore
    KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
    trustStore.load(null, "security".toCharArray());

    trustStore.setCertificateEntry("subject", certificate);

    File truststoreFile = File.createTempFile("samltruststore", ".jks");
    try (OutputStream output = Files.newOutputStream(truststoreFile.toPath())) {
        trustStore.store(output, "security".toCharArray());
    }
    truststorePath = truststoreFile.toPath();
}
 
开发者ID:apache,项目名称:syncope,代码行数:46,代码来源:SAML2ITCase.java

示例11: generationTest

import org.bouncycastle.asn1.x500.style.RFC4519Style; //导入依赖的package包/类
private void generationTest(int keySize, String keyName, String sigName)
    throws Exception
{
    AsymmetricCipherKeyPairGenerator kpg = new RSAKeyPairGenerator();
    RSAKeyGenerationParameters genParam = new RSAKeyGenerationParameters(
                                        BigInteger.valueOf(0x1001), new SecureRandom(), keySize, 25);

    kpg.init(genParam);

    AsymmetricCipherKeyPair kp = kpg.generateKeyPair();


    X500NameBuilder x500NameBld = new X500NameBuilder(RFC4519Style.INSTANCE);

    x500NameBld.addRDN(RFC4519Style.c, "AU");
    x500NameBld.addRDN(RFC4519Style.o, "The Legion of the Bouncy Castle");
    x500NameBld.addRDN(RFC4519Style.l, "Melbourne");
    x500NameBld.addRDN(RFC4519Style.st, "Victoria");
    x500NameBld.addRDN(PKCSObjectIdentifiers.pkcs_9_at_emailAddress, "[email protected]");

    X500Name subject = x500NameBld.build();

    PKCS10CertificationRequestBuilder requestBuilder = new BcPKCS10CertificationRequestBuilder(subject, kp.getPublic());

    DefaultSignatureAlgorithmIdentifierFinder sigAlgFinder = new DefaultSignatureAlgorithmIdentifierFinder();
    DefaultDigestAlgorithmIdentifierFinder digAlgFinder = new DefaultDigestAlgorithmIdentifierFinder();

    AlgorithmIdentifier sigAlgId = sigAlgFinder.find("SHA1withRSA");

    AlgorithmIdentifier digAlgId = digAlgFinder.find(sigAlgId);

    BcContentSignerBuilder contentSignerBuilder = new BcRSAContentSignerBuilder(sigAlgId, digAlgId);

    PKCS10CertificationRequest req1 = requestBuilder.build(contentSignerBuilder.build(kp.getPrivate()));

    BcPKCS10CertificationRequest req2 = new BcPKCS10CertificationRequest(req1.getEncoded());

    if (!req2.isSignatureValid(new BcRSAContentVerifierProviderBuilder(digAlgFinder).build(kp.getPublic())))
    {
        fail(sigName + ": Failed verify check.");
    }

    if (!Arrays.areEqual(req2.getSubjectPublicKeyInfo().getEncoded(), req1.getSubjectPublicKeyInfo().getEncoded()))
    {
        fail(keyName + ": Failed public key check.");
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:48,代码来源:BcPKCS10Test.java

示例12: getAlternativeNames

import org.bouncycastle.asn1.x500.style.RFC4519Style; //导入依赖的package包/类
private static Collection getAlternativeNames(byte[] extVal)
    throws CertificateParsingException
{
    if (extVal == null)
    {
        return null;
    }
    try
    {
        Collection temp = new ArrayList();
        Enumeration it = ASN1Sequence.getInstance(extVal).getObjects();
        while (it.hasMoreElements())
        {
            GeneralName genName = GeneralName.getInstance(it.nextElement());
            List list = new ArrayList();
            list.add(Integers.valueOf(genName.getTagNo()));
            switch (genName.getTagNo())
            {
            case GeneralName.ediPartyName:
            case GeneralName.x400Address:
            case GeneralName.otherName:
                list.add(genName.getEncoded());
                break;
            case GeneralName.directoryName:
                list.add(X500Name.getInstance(RFC4519Style.INSTANCE, genName.getName()).toString());
                break;
            case GeneralName.dNSName:
            case GeneralName.rfc822Name:
            case GeneralName.uniformResourceIdentifier:
                list.add(((ASN1String)genName.getName()).getString());
                break;
            case GeneralName.registeredID:
                list.add(ASN1ObjectIdentifier.getInstance(genName.getName()).getId());
                break;
            case GeneralName.iPAddress:
                byte[] addrBytes = DEROctetString.getInstance(genName.getName()).getOctets();
                list.add(addrBytes);
                break;
            default:
                throw new IOException("Bad tag number: " + genName.getTagNo());
            }

            temp.add(list);
        }
        if (temp.size() == 0)
        {
            return null;
        }
        return Collections.unmodifiableCollection(temp);
    }
    catch (Exception e)
    {
        throw new CertificateParsingException(e.getMessage());
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:56,代码来源:X509CertificateObject.java


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