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


Java Extensions.getExtension方法代码示例

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


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

示例1: getExtensionValue

import org.bouncycastle.asn1.x509.Extensions; //导入方法依赖的package包/类
public byte[] getExtensionValue(String oid) 
{
    Extensions extensions = cert.getAcinfo().getExtensions();

    if (extensions != null)
    {
        Extension ext = extensions.getExtension(new ASN1ObjectIdentifier(oid));

        if (ext != null)
        {
            try
            {
                return ext.getExtnValue().getEncoded(ASN1Encoding.DER);
            }
            catch (Exception e)
            {
                throw new RuntimeException("error encoding " + e.toString());
            }
        }
    }

    return null;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:24,代码来源:X509V2AttributeCertificate.java

示例2: getExtensionOIDs

import org.bouncycastle.asn1.x509.Extensions; //导入方法依赖的package包/类
private Set getExtensionOIDs(
    boolean critical) 
{
    Extensions  extensions = cert.getAcinfo().getExtensions();

    if (extensions != null)
    {
        Set             set = new HashSet();
        Enumeration     e = extensions.oids();

        while (e.hasMoreElements())
        {
            ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier)e.nextElement();
            Extension            ext = extensions.getExtension(oid);

            if (ext.isCritical() == critical)
            {
                set.add(oid.getId());
            }
        }

        return set;
    }

    return null;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:27,代码来源:X509V2AttributeCertificate.java

示例3: getExtensionValue

import org.bouncycastle.asn1.x509.Extensions; //导入方法依赖的package包/类
public byte[] getExtensionValue(String oid) 
{
    Extensions exts = c.getTBSCertificate().getExtensions();

    if (exts != null)
    {
        Extension   ext = exts.getExtension(new ASN1ObjectIdentifier(oid));

        if (ext != null)
        {
            try
            {
                return ext.getExtnValue().getEncoded();
            }
            catch (Exception e)
            {
                throw new IllegalStateException("error parsing " + e.toString());
            }
        }
    }

    return null;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:24,代码来源:X509CertificateObject.java

示例4: getExtensionValue

import org.bouncycastle.asn1.x509.Extensions; //导入方法依赖的package包/类
public byte[] getExtensionValue(String oid)
{
    Extensions exts = c.getTBSCertList().getExtensions();

    if (exts != null)
    {
        Extension ext = exts.getExtension(new ASN1ObjectIdentifier(oid));

        if (ext != null)
        {
            try
            {
                return ext.getExtnValue().getEncoded();
            }
            catch (Exception e)
            {
                throw new IllegalStateException("error parsing " + e.toString());
            }
        }
    }

    return null;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:24,代码来源:X509CRLObject.java

示例5: getExtensionOIDs

import org.bouncycastle.asn1.x509.Extensions; //导入方法依赖的package包/类
private Set getExtensionOIDs(boolean critical)
{
    Extensions extensions = c.getExtensions();

    if (extensions != null)
    {
        Set set = new HashSet();
        Enumeration e = extensions.oids();

        while (e.hasMoreElements())
        {
            ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier) e.nextElement();
            Extension ext = extensions.getExtension(oid);

            if (critical == ext.isCritical())
            {
                set.add(oid.getId());
            }
        }

        return set;
    }

    return null;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:26,代码来源:X509CRLEntryObject.java

示例6: isIndirectCRL

import org.bouncycastle.asn1.x509.Extensions; //导入方法依赖的package包/类
private static boolean isIndirectCRL(Extensions extensions)
{
    if (extensions == null)
    {
        return false;
    }

    Extension ext = extensions.getExtension(Extension.issuingDistributionPoint);

    return ext != null && IssuingDistributionPoint.getInstance(ext.getParsedValue()).isIndirectCRL();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:12,代码来源:X509CRLHolder.java

示例7: getExtension

import org.bouncycastle.asn1.x509.Extensions; //导入方法依赖的package包/类
/**
 * Look up the extension associated with the passed in OID.
 *
 * @param oid the OID of the extension of interest.
 *
 * @return the extension if present, null otherwise.
 */
public Extension getExtension(ASN1ObjectIdentifier oid)
{
    Extensions extensions = entry.getExtensions();

    if (extensions != null)
    {
        return extensions.getExtension(oid);
    }

    return null;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:19,代码来源:X509CRLEntryHolder.java

示例8: generateIssuedCertificate

import org.bouncycastle.asn1.x509.Extensions; //导入方法依赖的package包/类
/**
 * Generates an issued {@link X509Certificate} from the given issuer certificate and {@link KeyPair}
 *
 * @param dn the distinguished name to use
 * @param publicKey the public key to issue the certificate to
 * @param extensions extensions extracted from the CSR
 * @param issuer the issuer's certificate
 * @param issuerKeyPair the issuer's keypair
 * @param signingAlgorithm the signing algorithm to use
 * @param days the number of days it should be valid for
 * @return an issued {@link X509Certificate} from the given issuer certificate and {@link KeyPair}
 * @throws CertificateException if there is an error issuing the certificate
 */
public static X509Certificate generateIssuedCertificate(String dn, PublicKey publicKey, Extensions extensions, X509Certificate issuer, KeyPair issuerKeyPair, String signingAlgorithm, int days)
        throws CertificateException {
    try {
        ContentSigner sigGen = new JcaContentSignerBuilder(signingAlgorithm).setProvider(BouncyCastleProvider.PROVIDER_NAME).build(issuerKeyPair.getPrivate());
        SubjectPublicKeyInfo subPubKeyInfo = SubjectPublicKeyInfo.getInstance(publicKey.getEncoded());
        Date startDate = new Date();
        Date endDate = new Date(startDate.getTime() + TimeUnit.DAYS.toMillis(days));

        X509v3CertificateBuilder certBuilder = new X509v3CertificateBuilder(
                reverseX500Name(new X500Name(issuer.getSubjectX500Principal().getName())),
                getUniqueSerialNumber(),
                startDate, endDate,
                reverseX500Name(new X500Name(dn)),
                subPubKeyInfo);

        certBuilder.addExtension(Extension.subjectKeyIdentifier, false, new JcaX509ExtensionUtils().createSubjectKeyIdentifier(publicKey));

        certBuilder.addExtension(Extension.authorityKeyIdentifier, false, new JcaX509ExtensionUtils().createAuthorityKeyIdentifier(issuerKeyPair.getPublic()));
        // Set certificate extensions
        // (1) digitalSignature extension
        certBuilder.addExtension(Extension.keyUsage, true,
                new KeyUsage(KeyUsage.digitalSignature | KeyUsage.keyEncipherment | KeyUsage.dataEncipherment | KeyUsage.keyAgreement | KeyUsage.nonRepudiation));

        certBuilder.addExtension(Extension.basicConstraints, false, new BasicConstraints(false));

        // (2) extendedKeyUsage extension
        certBuilder.addExtension(Extension.extendedKeyUsage, false, new ExtendedKeyUsage(new KeyPurposeId[]{KeyPurposeId.id_kp_clientAuth, KeyPurposeId.id_kp_serverAuth}));

        // (3) subjectAlternativeName
        if(extensions != null && extensions.getExtension(Extension.subjectAlternativeName) != null) {
            certBuilder.addExtension(Extension.subjectAlternativeName, false, extensions.getExtensionParsedValue(Extension.subjectAlternativeName));
        }

        X509CertificateHolder certificateHolder = certBuilder.build(sigGen);
        return new JcaX509CertificateConverter().setProvider(BouncyCastleProvider.PROVIDER_NAME).getCertificate(certificateHolder);
    } catch (CertIOException | NoSuchAlgorithmException | OperatorCreationException e) {
        throw new CertificateException(e);
    }
}
 
开发者ID:apache,项目名称:nifi-registry,代码行数:53,代码来源:CertificateUtils.java

示例9: getExtensionBytes

import org.bouncycastle.asn1.x509.Extensions; //导入方法依赖的package包/类
private byte[] getExtensionBytes(String oid)
{
    Extensions exts = c.getTBSCertificate().getExtensions();

    if (exts != null)
    {
        Extension   ext = exts.getExtension(new ASN1ObjectIdentifier(oid));
        if (ext != null)
        {
            return ext.getExtnValue().getOctets();
        }
    }

    return null;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:16,代码来源:X509CertificateObject.java

示例10: getNonCriticalExtensionOIDs

import org.bouncycastle.asn1.x509.Extensions; //导入方法依赖的package包/类
public Set getNonCriticalExtensionOIDs() 
{
    if (this.getVersion() == 3)
    {
        Set             set = new HashSet();
        Extensions  extensions = c.getTBSCertificate().getExtensions();

        if (extensions != null)
        {
            Enumeration     e = extensions.oids();

            while (e.hasMoreElements())
            {
                ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier)e.nextElement();
                Extension       ext = extensions.getExtension(oid);

                if (!ext.isCritical())
                {
                    set.add(oid.getId());
                }
            }

            return set;
        }
    }

    return null;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:29,代码来源:X509CertificateObject.java

示例11: getExtensionOIDs

import org.bouncycastle.asn1.x509.Extensions; //导入方法依赖的package包/类
private Set getExtensionOIDs(boolean critical)
{
    if (this.getVersion() == 2)
    {
        Extensions extensions = c.getTBSCertList().getExtensions();

        if (extensions != null)
        {
            Set set = new HashSet();
            Enumeration e = extensions.oids();

            while (e.hasMoreElements())
            {
                ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier)e.nextElement();
                Extension ext = extensions.getExtension(oid);

                if (critical == ext.isCritical())
                {
                    set.add(oid.getId());
                }
            }

            return set;
        }
    }

    return null;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:29,代码来源:X509CRLObject.java

示例12: getExtension

import org.bouncycastle.asn1.x509.Extensions; //导入方法依赖的package包/类
private Extension getExtension(ASN1ObjectIdentifier oid)
{
    Extensions exts = c.getExtensions();

    if (exts != null)
    {
        return exts.getExtension(oid);
    }

    return null;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:12,代码来源:X509CRLEntryObject.java

示例13: getCriticalExtensionOIDs

import org.bouncycastle.asn1.x509.Extensions; //导入方法依赖的package包/类
public Set getCriticalExtensionOIDs() 
{
    if (this.getVersion() == 3)
    {
        Set             set = new HashSet();
        Extensions  extensions = c.getTBSCertificate().getExtensions();

        if (extensions != null)
        {
            Enumeration     e = extensions.oids();

            while (e.hasMoreElements())
            {
                ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier)e.nextElement();
                Extension       ext = extensions.getExtension(oid);

                if (ext.isCritical())
                {
                    set.add(oid.getId());
                }
            }

            return set;
        }
    }

    return null;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:29,代码来源:X509CertificateObject.java

示例14: hasUnsupportedCriticalExtension

import org.bouncycastle.asn1.x509.Extensions; //导入方法依赖的package包/类
public boolean hasUnsupportedCriticalExtension()
{
    if (this.getVersion() == 3)
    {
        Extensions  extensions = c.getTBSCertificate().getExtensions();

        if (extensions != null)
        {
            Enumeration     e = extensions.oids();

            while (e.hasMoreElements())
            {
                ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier)e.nextElement();
                String              oidId = oid.getId();

                if (oidId.equals(RFC3280CertPathUtilities.KEY_USAGE)
                 || oidId.equals(RFC3280CertPathUtilities.CERTIFICATE_POLICIES)
                 || oidId.equals(RFC3280CertPathUtilities.POLICY_MAPPINGS)
                 || oidId.equals(RFC3280CertPathUtilities.INHIBIT_ANY_POLICY)
                 || oidId.equals(RFC3280CertPathUtilities.CRL_DISTRIBUTION_POINTS)
                 || oidId.equals(RFC3280CertPathUtilities.ISSUING_DISTRIBUTION_POINT)
                 || oidId.equals(RFC3280CertPathUtilities.DELTA_CRL_INDICATOR)
                 || oidId.equals(RFC3280CertPathUtilities.POLICY_CONSTRAINTS)
                 || oidId.equals(RFC3280CertPathUtilities.BASIC_CONSTRAINTS)
                 || oidId.equals(RFC3280CertPathUtilities.SUBJECT_ALTERNATIVE_NAME)
                 || oidId.equals(RFC3280CertPathUtilities.NAME_CONSTRAINTS))
                {
                    continue;
                }

                Extension       ext = extensions.getExtension(oid);

                if (ext.isCritical())
                {
                    return true;
                }
            }
        }
    }

    return false;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:43,代码来源:X509CertificateObject.java

示例15: toString

import org.bouncycastle.asn1.x509.Extensions; //导入方法依赖的package包/类
public String toString()
{
    StringBuffer buf = new StringBuffer();
    String nl = System.getProperty("line.separator");

    buf.append("      userCertificate: ").append(this.getSerialNumber()).append(nl);
    buf.append("       revocationDate: ").append(this.getRevocationDate()).append(nl);
    buf.append("       certificateIssuer: ").append(this.getCertificateIssuer()).append(nl);

    Extensions extensions = c.getExtensions();

    if (extensions != null)
    {
        Enumeration e = extensions.oids();
        if (e.hasMoreElements())
        {
            buf.append("   crlEntryExtensions:").append(nl);

            while (e.hasMoreElements())
            {
                ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier)e.nextElement();
                Extension ext = extensions.getExtension(oid);
                if (ext.getExtnValue() != null)
                {
                    byte[]                  octs = ext.getExtnValue().getOctets();
                    ASN1InputStream dIn = new ASN1InputStream(octs);
                    buf.append("                       critical(").append(ext.isCritical()).append(") ");
                    try
                    {
                        if (oid.equals(X509Extension.reasonCode))
                        {
                            buf.append(CRLReason.getInstance(ASN1Enumerated.getInstance(dIn.readObject()))).append(nl);
                        }
                        else if (oid.equals(X509Extension.certificateIssuer))
                        {
                            buf.append("Certificate issuer: ").append(GeneralNames.getInstance(dIn.readObject())).append(nl);
                        }
                        else 
                        {
                            buf.append(oid.getId());
                            buf.append(" value = ").append(ASN1Dump.dumpAsString(dIn.readObject())).append(nl);
                        }
                    }
                    catch (Exception ex)
                    {
                        buf.append(oid.getId());
                        buf.append(" value = ").append("*****").append(nl);
                    }
                }
                else
                {
                    buf.append(nl);
                }
            }
        }
    }

    return buf.toString();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:60,代码来源:X509CRLEntryObject.java


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