Package org.bouncycastle.asn1.x509

Examples of org.bouncycastle.asn1.x509.CertificatePolicies


        v.add(tbsCrl);
        v.add(sigAlgId);
        v.add(new DERBitString(sig.sign()));

        return new X509CRLObject(new CertificateList(new DERSequence(v)));
    }
View Full Code Here


        InputStream in)
        throws IOException
    {
        DERInputStream  dIn = new DERInputStream(in);

        return new X509CRLObject(new CertificateList((ASN1Sequence)dIn.readObject()));
    }
View Full Code Here

        PublicKey           intPubKey  = fact.generatePublic(intPubKeySpec);
        PrivateKey          privKey    = fact.generatePrivate(privKeySpec);
        PublicKey           pubKey     = fact.generatePublic(pubKeySpec);
       
        X509Certificate     trustCert       = createTrustCert(caPubKey, caPrivKey);
        CertificatePolicies intPolicies     = null;
        Hashtable           map             = null;
        ASN1EncodableVector policies        = null;
        Set                 requirePolicies = null;
        X509Certificate     intCert         = null;
        X509Certificate     endCert         = null;
       
        /**
         * valid test_00
         */
        intPolicies = new CertificatePolicies(new PolicyInformation(new ASN1ObjectIdentifier("2.5.29.32.0")));
        map = new Hashtable();
        map.put("2.16.840.1.101.3.2.1.48.1","2.16.840.1.101.3.2.1.48.2");
        intCert = createIntmedCert(intPubKey, caPrivKey, caPubKey, intPolicies, map);
       
        policies   = new ASN1EncodableVector();
        policies.add(new PolicyInformation(new ASN1ObjectIdentifier("2.16.840.1.101.3.2.1.48.2")));
        endCert = createEndEntityCert(pubKey, intPrivKey, intPubKey, policies);
       
        requirePolicies = null;
        String msg = testPolicies(0, trustCert, intCert, endCert, requirePolicies, true);
        checkMessage(0, msg, "");
       
        /**
         * test_01
         */
        intPolicies = new CertificatePolicies(new PolicyInformation(new ASN1ObjectIdentifier("2.5.29.32.0")));
        map = new Hashtable();
        map.put("2.16.840.1.101.3.2.1.48.1","2.16.840.1.101.3.2.1.48.2");
        intCert = createIntmedCert(intPubKey, caPrivKey, caPubKey, intPolicies, map);
       
        policies   = new ASN1EncodableVector();
        policies.add(new PolicyInformation(new ASN1ObjectIdentifier("2.16.840.1.101.3.2.1.48.2")));
        endCert = createEndEntityCert(pubKey, intPrivKey, intPubKey, policies);
       
        requirePolicies = new HashSet();
        requirePolicies.add("2.16.840.1.101.3.2.1.48.1");
        msg = testPolicies(1, trustCert, intCert, endCert, requirePolicies, true);
        checkMessage(1, msg, "");
       
        /**
         * test_02
         */
        intPolicies = new CertificatePolicies(new PolicyInformation(new ASN1ObjectIdentifier("2.5.29.32.0")));
        map = new Hashtable();
        map.put("2.16.840.1.101.3.2.1.48.1","2.16.840.1.101.3.2.1.48.2");
        intCert = createIntmedCert(intPubKey, caPrivKey, caPubKey, intPolicies, map);
       
        policies   = new ASN1EncodableVector();
        policies.add(new PolicyInformation(new ASN1ObjectIdentifier("2.16.840.1.101.3.2.1.48.2")));
        endCert = createEndEntityCert(pubKey, intPrivKey, intPubKey, policies);
       
        requirePolicies = new HashSet();
        requirePolicies.add("2.5.29.32.0");
        msg = testPolicies(2, trustCert, intCert, endCert, requirePolicies, true);
        checkMessage(2, msg, "");
  
        /**
         * test_03
         */
        intPolicies = new CertificatePolicies(new PolicyInformation[]
            { new PolicyInformation(new ASN1ObjectIdentifier("2.16.840.1.101.3.2.1.48.3")),
              new PolicyInformation(new ASN1ObjectIdentifier("2.5.29.32.0")) });

        map = new Hashtable();
        map.put("2.16.840.1.101.3.2.1.48.1","2.16.840.1.101.3.2.1.48.2");
        intCert = createIntmedCert(intPubKey, caPrivKey, caPubKey, intPolicies, map);
       
        policies   = new ASN1EncodableVector();
        policies.add(new PolicyInformation(new ASN1ObjectIdentifier("2.16.840.1.101.3.2.1.48.2")));
        endCert = createEndEntityCert(pubKey, intPrivKey, intPubKey, policies);
       
        requirePolicies = new HashSet();
        requirePolicies.add("2.16.840.1.101.3.2.1.48.1");
        msg = testPolicies(3, trustCert, intCert, endCert, requirePolicies, true);
        checkMessage(3, msg, "");
       
        /**
         * test_04
         */
        intPolicies = new CertificatePolicies(new PolicyInformation[]
            { new PolicyInformation(new ASN1ObjectIdentifier("2.16.840.1.101.3.2.1.48.3")),
              new PolicyInformation(new ASN1ObjectIdentifier("2.5.29.32.0")) } );
        map = new Hashtable();
        map.put("2.16.840.1.101.3.2.1.48.1", "2.16.840.1.101.3.2.1.48.2");
        intCert = createIntmedCert(intPubKey, caPrivKey, caPubKey, intPolicies, map);
       
        policies   = new ASN1EncodableVector();
        policies.add(new PolicyInformation(new ASN1ObjectIdentifier("2.16.840.1.101.3.2.1.48.3")));
        endCert = createEndEntityCert(pubKey, intPrivKey, intPubKey, policies);
       
        requirePolicies = new HashSet();
        requirePolicies.add("2.16.840.1.101.3.2.1.48.3");
        msg = testPolicies(4, trustCert, intCert, endCert, requirePolicies, true);
        checkMessage(4, msg, "");
       
        /**
         * test_05
         */
        intPolicies = new CertificatePolicies(new PolicyInformation(new ASN1ObjectIdentifier("2.5.29.32.0")));
        map = new Hashtable();
        map.put("2.16.840.1.101.3.2.1.48.1", "2.16.840.1.101.3.2.1.48.2");
        intCert = createIntmedCert(intPubKey, caPrivKey, caPubKey, intPolicies, map);
       
        policies   = new ASN1EncodableVector();
        policies.add(new PolicyInformation(new ASN1ObjectIdentifier("2.16.840.1.101.3.2.1.48.2")));
        endCert = createEndEntityCert(pubKey, intPrivKey, intPubKey, policies);
       
        requirePolicies = new HashSet();
        requirePolicies.add("2.16.840.1.101.3.2.1.48.2");
        msg = testPolicies(5, trustCert, intCert, endCert, requirePolicies, false);
        checkMessage(5, msg, "Path processing failed on policy.");
       
        /**
         * test_06
         */
        intPolicies = new CertificatePolicies(new PolicyInformation(new ASN1ObjectIdentifier("2.5.29.32.0")));
        map = new Hashtable();
        map.put("2.16.840.1.101.3.2.1.48.1", "2.16.840.1.101.3.2.1.48.2");
        intCert = createIntmedCert(intPubKey, caPrivKey, caPubKey, intPolicies, map);
       
        policies   = new ASN1EncodableVector();
        policies.add(new PolicyInformation(new ASN1ObjectIdentifier("2.16.840.1.101.3.2.1.48.1")));
        endCert = createEndEntityCert(pubKey, intPrivKey, intPubKey, policies);
       
        requirePolicies = new HashSet();
        requirePolicies.add("2.16.840.1.101.3.2.1.48.1");
        msg = testPolicies(6, trustCert, intCert, endCert, requirePolicies, true);
        checkMessage(6, msg, "");
       
        /**
         * test_07
         */
        intPolicies = new CertificatePolicies(new PolicyInformation(new ASN1ObjectIdentifier("2.5.29.32.0")));
        map = new Hashtable();
        map.put("2.16.840.1.101.3.2.1.48.1", "2.16.840.1.101.3.2.1.48.2");
        intCert = createIntmedCert(intPubKey, caPrivKey, caPubKey, intPolicies, map);
       
        policies   = new ASN1EncodableVector();
        policies.add(new PolicyInformation(new ASN1ObjectIdentifier("2.16.840.1.101.3.2.1.48.2")));
        endCert = createEndEntityCert(pubKey, intPrivKey, intPubKey, policies);
       
        requirePolicies = new HashSet();
        requirePolicies.add("2.16.840.1.101.3.2.1.48.3");
        msg = testPolicies(7, trustCert, intCert, endCert, requirePolicies, false);
        checkMessage(7, msg, "Path processing failed on policy.");
       
        /**
         * test_08
         */
        intPolicies = new CertificatePolicies(new PolicyInformation(new ASN1ObjectIdentifier("2.5.29.32.0")));
        map = new Hashtable();
        map.put("2.16.840.1.101.3.2.1.48.1", "2.16.840.1.101.3.2.1.48.2");
        intCert = createIntmedCert(intPubKey, caPrivKey, caPubKey, intPolicies, map);
       
        policies   = new ASN1EncodableVector();
