• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Extensions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: generateOCSPRequest

import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
/**
 * Generates an OCSP request using BouncyCastle.
 * @param issuerCert	certificate of the issues
 * @param serialNumber	serial number
 * @return	an OCSP request
 * @throws OCSPException
 * @throws IOException
 */
private static OCSPReq generateOCSPRequest(X509Certificate issuerCert, BigInteger serialNumber) throws OCSPException, IOException, OperatorException, CertificateEncodingException {
    //Add provider BC
    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    
    JcaDigestCalculatorProviderBuilder digestCalculatorProviderBuilder = new JcaDigestCalculatorProviderBuilder();
    DigestCalculatorProvider digestCalculatorProvider = digestCalculatorProviderBuilder.build();
    DigestCalculator digestCalculator = digestCalculatorProvider.get(CertificateID.HASH_SHA1);
    // Generate the id for the certificate we are looking for
    CertificateID id = new CertificateID(digestCalculator, new JcaX509CertificateHolder(issuerCert), serialNumber);
    
    // basic request generation with nonce
    OCSPReqBuilder gen = new OCSPReqBuilder();
    
    gen.addRequest(id);
    
    // create details for nonce extension
    Extension ext = new Extension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce, false, new DEROctetString(new DEROctetString(PdfEncryption.createDocumentId()).getEncoded()));
    gen.setRequestExtensions(new Extensions(new Extension[]{ext}));
    
    return gen.build();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:30,代码来源:OcspClientBouncyCastle.java


示例2: 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


示例3: 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


示例4: 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


示例5: 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


示例6: 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


示例7: validateKeyUsage

import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
static void validateKeyUsage(org.bouncycastle.asn1.x509.Certificate c, int keyUsageBits)
    throws IOException
{
    Extensions exts = c.getTBSCertificate().getExtensions();
    if (exts != null)
    {
        KeyUsage ku = KeyUsage.fromExtensions(exts);
        if (ku != null)
        {
            int bits = ku.getBytes()[0] & 0xff;
            if ((bits & keyUsageBits) != keyUsageBits)
            {
                throw new TlsFatalAlert(AlertDescription.certificate_unknown);
            }
        }
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:18,代码来源:TlsUtils.java


示例8: TSTInfo

import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
public TSTInfo(ASN1ObjectIdentifier tsaPolicyId, MessageImprint messageImprint,
        ASN1Integer serialNumber, ASN1GeneralizedTime genTime,
        Accuracy accuracy, ASN1Boolean ordering, ASN1Integer nonce,
        GeneralName tsa, Extensions extensions)
{
    version = new ASN1Integer(1);
    this.tsaPolicyId = tsaPolicyId;
    this.messageImprint = messageImprint;
    this.serialNumber = serialNumber;
    this.genTime = genTime;

    this.accuracy = accuracy;
    this.ordering = ordering;
    this.nonce = nonce;
    this.tsa = tsa;
    this.extensions = extensions;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:18,代码来源:TSTInfo.java


示例9: TimeStampReq

import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
public TimeStampReq(
    MessageImprint      messageImprint,
    ASN1ObjectIdentifier tsaPolicy,
    ASN1Integer          nonce,
    ASN1Boolean          certReq,
    Extensions      extensions)
{
    // default
    version = new ASN1Integer(1);

    this.messageImprint = messageImprint;
    this.tsaPolicy = tsaPolicy;
    this.nonce = nonce;
    this.certReq = certReq;
    this.extensions = extensions;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:17,代码来源:TimeStampReq.java


示例10: getExtensionValue

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

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

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

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


示例11: getExtensionsFromCSR

import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
/**
 * Extract extensions from CSR object
 */
public static Extensions getExtensionsFromCSR(JcaPKCS10CertificationRequest csr) {
    Attribute[] attributess = csr.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest);
    for (Attribute attribute : attributess) {
        ASN1Set attValue = attribute.getAttrValues();
        if (attValue != null) {
            ASN1Encodable extension = attValue.getObjectAt(0);
            if (extension instanceof Extensions) {
                return (Extensions) extension;
            } else if (extension instanceof DERSequence) {
                return Extensions.getInstance(extension);
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:nifi-registry,代码行数:19,代码来源:CertificateUtils.java


示例12: extractX509CSRIPAddresses

import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
public static List<String> extractX509CSRIPAddresses(PKCS10CertificationRequest certReq) {
   
    List<String> ipAddresses = new ArrayList<>();
    Attribute[] attributes = certReq.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest);
    for (Attribute attribute : attributes) {
        for (ASN1Encodable value : attribute.getAttributeValues()) {
            Extensions extensions = Extensions.getInstance(value);
            GeneralNames gns = GeneralNames.fromExtensions(extensions, Extension.subjectAlternativeName);
            for (GeneralName name : gns.getNames()) {
                if (name.getTagNo() == GeneralName.iPAddress) {
                    try {
                        InetAddress addr = InetAddress.getByAddress(((DEROctetString) name.getName()).getOctets());
                        ipAddresses.add(addr.getHostAddress());
                    } catch (UnknownHostException e) {
                    }
                }
            }
        }
    }
    return ipAddresses;
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:22,代码来源:Crypto.java


示例13: getCriticalExtensionOIDs

import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
static Set getCriticalExtensionOIDs(Extensions extensions)
{
    if (extensions == null)
    {
        return EMPTY_SET;
    }

    return Collections.unmodifiableSet(new HashSet(Arrays.asList(extensions.getCriticalExtensionOIDs())));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:10,代码来源:CertUtils.java


示例14: getNonCriticalExtensionOIDs

import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
static Set getNonCriticalExtensionOIDs(Extensions extensions)
{
    if (extensions == null)
    {
        return EMPTY_SET;
    }

    // TODO: should probably produce a set that imposes correct ordering
    return Collections.unmodifiableSet(new HashSet(Arrays.asList(extensions.getNonCriticalExtensionOIDs())));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:11,代码来源:CertUtils.java


示例15: getExtensionOIDs

import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
static List getExtensionOIDs(Extensions extensions)
{
    if (extensions == null)
    {
        return EMPTY_LIST;
    }

    return Collections.unmodifiableList(Arrays.asList(extensions.getExtensionOIDs()));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:10,代码来源:CertUtils.java


示例16: 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


示例17: 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


示例18: BasicOCSPResp

import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
public BasicOCSPResp(
    BasicOCSPResponse   resp)
{
    this.resp = resp;
    this.data = resp.getTbsResponseData();
    this.extensions = Extensions.getInstance(resp.getTbsResponseData().getResponseExtensions());
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:8,代码来源:BasicOCSPResp.java


示例19: RequestObject

import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
public RequestObject(
    CertificateID   certId,
    Extensions  extensions)
{
    this.certId = certId;
    this.extensions = extensions;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:8,代码来源:OCSPReqBuilder.java


示例20: addRequest

import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
/**
 * Add a request with extensions
 * 
 * @param certId certificate ID of interest
 * @param singleRequestExtensions the extensions to attach to the request
 */
public OCSPReqBuilder addRequest(
    CertificateID   certId,
    Extensions singleRequestExtensions)
{
    list.add(new RequestObject(certId, singleRequestExtensions));

    return this;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:15,代码来源:OCSPReqBuilder.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NetworkConfig类代码示例发布时间:2022-05-21
下一篇:
Java DataBlockEncoder类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap