• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java TargetInformation类的典型用法和代码示例

java 1次浏览

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

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

示例1: performTest

点赞 3

import org.bouncycastle.asn1.x509.TargetInformation; //导入依赖的package包/类
public void performTest() throws Exception
{
    Target[] targets = new Target[2];
    Target targetName = new Target(Target.targetName, new GeneralName(GeneralName.dNSName, "www.test.com"));
    Target targetGroup = new Target(Target.targetGroup, new GeneralName(GeneralName.directoryName, "o=Test, ou=Test"));
    targets[0] = targetName;
    targets[1] = targetGroup;
    Targets targetss = new Targets(targets);
    TargetInformation targetInformation1 = new TargetInformation(targetss);
    // use an Target array
    TargetInformation targetInformation2 = new TargetInformation(targets);
    // targetInformation1 and targetInformation2 must have same
    // encoding.
    if (!targetInformation1.equals(targetInformation2))
    {
        fail("targetInformation1 and targetInformation2 should have the same encoding.");
    }
    TargetInformation targetInformation3 = TargetInformation.getInstance(targetInformation1);
    TargetInformation targetInformation4 = TargetInformation.getInstance(targetInformation2);
    if (!targetInformation3.equals(targetInformation4))
    {
        fail("targetInformation3 and targetInformation4 should have the same encoding.");
    }
}
 

开发者ID:ttt43ttt,
项目名称:gwt-crypto,
代码行数:25,
代码来源:TargetInformationTest.java

示例2: createAttrCert

点赞 2

import org.bouncycastle.asn1.x509.TargetInformation; //导入依赖的package包/类
private X509AttributeCertificateHolder createAttrCert() throws Exception
{
    X509CertificateHolder iCertHolder = new X509CertificateHolder(holderCert);
    //
    // a sample key pair.
    //
    // RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(
    // new BigInteger(
    // "b4a7e46170574f16a97082b22be58b6a2a629798419be12872a4bdba626cfae9900f76abfb12139dce5de56564fab2b6543165a040c606887420e33d91ed7ed7",
    // 16), new BigInteger("11", 16));

    //
    // set up the keys
    //
    X509v2AttributeCertificateBuilder gen = new X509v2AttributeCertificateBuilder(
            new AttributeCertificateHolder(iCertHolder.getSubject()),
            new AttributeCertificateIssuer(new X500Name("cn=test")),
            BigInteger.valueOf(1),
            new Date(System.currentTimeMillis() - 50000),
            new Date(System.currentTimeMillis() + 50000));

    // the actual attributes
    GeneralName roleName = new GeneralName(GeneralName.rfc822Name,
        "[email protected]");
    ASN1EncodableVector roleSyntax = new ASN1EncodableVector();
    roleSyntax.add(roleName);

    // roleSyntax OID: 2.5.24.72
    gen.addAttribute(new ASN1ObjectIdentifier("2.5.24.72"), new DERSequence(roleSyntax));

    AlgorithmIdentifier sigAlgId = new DefaultSignatureAlgorithmIdentifierFinder().find("SHA1WithRSAEncryption");
    AlgorithmIdentifier digAlgId = new DefaultDigestAlgorithmIdentifierFinder().find(sigAlgId);

    ContentSigner sigGen = new BcRSAContentSignerBuilder(sigAlgId, digAlgId).build(RSA_PRIVATE_KEY);

    Target targetName = new Target(Target.targetName, new GeneralName(GeneralName.dNSName,
        "www.test.com"));

    Target targetGroup = new Target(Target.targetGroup, new GeneralName(
        GeneralName.directoryName, "o=Test, ou=Test"));
    Target[] targets = new Target[2];
    targets[0] = targetName;
    targets[1] = targetGroup;
    TargetInformation targetInformation = new TargetInformation(targets);

    gen.addExtension(X509Extension.targetInformation, true, targetInformation);

    return gen.build(sigGen);
}
 