View Full Code Here

    {
        byte[]  hash = new byte[digest.getDigestSize()];

        digest.doFinal(hash, 0);

        DigestInfo  digInfo;
        byte[]      sig;

        try
        {
            sig = cipher.processBlock(sigBytes, 0, sigBytes.length);
            digInfo = derDecode(sig);
        }
        catch (Exception e)
        {
            return false;
        }

        if (!digInfo.getAlgorithmId().equals(algId))
        {
            return false;
        }

        byte[]  sigHash = digInfo.getDigest();

        if (hash.length != sigHash.length)
        {
            return false;
        }
View Full Code Here

        byte[]  hash)
        throws IOException
    {
        ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
        DEROutputStream         dOut = new DEROutputStream(bOut);
        DigestInfo              dInfo = new DigestInfo(algId, hash);

        dOut.writeObject(dInfo);

        return bOut.toByteArray();
    }
View Full Code Here

        throws IOException
    {
        ByteArrayInputStream    bIn = new ByteArrayInputStream(encoding);
        DERInputStream          dIn = new DERInputStream(bIn);

        return new DigestInfo((ASN1Sequence)dIn.readObject());
    }
View Full Code Here

    }

    private byte[] derEncode(ASN1ObjectIdentifier oid, byte[] hash) throws IOException
    {
        AlgorithmIdentifier algId = new AlgorithmIdentifier(oid, DERNull.INSTANCE);
        DigestInfo dInfo = new DigestInfo(algId, hash);

        return dInfo.getEncoded(ASN1Encoding.DER);
    }
