Java 类org.bouncycastle.asn1.x509.X509Extension 实例源码

项目:signer-source    文件:DerEncoder.java   
public static OCSPReq GenOcspReq(X509Certificate nextCert,
        X509Certificate nextIssuer) throws OCSPException {

    OCSPReqGenerator ocspRequestGenerator = new OCSPReqGenerator();
    CertificateID certId = new CertificateID(CertificateID.HASH_SHA1,
            nextIssuer, nextCert.getSerialNumber());
    ocspRequestGenerator.addRequest(certId);

    BigInteger nonce = BigInteger.valueOf(System.currentTimeMillis());
    Vector<DERObjectIdentifier> oids = new Vector<DERObjectIdentifier>();
    Vector<X509Extension> values = new Vector<X509Extension>();

    oids.add(OCSPObjectIdentifiers.id_pkix_ocsp_nonce);
    values.add(new X509Extension(false, new DEROctetString(nonce
            .toByteArray())));

    ocspRequestGenerator.setRequestExtensions(new X509Extensions(oids,
            values));
    return ocspRequestGenerator.generate();
}
项目:ipack    文件:RespData.java   
private Set getExtensionOIDs(boolean critical)
{
    Set             set = new HashSet();
    X509Extensions  extensions = this.getResponseExtensions();

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

        while (e.hasMoreElements())
        {
            DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
            X509Extension       ext = extensions.getExtension(oid);

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

    return set;
}
项目:ipack    文件:RespData.java   
public byte[] getExtensionValue(String oid)
{
    X509Extensions exts = this.getResponseExtensions();

    if (exts != null)
    {
        X509Extension   ext = exts.getExtension(new DERObjectIdentifier(oid));

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

    return null;
}
项目:ipack    文件:OCSPReq.java   
private Set getExtensionOIDs(boolean critical)
{
    Set             set = new HashSet();
    X509Extensions  extensions = this.getRequestExtensions();

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

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

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

    return set;
}
项目:ipack    文件:OCSPReq.java   
public byte[] getExtensionValue(String oid)
{
    X509Extensions exts = this.getRequestExtensions();

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

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

    return null;
}
项目:ipack    文件:Req.java   
private Set getExtensionOIDs(boolean critical)
{
    Set             set = new HashSet();
    X509Extensions  extensions = this.getSingleRequestExtensions();

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

        while (e.hasMoreElements())
        {
            DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
            X509Extension       ext = extensions.getExtension(oid);

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

    return set;
}
项目:ipack    文件:Req.java   
public byte[] getExtensionValue(String oid)
{
    X509Extensions exts = this.getSingleRequestExtensions();

    if (exts != null)
    {
        X509Extension   ext = exts.getExtension(new DERObjectIdentifier(oid));

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

    return null;
}
项目:ipack    文件:BasicOCSPResp.java   
private Set getExtensionOIDs(boolean critical)
{
    Set             set = new HashSet();
    X509Extensions  extensions = this.getResponseExtensions();

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

        while (e.hasMoreElements())
        {
            DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
            X509Extension       ext = extensions.getExtension(oid);

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

    return set;
}
项目:ipack    文件:BasicOCSPResp.java   
public byte[] getExtensionValue(String oid)
{
    X509Extensions exts = this.getResponseExtensions();

    if (exts != null)
    {
        X509Extension   ext = exts.getExtension(new DERObjectIdentifier(oid));

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

    return null;
}
项目:ipack    文件:SingleResp.java   
private Set getExtensionOIDs(boolean critical)
{
    Set             set = new HashSet();
    X509Extensions  extensions = this.getSingleExtensions();

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

        while (e.hasMoreElements())
        {
            DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
            X509Extension       ext = extensions.getExtension(oid);

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

    return set;
}
项目:ipack    文件:SingleResp.java   
public byte[] getExtensionValue(String oid)
{
    X509Extensions exts = this.getSingleExtensions();

    if (exts != null)
    {
        X509Extension   ext = exts.getExtension(new DERObjectIdentifier(oid));

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

    return null;
}
项目:Direct-File-Downloader    文件:X509V2AttributeCertificate.java   
private Set getExtensionOIDs(
    boolean critical) 
{
    X509Extensions  extensions = cert.getAcinfo().getExtensions();

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

        while (e.hasMoreElements())
        {
            DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
            X509Extension       ext = extensions.getExtension(oid);

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

        return set;
    }

    return null;
}
项目:Direct-File-Downloader    文件:X509CRLObject.java   
private Set getExtensionOIDs(boolean critical)
{
    if (this.getVersion() == 2)
    {
        HashSet         set = new HashSet();
        X509Extensions  extensions = c.getTBSCertList().getExtensions();
        Enumeration     e = extensions.oids();

        while (e.hasMoreElements())
        {
            DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
            X509Extension       ext = extensions.getExtension(oid);

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

        return set;
    }

    return null;
}
项目:Direct-File-Downloader    文件:X509CRLEntryObject.java   
private Set getExtensionOIDs(boolean critical)
{
    X509Extensions extensions = c.getExtensions();

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

        while (e.hasMoreElements())
        {
            DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
            X509Extension       ext = extensions.getExtension(oid);

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

        return set;
    }

    return null;
}
项目:Direct-File-Downloader    文件:X509CRLEntryObject.java   
public byte[] getExtensionValue(String oid)
{
    X509Extensions exts = c.getExtensions();

    if (exts != null)
    {
        X509Extension ext = exts.getExtension(new DERObjectIdentifier(oid));

        if (ext != null)
        {
            return ext.getValue().getOctets();
        }
    }

    return null;
}
项目:gwt-crypto    文件:CMSTestUtil.java   
public static X509CertificateHolder makeCertificate(AsymmetricCipherKeyPair subKP, String _subDN, AsymmetricCipherKeyPair issKP, String _issDN, boolean _ca)
    throws IOException, OperatorCreationException
{
    RSAKeyParameters lwPubKey = (RSAKeyParameters)subKP.getPublic();

    X509v3CertificateBuilder v3CertGen = new X509v3CertificateBuilder(
        new X500Name(_issDN),
        allocateSerialNumber(),
        new Date(System.currentTimeMillis()),
        new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 100)),
        new X500Name(_subDN),
        new SubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE), new RSAPublicKey(lwPubKey.getModulus(), lwPubKey.getExponent()))
    );

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

    ContentSigner sigGen = new BcRSAContentSignerBuilder(sigAlgId, digAlgId).build((AsymmetricKeyParameter)issKP.getPrivate());

    v3CertGen.addExtension(
        X509Extension.basicConstraints,
        false,
        new BasicConstraints(_ca));

    return v3CertGen.build(sigGen);
}
项目:signer-source    文件:DerEncoder.java   
public static OCSPReq GenOcspReq(X509Certificate nextCert,
        X509Certificate nextIssuer) throws OCSPException {

    OCSPReqGenerator ocspRequestGenerator = new OCSPReqGenerator();
    CertificateID certId = new CertificateID(CertificateID.HASH_SHA1,
            nextIssuer, nextCert.getSerialNumber());
    ocspRequestGenerator.addRequest(certId);

    BigInteger nonce = BigInteger.valueOf(System.currentTimeMillis());
    Vector<DERObjectIdentifier> oids = new Vector<DERObjectIdentifier>();
    Vector<X509Extension> values = new Vector<X509Extension>();

    oids.add(OCSPObjectIdentifiers.id_pkix_ocsp_nonce);
    values.add(new X509Extension(false, new DEROctetString(nonce
            .toByteArray())));

    ocspRequestGenerator.setRequestExtensions(new X509Extensions(oids,
            values));
    return ocspRequestGenerator.generate();
}
项目:oiosaml.java    文件:SecurityHelper.java   
public static X509Certificate generateCertificate(Credential credential, String entityId) throws Exception {
    X500Name issuer = new X500Name("o=keymanager, ou=oiosaml-sp");
    BigInteger serialNumber = BigInteger.valueOf(System.currentTimeMillis());
    Date notBefore = new Date();
    Date notAfter = new Date(System.currentTimeMillis() + 1000L * 60L * 60L * 24L * 365L * 10L);
    X500Name subject = new X500Name("cn=" + entityId + ", ou=oiosaml-sp");

    ByteArrayInputStream bIn = new ByteArrayInputStream(credential.getPublicKey().getEncoded());
    SubjectPublicKeyInfo publicKeyInfo = new SubjectPublicKeyInfo((ASN1Sequence)new ASN1InputStream(bIn).readObject());

    X509v3CertificateBuilder gen = new X509v3CertificateBuilder(issuer, serialNumber, notBefore, notAfter, subject, publicKeyInfo);

    gen.addExtension(X509Extension.subjectKeyIdentifier, false, new JcaX509ExtensionUtils().createSubjectKeyIdentifier(credential.getPublicKey()));
    gen.addExtension(X509Extension.authorityKeyIdentifier, false, new JcaX509ExtensionUtils().createAuthorityKeyIdentifier(credential.getPublicKey()));

    ContentSigner sigGen = new JcaContentSignerBuilder("SHA1withRSA").setProvider("BC").build(credential.getPrivateKey());
    X509CertificateHolder certificateHolder = gen.build(sigGen);

    X509Certificate x509Certificate = new JcaX509CertificateConverter().setProvider("BC").getCertificate(certificateHolder);
    return x509Certificate;
}
项目:testarea-itext5    文件:RsaSsaPss.java   
/**
 * create a basic X509 certificate from the given keys
 */
static X509Certificate makeCertificate(
    KeyPair subKP,
    String  subDN,
    KeyPair issKP,
    String  issDN)
    throws GeneralSecurityException, IOException, OperatorCreationException
{
    PublicKey  subPub  = subKP.getPublic();
    PrivateKey issPriv = issKP.getPrivate();
    PublicKey  issPub  = issKP.getPublic();

    X509v3CertificateBuilder v3CertGen = new JcaX509v3CertificateBuilder(new X500Name(issDN), BigInteger.valueOf(serialNo++), new Date(System.currentTimeMillis()), new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 100)), new X500Name(subDN), subPub);

    v3CertGen.addExtension(
        X509Extension.subjectKeyIdentifier,
        false,
        createSubjectKeyId(subPub));

    v3CertGen.addExtension(
        X509Extension.authorityKeyIdentifier,
        false,
        createAuthorityKeyId(issPub));

    return new JcaX509CertificateConverter().setProvider("BC").getCertificate(v3CertGen.build(new JcaContentSignerBuilder("MD5withRSA").setProvider("BC").build(issPriv)));
}
项目:AcademicTorrents-Downloader    文件:X509V2AttributeCertificate.java   
private Set getExtensionOIDs(
    boolean critical) 
{
    X509Extensions  extensions = cert.getAcinfo().getExtensions();

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

        while (e.hasMoreElements())
        {
            DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
            X509Extension       ext = extensions.getExtension(oid);

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

        return set;
    }

    return null;
}
项目:AcademicTorrents-Downloader    文件:X509CRLObject.java   
private Set getExtensionOIDs(boolean critical)
{
    if (this.getVersion() == 2)
    {
        HashSet         set = new HashSet();
        X509Extensions  extensions = c.getTBSCertList().getExtensions();
        Enumeration     e = extensions.oids();

        while (e.hasMoreElements())
        {
            DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
            X509Extension       ext = extensions.getExtension(oid);

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

        return set;
    }

    return null;
}
项目:AcademicTorrents-Downloader    文件:X509CRLEntryObject.java   
private Set getExtensionOIDs(boolean critical)
{
    X509Extensions extensions = c.getExtensions();

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

        while (e.hasMoreElements())
        {
            DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
            X509Extension       ext = extensions.getExtension(oid);

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

        return set;
    }

    return null;
}
项目:AcademicTorrents-Downloader    文件:X509CRLEntryObject.java   
public byte[] getExtensionValue(String oid)
{
    X509Extensions exts = c.getExtensions();

    if (exts != null)
    {
        X509Extension ext = exts.getExtension(new DERObjectIdentifier(oid));

        if (ext != null)
        {
            return ext.getValue().getOctets();
        }
    }

    return null;
}
项目:CryptMeme    文件:RespData.java   
private Set getExtensionOIDs(boolean critical)
{
    Set             set = new HashSet();
    X509Extensions  extensions = this.getResponseExtensions();

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

        while (e.hasMoreElements())
        {
            DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
            X509Extension       ext = extensions.getExtension(oid);

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

    return set;
}
项目:CryptMeme    文件:RespData.java   
public byte[] getExtensionValue(String oid)
{
    X509Extensions exts = this.getResponseExtensions();

    if (exts != null)
    {
        X509Extension   ext = exts.getExtension(new DERObjectIdentifier(oid));

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

    return null;
}
项目:CryptMeme    文件:OCSPReq.java   
private Set getExtensionOIDs(boolean critical)
{
    Set             set = new HashSet();
    X509Extensions  extensions = this.getRequestExtensions();

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

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

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

    return set;
}
项目:CryptMeme    文件:OCSPReq.java   
public byte[] getExtensionValue(String oid)
{
    X509Extensions exts = this.getRequestExtensions();

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

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

    return null;
}
项目:CryptMeme    文件:Req.java   
private Set getExtensionOIDs(boolean critical)
{
    Set             set = new HashSet();
    X509Extensions  extensions = this.getSingleRequestExtensions();

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

        while (e.hasMoreElements())
        {
            DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
            X509Extension       ext = extensions.getExtension(oid);

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

    return set;
}
项目:CryptMeme    文件:Req.java   
public byte[] getExtensionValue(String oid)
{
    X509Extensions exts = this.getSingleRequestExtensions();

    if (exts != null)
    {
        X509Extension   ext = exts.getExtension(new DERObjectIdentifier(oid));

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

    return null;
}
项目:CryptMeme    文件:BasicOCSPResp.java   
private Set getExtensionOIDs(boolean critical)
{
    Set             set = new HashSet();
    X509Extensions  extensions = this.getResponseExtensions();

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

        while (e.hasMoreElements())
        {
            DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
            X509Extension       ext = extensions.getExtension(oid);

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

    return set;
}
项目:CryptMeme    文件:BasicOCSPResp.java   
public byte[] getExtensionValue(String oid)
{
    X509Extensions exts = this.getResponseExtensions();

    if (exts != null)
    {
        X509Extension   ext = exts.getExtension(new DERObjectIdentifier(oid));

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

    return null;
}
项目:CryptMeme    文件:SingleResp.java   
private Set getExtensionOIDs(boolean critical)
{
    Set             set = new HashSet();
    X509Extensions  extensions = this.getSingleExtensions();

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

        while (e.hasMoreElements())
        {
            DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
            X509Extension       ext = extensions.getExtension(oid);

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

    return set;
}
项目:CryptMeme    文件:SingleResp.java   
public byte[] getExtensionValue(String oid)
{
    X509Extensions exts = this.getSingleExtensions();

    if (exts != null)
    {
        X509Extension   ext = exts.getExtension(new DERObjectIdentifier(oid));

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

    return null;
}
项目:irma_future_id    文件:CMSTestUtil.java   
public static X509CertificateHolder makeCertificate(AsymmetricCipherKeyPair subKP, String _subDN, AsymmetricCipherKeyPair issKP, String _issDN, boolean _ca)
    throws IOException, OperatorCreationException
{
    RSAKeyParameters lwPubKey = (RSAKeyParameters)subKP.getPublic();

    X509v3CertificateBuilder v3CertGen = new X509v3CertificateBuilder(
        new X500Name(_issDN),
        allocateSerialNumber(),
        new Date(System.currentTimeMillis()),
        new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 100)),
        new X500Name(_subDN),
        new SubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE), new RSAPublicKey(lwPubKey.getModulus(), lwPubKey.getExponent()))
    );

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

    ContentSigner sigGen = new BcRSAContentSignerBuilder(sigAlgId, digAlgId).build((AsymmetricKeyParameter)issKP.getPrivate());

    v3CertGen.addExtension(
        X509Extension.basicConstraints,
        false,
        new BasicConstraints(_ca));

    return v3CertGen.build(sigGen);
}
项目:irma_future_id    文件:CreateSignedMail.java   
/**
 * create a basic X509 certificate from the given keys
 */
static X509Certificate makeCertificate(
    KeyPair subKP,
    String  subDN,
    KeyPair issKP,
    String  issDN)
    throws GeneralSecurityException, IOException, OperatorCreationException
{
    PublicKey  subPub  = subKP.getPublic();
    PrivateKey issPriv = issKP.getPrivate();
    PublicKey  issPub  = issKP.getPublic();

    X509v3CertificateBuilder v3CertGen = new JcaX509v3CertificateBuilder(new X500Name(issDN), BigInteger.valueOf(serialNo++), new Date(System.currentTimeMillis()), new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 100)), new X500Name(subDN), subPub);

    v3CertGen.addExtension(
        X509Extension.subjectKeyIdentifier,
        false,
        createSubjectKeyId(subPub));

    v3CertGen.addExtension(
        X509Extension.authorityKeyIdentifier,
        false,
        createAuthorityKeyId(issPub));

    return new JcaX509CertificateConverter().setProvider("BC").getCertificate(v3CertGen.build(new JcaContentSignerBuilder("MD5withRSA").setProvider("BC").build(issPriv)));
}
项目:irma_future_id    文件:ValidateSignedMail.java   
protected static TrustAnchor getTrustAnchor(String trustcert)
        throws Exception
{
    X509Certificate cert = loadCert(trustcert);
    if (cert != null)
    {
        byte[] ncBytes = cert
                .getExtensionValue(X509Extension.nameConstraints.getId());

        if (ncBytes != null)
        {
            ASN1Encodable extValue = X509ExtensionUtil
                    .fromExtensionValue(ncBytes);
            return new TrustAnchor(cert, extValue.toASN1Primitive().getEncoded(ASN1Encoding.DER));
        }
        return new TrustAnchor(cert, null);
    }
    return null;
}
项目:irma_future_id    文件:SignedMailValidatorTest.java   
private TrustAnchor getTrustAnchor(String trustcert) throws Exception
{
    X509Certificate cert = loadCert(trustcert);
    if (cert != null)
    {
        byte[] ncBytes = cert
                .getExtensionValue(X509Extension.nameConstraints.getId());

        if (ncBytes != null)
        {
            ASN1Encodable extValue = X509ExtensionUtil
                    .fromExtensionValue(ncBytes);
            return new TrustAnchor(cert, extValue.toASN1Primitive().getEncoded(ASN1Encoding.DER));
        }
        return new TrustAnchor(cert, null);
    }
    return null;
}
项目:irma_future_id    文件:RespData.java   
private Set getExtensionOIDs(boolean critical)
{
    Set             set = new HashSet();
    X509Extensions  extensions = this.getResponseExtensions();

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

        while (e.hasMoreElements())
        {
            DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
            X509Extension       ext = extensions.getExtension(oid);

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

    return set;
}
项目:irma_future_id    文件:RespData.java   
public byte[] getExtensionValue(String oid)
{
    X509Extensions exts = this.getResponseExtensions();

    if (exts != null)
    {
        X509Extension   ext = exts.getExtension(new DERObjectIdentifier(oid));

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

    return null;
}
项目:irma_future_id    文件:OCSPReq.java   
private Set getExtensionOIDs(boolean critical)
{
    Set             set = new HashSet();
    X509Extensions  extensions = this.getRequestExtensions();

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

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

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

    return set;
}