Package com.maverick.crypto.asn1

Examples of com.maverick.crypto.asn1.BERInputStream


                       || oid.getId().equals("2.5.29.19"))
                    {
                        continue;
                    }

                    X509Extension       ext = extensions.getExtension(oid);

                    if (ext.isCritical())
                    {
                        return true;
                    }
                }
            }
View Full Code Here


            }

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

                if (ext.getValue() != null)
                {
                    byte[]                  octs = ext.getValue().getOctets();
                    ByteArrayInputStream    bIn = new ByteArrayInputStream(octs);
                    DERInputStream          dIn = new DERInputStream(bIn);
                    buf.append("                       critical(" + ext.isCritical() + ") ");
                    try
                    {
                        if (oid.equals(X509Extensions.BasicConstraints))
                        {
                            buf.append(new BasicConstraints((ASN1Sequence)dIn.readObject()) + nl);
View Full Code Here

    public X509Extension[] getCriticalExtensionOIDs()
    {
        if (this.getVersion() == 3)
        {
            Vector         set = new Vector();
            X509Extensions  extensions = c.getTBSCertificate().getExtensions();

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

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

                    if (ext.isCritical())
                    {
                        set.addElement(oid.getId());
                    }
View Full Code Here

        return null;
    }

    private byte[] getExtensionBytes(String oid)
    {
        X509Extensions exts = c.getTBSCertificate().getExtensions();

        if (exts != null)
        {
            X509Extension   ext = exts.getExtension(new DERObjectIdentifier(oid));
            if (ext != null)
            {
                return ext.getValue().getOctets();
            }
        }
View Full Code Here

        return null;
    }

    public byte[] getExtensionValue(String oid)
    {
        X509Extensions exts = c.getTBSCertificate().getExtensions();

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

            if (ext != null)
            {
                ByteArrayOutputStream    bOut = new ByteArrayOutputStream();
                DEROutputStream            dOut = new DEROutputStream(bOut);
View Full Code Here

    public X509Extension[] getNonCriticalExtensionOIDs()
    {
        if (this.getVersion() == 3)
        {
            Vector         set = new Vector();
            X509Extensions  extensions = c.getTBSCertificate().getExtensions();

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

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

                    if (!ext.isCritical())
                    {
                        set.addElement(oid.getId());
                    }
View Full Code Here

    public boolean hasUnsupportedCriticalExtension()
    {
        if (this.getVersion() == 3)
        {
            X509Extensions  extensions = c.getTBSCertificate().getExtensions();

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

                while (e.hasMoreElements())
                {
                    DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
                    if (oid.getId().equals("2.5.29.15")
                       || oid.getId().equals("2.5.29.19"))
                    {
                        continue;
                    }

                    X509Extension       ext = extensions.getExtension(oid);

                    if (ext.isCritical())
                    {
                        return true;
                    }
View Full Code Here

            {
                buf.append("                       " + new String(Hex.encode(sig, i, sig.length - i)) + nl);
            }
        }

        X509Extensions  extensions = c.getTBSCertificate().getExtensions();

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

            if (e.hasMoreElements())
            {
                buf.append("       Extensions: \n");
            }

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

                if (ext.getValue() != null)
                {
                    byte[]                  octs = ext.getValue().getOctets();
                    ByteArrayInputStream    bIn = new ByteArrayInputStream(octs);
View Full Code Here

                        BigInteger.valueOf(0xFFFFFF) }, };

        // positive testcases
        for (int i = 0; i < testcase.length; i++) {
            try {
                BerInputStream in = new BerInputStream(
                        new ByteArrayInputStream((byte[]) testcase[i][0]));

                int expected = ((BigInteger) testcase[i][1]).intValue();

                assertEquals(expected, in.getLength());
            } catch (IOException e) {
                e.printStackTrace();
                fail("Testcase: " + i + "\nUnexpected exception." + e);
            }
        }

        // negative testcase
        try {
            new BerInputStream(new ByteArrayInputStream(new byte[] { 0x30,
                    (byte) 0x84, 0x01, 0x01, 0x01, 0x01 }));
            fail("No expected ASN1Exception");
        } catch (ASN1Exception e) {
            assertTrue(e.getMessage().startsWith("Too long"));
        }
View Full Code Here

                0x06, 0x02, 0x01, 0x03, // oid bytes
                0x01, 0x00 // just random bytes
        };

        // pass boolean encoding
        BerInputStream in = new BerInputStream(encoded, 0, 3);
        assertEquals("boolean", 1, in.getLength());

        // pass oid encoding
        in = new BerInputStream(encoded, 3, 4);
        assertEquals("boolean", 2, in.getLength());

        // pass random encoding (equals to ANY)
        in = new BerInputStream(encoded, 7, 2);
        assertEquals("any", 0, in.getLength());

        // extra bytes for oid
        try {
            new BerInputStream(encoded, 3, 5);
            fail("No expected ASN1Exception");
        } catch (ASN1Exception e) {
            assertEquals("Wrong content length", e.getMessage());
        }

        // less bytes for oid
        try {
            new BerInputStream(encoded, 3, 3);
            fail("No expected ASN1Exception");
        } catch (ASN1Exception e) {
            assertEquals("Wrong content length", e.getMessage());
        }
    }
View Full Code Here

TOP

Related Classes of com.maverick.crypto.asn1.BERInputStream

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.