View Full Code Here

        CRLDistPoint crldp, ExtendedPKIXParameters pkixParams)
        throws AnnotatedException
    {
        if (crldp != null)
        {
            DistributionPoint dps[] = null;
            try
            {
                dps = crldp.getDistributionPoints();
            }
            catch (Exception e)
View Full Code Here

                throw new AnnotatedException(
                    "Distribution points could not be read.", e);
            }
            for (int i = 0; i < dps.length; i++)
            {
                DistributionPointName dpn = dps[i].getDistributionPoint();
                // look for URIs in fullName
                if (dpn != null)
                {
                    if (dpn.getType() == DistributionPointName.FULL_NAME)
                    {
                        GeneralName[] genNames = GeneralNames.getInstance(
                            dpn.getName()).getNames();
                        // look for an URI
                        for (int j = 0; j < genNames.length; j++)
                        {
                            if (genNames[j].getTagNo() == GeneralName.uniformResourceIdentifier)
                            {
View Full Code Here

    {
        List issuers = new ArrayList();
        // indirect CRL
        if (dp.getCRLIssuer() != null)
        {
            GeneralName genNames[] = dp.getCRLIssuer().getNames();
            // look for a DN
            for (int j = 0; j < genNames.length; j++)
            {
                if (genNames[j].getTagNo() == GeneralName.directoryName)
                {
View Full Code Here

TOP

Related Classes of org.bouncycastle.asn1.x509.CertificatePolicies

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.