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


Java ASN1Encodable类代码示例

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


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

示例1: getUnprotectedAttrs

import org.bouncycastle.asn1.ASN1Encodable; //导入依赖的package包/类
public ASN1SetParser getUnprotectedAttrs()
    throws IOException
{
    if (_nextObject == null)
    {
        _nextObject = _seq.readObject();
    }
    
    
    if (_nextObject != null)
    {
        ASN1Encodable o = _nextObject;
        _nextObject = null;
        return (ASN1SetParser)((ASN1TaggedObjectParser)o).getObjectParser(BERTags.SET, false);
    }
    
    return null;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:19,代码来源:EnvelopedDataParser.java

示例2: extractDigesetAlgFromSigAlg

import org.bouncycastle.asn1.ASN1Encodable; //导入依赖的package包/类
public static AlgorithmIdentifier extractDigesetAlgFromSigAlg( AlgorithmIdentifier sigAlgId)
        throws NoSuchAlgorithmException {
    ASN1ObjectIdentifier algOid = sigAlgId.getAlgorithm();

    ASN1ObjectIdentifier digestAlgOid;
    if (PKCSObjectIdentifiers.id_RSASSA_PSS.equals(algOid)) {
        ASN1Encodable asn1Encodable = sigAlgId.getParameters();
        RSASSAPSSparams param = RSASSAPSSparams.getInstance(asn1Encodable);
        digestAlgOid = param.getHashAlgorithm().getAlgorithm();
    } else {
        HashAlgoType digestAlg = sigAlgOidToDigestMap.get(algOid);
        if (digestAlg == null) {
            throw new NoSuchAlgorithmException("unknown signature algorithm " + algOid.getId());
        }
        digestAlgOid = digestAlg.oid();
    }

    return new AlgorithmIdentifier(digestAlgOid, DERNull.INSTANCE);
}
 
开发者ID:xipki,项目名称:xitk,代码行数:20,代码来源:AlgorithmUtil.java

示例3: matchesDN

import org.bouncycastle.asn1.ASN1Encodable; //导入依赖的package包/类
private boolean matchesDN(X500Principal subject, GeneralNames targets)
{
    GeneralName[] names = targets.getNames();

    for (int i = 0; i != names.length; i++)
    {
        GeneralName gn = names[i];

        if (gn.getTagNo() == GeneralName.directoryName)
        {
            try
            {
                if (new X500Principal(((ASN1Encodable)gn.getName()).toASN1Primitive().getEncoded()).equals(subject))
                {
                    return true;
                }
            }
            catch (IOException e)
            {
            }
        }
    }

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

示例4: matchesDN

import org.bouncycastle.asn1.ASN1Encodable; //导入依赖的package包/类
private boolean matchesDN(X509Principal subject, GeneralNames targets)
{
    GeneralName[] names = targets.getNames();

    for (int i = 0; i != names.length; i++)
    {
        GeneralName gn = names[i];

        if (gn.getTagNo() == GeneralName.directoryName)
        {
            try
            {
                if (new X509Principal(((ASN1Encodable)gn.getName()).toASN1Primitive()
                    .getEncoded()).equals(subject))
                {
                    return true;
                }
            }
            catch (IOException e)
            {
            }
        }
    }

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

示例5: getNames

import org.bouncycastle.asn1.ASN1Encodable; //导入依赖的package包/类
private Object[] getNames(GeneralName[] names)
{
    List l = new ArrayList(names.length);

    for (int i = 0; i != names.length; i++)
    {
        if (names[i].getTagNo() == GeneralName.directoryName)
        {
            try
            {
                l.add(new X500Principal(
                    ((ASN1Encodable)names[i].getName()).toASN1Primitive().getEncoded()));
            }
            catch (IOException e)
            {
                throw new RuntimeException("badly formed Name object");
            }
        }
    }

    return l.toArray(new Object[l.size()]);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:23,代码来源:AttributeCertificateHolder.java

示例6: copyAndAddExtension

import org.bouncycastle.asn1.ASN1Encodable; //导入依赖的package包/类
/**
 * add a given extension field for the standard extensions tag (tag 3)
 * copying the extension value from another certificate.
 * @throws CertificateParsingException if the extension cannot be extracted.
 */
public void copyAndAddExtension(
    String          oid,
    boolean         critical,
    X509Certificate cert) 
    throws CertificateParsingException
{
    byte[] extValue = cert.getExtensionValue(oid);
    
    if (extValue == null)
    {
        throw new CertificateParsingException("extension " + oid + " not present");
    }
    
    try
    {
        ASN1Encodable value = X509ExtensionUtil.fromExtensionValue(extValue);

        this.addExtension(oid, critical, value);
    }
    catch (IOException e)
    {
        throw new CertificateParsingException(e.toString());
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:30,代码来源:X509V3CertificateGenerator.java

示例7: generateServerCertificate

import org.bouncycastle.asn1.ASN1Encodable; //导入依赖的package包/类
public static X500PrivateCredential generateServerCertificate(KeyPair caKeyPair) throws NoSuchAlgorithmException, CertificateException, OperatorCreationException, CertIOException {
    X500Name issuerName = new X500Name("CN=bouncrca");
    X500Name subjectName = new X500Name("CN=bouncr");
    BigInteger serial = BigInteger.valueOf(2);
    long t1 = System.currentTimeMillis();
    KeyPairGenerator rsa = KeyPairGenerator.getInstance("RSA");
    rsa.initialize(2048, SecureRandom.getInstance("NativePRNGNonBlocking"));
    KeyPair kp = rsa.generateKeyPair();
    System.out.println(System.currentTimeMillis() - t1);

    X509v3CertificateBuilder builder = new JcaX509v3CertificateBuilder(issuerName, serial, NOT_BEFORE, NOT_AFTER, subjectName, kp.getPublic());
    DERSequence subjectAlternativeNames = new DERSequence(new ASN1Encodable[] {
            new GeneralName(GeneralName.dNSName, "localhost"),
            new GeneralName(GeneralName.dNSName, "127.0.0.1")
    });
    builder.addExtension(Extension.subjectAlternativeName, false, subjectAlternativeNames);
    X509Certificate cert = signCertificate(builder, caKeyPair.getPrivate());

    return new X500PrivateCredential(cert, kp.getPrivate());
}
 
开发者ID:kawasima,项目名称:bouncr,代码行数:21,代码来源:Certificate.java

示例8: getAlgorithmIdentifier

import org.bouncycastle.asn1.ASN1Encodable; //导入依赖的package包/类
AlgorithmIdentifier getAlgorithmIdentifier(ASN1ObjectIdentifier encryptionOID, AlgorithmParameters params)
    throws CRMFException
{
    ASN1Encodable asn1Params;
    if (params != null)
    {
        try
        {
            asn1Params = ASN1Primitive.fromByteArray(params.getEncoded("ASN.1"));
        }
        catch (IOException e)
        {
            throw new CRMFException("cannot encode parameters: " + e.getMessage(), e);
        }
    }
    else
    {
        asn1Params = DERNull.INSTANCE;
    }

    return new AlgorithmIdentifier(
        encryptionOID,
        asn1Params);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:CRMFHelper.java

示例9: addCRL

import org.bouncycastle.asn1.ASN1Encodable; //导入依赖的package包/类
/**
 * Add the CRLEntry objects contained in a previous CRL.
 * 
 * @param other the X509CRLHolder to source the other entries from.
 * @return the current builder.
 */
public X509v2CRLBuilder addCRL(X509CRLHolder other)
{
    TBSCertList revocations = other.toASN1Structure().getTBSCertList();

    if (revocations != null)
    {
        for (Enumeration en = revocations.getRevokedCertificateEnumeration(); en.hasMoreElements();)
        {
            tbsGen.addCRLEntry(ASN1Sequence.getInstance(((ASN1Encodable)en.nextElement()).toASN1Primitive()));
        }
    }

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

示例10: EncKeyWithID

import org.bouncycastle.asn1.ASN1Encodable; //导入依赖的package包/类
private EncKeyWithID(ASN1Sequence seq)
{
    this.privKeyInfo = PrivateKeyInfo.getInstance(seq.getObjectAt(0));

    if (seq.size() > 1)
    {
        if (!(seq.getObjectAt(1) instanceof DERUTF8String))
        {
            this.identifier = GeneralName.getInstance(seq.getObjectAt(1));
        }
        else
        {
            this.identifier = (ASN1Encodable)seq.getObjectAt(1);
        }
    }
    else
    {
        this.identifier = null;
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:21,代码来源:EncKeyWithID.java

示例11: addExtension

import org.bouncycastle.asn1.ASN1Encodable; //导入依赖的package包/类
/**
 * Add a given extension field for the standard extensions tag (tag 3)
 *
 * @param oid the OID defining the extension type.
 * @param isCritical true if the extension is critical, false otherwise.
 * @param value the ASN.1 structure that forms the extension's value.
 * @return this builder object.
 */
public X509v3CertificateBuilder addExtension(
    ASN1ObjectIdentifier oid,
    boolean isCritical,
    ASN1Encodable value)
    throws CertIOException
{
    CertUtils.addExtension(extGenerator, oid, isCritical, value);

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

示例12: getExtensionsFromCSR

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

示例13: checkSignature

import org.bouncycastle.asn1.ASN1Encodable; //导入依赖的package包/类
private void checkSignature(
    PublicKey key, 
    Signature signature) 
    throws CertificateException, NoSuchAlgorithmException, 
        SignatureException, InvalidKeyException
{
    if (!isAlgIdEqual(c.getSignatureAlgorithm(), c.getTBSCertificate().getSignature()))
    {
        throw new CertificateException("signature algorithm in TBS cert not same as outer cert");
    }

    ASN1Encodable params = c.getSignatureAlgorithm().getParameters();

    // TODO This should go after the initVerify?
    X509SignatureUtil.setSignatureParameters(signature, params);

    signature.initVerify(key);

    signature.update(this.getTBSCertificate());

    if (!signature.verify(this.getSignature()))
    {
        throw new SignatureException("certificate does not verify with supplied key");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:26,代码来源:X509CertificateObject.java

示例14: getCertificates

import org.bouncycastle.asn1.ASN1Encodable; //导入依赖的package包/类
Store getCertificates(ASN1Set certSet)
{
    if (certSet != null)
    {
        List certList = new ArrayList(certSet.size());

        for (Enumeration en = certSet.getObjects(); en.hasMoreElements();)
        {
            ASN1Primitive obj = ((ASN1Encodable)en.nextElement()).toASN1Primitive();

            if (obj instanceof ASN1Sequence)
            {
                certList.add(new X509CertificateHolder(Certificate.getInstance(obj)));
            }
        }

        return new CollectionStore(certList);
    }

    return new CollectionStore(new ArrayList());
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:22,代码来源:CMSSignedHelper.java

示例15: getAuthAttrs

import org.bouncycastle.asn1.ASN1Encodable; //导入依赖的package包/类
public ASN1SetParser getAuthAttrs()
    throws IOException
{
    if (nextObject == null)
    {
        nextObject = seq.readObject();
    }

    if (nextObject instanceof ASN1TaggedObjectParser)
    {
        ASN1Encodable o = nextObject;
        nextObject = null;
        return (ASN1SetParser)((ASN1TaggedObjectParser)o).getObjectParser(BERTags.SET, false);
    }

    // TODO
    // "The authAttrs MUST be present if the content type carried in
    // EncryptedContentInfo is not id-data."

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


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