开发者ID:ttt43ttt,
项目名称:gwt-crypto,
代码行数:50,
代码来源:AttrCertSelectorTest.java

示例3: createAttrCert

点赞 2

import org.bouncycastle.asn1.x509.TargetInformation; //导入依赖的package包/类
private X509AttributeCertificate createAttrCert() throws Exception
{
    CertificateFactory fact = CertificateFactory.getInstance("X.509", "BC");
    X509Certificate iCert = (X509Certificate) fact
        .generateCertificate(new ByteArrayInputStream(holderCert));

    //
    // a sample key pair.
    //
    // RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(
    // new BigInteger(
    // "b4a7e46170574f16a97082b22be58b6a2a629798419be12872a4bdba626cfae9900f76abfb12139dce5de56564fab2b6543165a040c606887420e33d91ed7ed7",
    // 16), new BigInteger("11", 16));

    //
    // set up the keys
    //
    PrivateKey privKey;

    KeyFactory kFact = KeyFactory.getInstance("RSA", "BC");

    privKey = kFact.generatePrivate(RSA_PRIVATE_KEY_SPEC);

    X509V2AttributeCertificateGenerator gen = new X509V2AttributeCertificateGenerator();

    // the actual attributes
    GeneralName roleName = new GeneralName(GeneralName.rfc822Name,
        "[email protected]");
    ASN1EncodableVector roleSyntax = new ASN1EncodableVector();
    roleSyntax.add(roleName);

    // roleSyntax OID: 2.5.24.72
    X509Attribute attributes = new X509Attribute("2.5.24.72",
        new DERSequence(roleSyntax));

    gen.addAttribute(attributes);
    gen.setHolder(new AttributeCertificateHolder(PrincipalUtil.getSubjectX509Principal(iCert)));
    gen.setIssuer(new AttributeCertificateIssuer(new X509Principal(
        "cn=test")));
    gen.setNotBefore(new Date(System.currentTimeMillis() - 50000));
    gen.setNotAfter(new Date(System.currentTimeMillis() + 50000));
    gen.setSerialNumber(BigInteger.valueOf(1));
    gen.setSignatureAlgorithm("SHA1WithRSAEncryption");

    Target targetName = new Target(Target.targetName, new GeneralName(GeneralName.dNSName,
        "www.test.com"));

    Target targetGroup = new Target(Target.targetGroup, new GeneralName(
        GeneralName.directoryName, "o=Test, ou=Test"));
    Target[] targets = new Target[2];
    targets[0] = targetName;
    targets[1] = targetGroup;
    TargetInformation targetInformation = new TargetInformation(targets);
    gen.addExtension(X509Extensions.TargetInformation.getId(), true,
        targetInformation);

    return gen.generate(privKey, "BC");
}
 

开发者ID:NoYouShutup,
项目名称:CryptMeme,
代码行数:59,
代码来源:AttrCertSelectorTest.java

示例4: createAttrCert

点赞 2

import org.bouncycastle.asn1.x509.TargetInformation; //导入依赖的package包/类
private X509AttributeCertificateHolder createAttrCert() throws Exception
{
    X509CertificateHolder iCertHolder = new X509CertificateHolder(holderCert);
    //
    // a sample key pair.
    //
    // RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(
    // new BigInteger(
    // "b4a7e46170574f16a97082b22be58b6a2a629798419be12872a4bdba626cfae9900f76abfb12139dce5de56564fab2b6543165a040c606887420e33d91ed7ed7",
    // 16), new BigInteger("11", 16));

    X509v2AttributeCertificateBuilder gen = new X509v2AttributeCertificateBuilder(
            new AttributeCertificateHolder(iCertHolder.getSubject()),
            new AttributeCertificateIssuer(new X500Name("cn=test")),
            BigInteger.ONE,
            new Date(System.currentTimeMillis() - 50000),
            new Date(System.currentTimeMillis() + 50000));

    // the actual attributes
    GeneralName roleName = new GeneralName(GeneralName.rfc822Name,
        "[email protected]");
    ASN1EncodableVector roleSyntax = new ASN1EncodableVector();
    roleSyntax.add(roleName);

    // roleSyntax OID: 2.5.24.72
    gen.addAttribute(new ASN1ObjectIdentifier("2.5.24.72"), new DERSequence(roleSyntax));


    AlgorithmIdentifier sigAlg = sigAlgFinder.find("SHA1withRSA");
    AlgorithmIdentifier digAlg = digAlgFinder.find(sigAlg);

    ContentSigner sigGen = new BcRSAContentSignerBuilder(sigAlg, digAlg).build(RSA_PRIVATE_KEY_SPEC);
    Target targetName = new Target(Target.targetName, new GeneralName(GeneralName.dNSName,
        "www.test.com"));

    Target targetGroup = new Target(Target.targetGroup, new GeneralName(
        GeneralName.directoryName, "o=Test, ou=Test"));
    Target[] targets = new Target[2];
    targets[0] = targetName;
    targets[1] = targetGroup;
    TargetInformation targetInformation = new TargetInformation(targets);

    gen.addExtension(Extension.targetInformation, true, targetInformation);

    return gen.build(sigGen);
}
 

开发者ID:credentials,
项目名称:irma_future_id,
代码行数:47,
代码来源:BcAttrCertSelectorTest.java

示例5: createAttrCert

点赞 2

import org.bouncycastle.asn1.x509.TargetInformation; //导入依赖的package包/类
private X509AttributeCertificateHolder createAttrCert() throws Exception
{
    CertificateFactory fact = CertificateFactory.getInstance("X.509", "BC");
    X509Certificate iCert = (X509Certificate) fact
        .generateCertificate(new ByteArrayInputStream(holderCert));
    X509CertificateHolder iCertHolder = new JcaX509CertificateHolder(iCert);
    //
    // a sample key pair.
    //
    // RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(
    // new BigInteger(
    // "b4a7e46170574f16a97082b22be58b6a2a629798419be12872a4bdba626cfae9900f76abfb12139dce5de56564fab2b6543165a040c606887420e33d91ed7ed7",
    // 16), new BigInteger("11", 16));

    //
    // set up the keys
    //
    PrivateKey privKey;

    KeyFactory kFact = KeyFactory.getInstance("RSA", "BC");

    privKey = kFact.generatePrivate(RSA_PRIVATE_KEY_SPEC);

    X509v2AttributeCertificateBuilder gen = new X509v2AttributeCertificateBuilder(
            new AttributeCertificateHolder(iCertHolder.getSubject()),
            new AttributeCertificateIssuer(new X500Name("cn=test")),
            BigInteger.valueOf(1),
            new Date(System.currentTimeMillis() - 50000),
            new Date(System.currentTimeMillis() + 50000));

    // the actual attributes
    GeneralName roleName = new GeneralName(GeneralName.rfc822Name,
        "[email protected]");
    ASN1EncodableVector roleSyntax = new ASN1EncodableVector();
    roleSyntax.add(roleName);

    // roleSyntax OID: 2.5.24.72
    gen.addAttribute(new ASN1ObjectIdentifier("2.5.24.72"), new DERSequence(roleSyntax));


    ContentSigner sigGen = new JcaContentSignerBuilder("SHA1WithRSAEncryption").setProvider(BC).build(privKey);

    Target targetName = new Target(Target.targetName, new GeneralName(GeneralName.dNSName,
        "www.test.com"));

    Target targetGroup = new Target(Target.targetGroup, new GeneralName(
        GeneralName.directoryName, "o=Test, ou=Test"));
    Target[] targets = new Target[2];
    targets[0] = targetName;
    targets[1] = targetGroup;
    TargetInformation targetInformation = new TargetInformation(targets);

    gen.addExtension(X509Extension.targetInformation, true, targetInformation);

    return gen.build(sigGen);
}
 

开发者ID:credentials,
项目名称:irma_future_id,
代码行数:57,
代码来源:AttrCertSelectorTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)