Package com.maverick.crypto.asn1

Examples of com.maverick.crypto.asn1.DERInputStream


                        {
                            buf.append(new KeyUsage((DERBitString)dIn.readObject()) + nl);
                        }
                        else if (oid.equals(MiscObjectIdentifiers.netscapeCertType))
                        {
                            buf.append(new NetscapeCertType((DERBitString)dIn.readObject()) + nl);
                        }
                        else if (oid.equals(MiscObjectIdentifiers.netscapeRevocationURL))
                        {
                            buf.append(new NetscapeRevocationURL((DERIA5String)dIn.readObject()) + nl);
                        }
View Full Code Here


                        {
                            buf.append(new NetscapeCertType((DERBitString)dIn.readObject()) + nl);
                        }
                        else if (oid.equals(MiscObjectIdentifiers.netscapeRevocationURL))
                        {
                            buf.append(new NetscapeRevocationURL((DERIA5String)dIn.readObject()) + nl);
                        }
                        else if (oid.equals(MiscObjectIdentifiers.verisignCzagExtension))
                        {
                            buf.append(new VerisignCzagExtension((DERIA5String)dIn.readObject()) + nl);
                        }
View Full Code Here

                        {
                            buf.append(new NetscapeRevocationURL((DERIA5String)dIn.readObject()) + nl);
                        }
                        else if (oid.equals(MiscObjectIdentifiers.verisignCzagExtension))
                        {
                            buf.append(new VerisignCzagExtension((DERIA5String)dIn.readObject()) + nl);
                        }
                        else
                        {
                            buf.append(oid.getId());
                            buf.append(" value = " + ASN1Dump.dumpAsString(dIn.readObject()) + nl);
View Full Code Here

        }
    }

    protected void parse(byte[] token) throws IOException {
        ByteArrayInputStream tokenStream = new ByteArrayInputStream(token);
        DERInputStream der = new DERInputStream(tokenStream);
        ASN1TaggedObject tagged = (ASN1TaggedObject) der.readObject();
        ASN1Sequence sequence = ASN1Sequence.getInstance(tagged, true);
        Enumeration fields = sequence.getObjects();
        while (fields.hasMoreElements()) {
            tagged = (ASN1TaggedObject) fields.nextElement();
            switch (tagged.getTagNo()) {
View Full Code Here

        }
    }

    protected void parse(byte[] token) throws IOException {
        ByteArrayInputStream tokenStream = new ByteArrayInputStream(token);
        DERInputStream der = new DERInputStream(tokenStream);
        DERUnknownTag constructed = (DERUnknownTag) der.readObject();
        if (constructed.getTag() !=
                (DERTags.CONSTRUCTED | DERTags.APPLICATION)) {
            throw new IOException("Malformed NegTokenInit.");
        }
        tokenStream = new ByteArrayInputStream(constructed.getData());
        der = new DERInputStream(tokenStream);
        DERObjectIdentifier spnego = (DERObjectIdentifier) der.readObject();
        ASN1TaggedObject tagged = (ASN1TaggedObject) der.readObject();
        ASN1Sequence sequence = ASN1Sequence.getInstance(tagged, true);
        Enumeration fields = sequence.getObjects();
        while (fields.hasMoreElements()) {
            tagged = (ASN1TaggedObject) fields.nextElement();
            switch (tagged.getTagNo()) {
View Full Code Here

        throws IOException, ParseException {
        // full fractional seconds
        Date myDate = new Date(1101980374187L);
        byte[] encoded =
            new DerOutputStream(gTime, myDate).encoded;
        DerInputStream dis = useInputStream
        ? new DerInputStream(new ByteArrayInputStream(encoded))
        : new DerInputStream(encoded);
        assertEquals("full", myDate, gTime.decode(dis));

        // 2 digit fractional seconds (last 0 must be trimmed out)
        myDate = new Date(1101980374180L);
        encoded =
            new DerOutputStream(gTime, myDate).encoded;
        dis = useInputStream
        ? new DerInputStream(new ByteArrayInputStream(encoded))
        : new DerInputStream(encoded);
        assertEquals("2 fraction", myDate, gTime.decode(dis));

        // 1 digit fractional seconds (last 2 0s must be trimmed out)
        myDate = new Date(1101980374100L);
        encoded =
            new DerOutputStream(gTime, myDate).encoded;
        dis = useInputStream
        ? new DerInputStream(new ByteArrayInputStream(encoded))
        : new DerInputStream(encoded);
        assertEquals("1 fraction", myDate, gTime.decode(dis));

        // no fractional seconds (last 3 0s and "." must be trimmed out)
        myDate = new Date(1101980374000L);
        encoded =
            new DerOutputStream(gTime, myDate).encoded;
        dis = useInputStream
        ? new DerInputStream(new ByteArrayInputStream(encoded))
        : new DerInputStream(encoded);
        assertEquals("no fraction", myDate, gTime.decode(dis));

        // midnight
        myDate = new SimpleDateFormat("MM.dd.yyyy HH:mm").
            parse("06.06.2004 00:00");
        encoded =
            new DerOutputStream(gTime, myDate).encoded;
        dis = useInputStream
        ? new DerInputStream(new ByteArrayInputStream(encoded))
        : new DerInputStream(encoded);
        assertEquals("midnight", myDate, gTime.decode(dis));

        // date 100 ms
        myDate = new Date(100L);
        encoded =
            new DerOutputStream(gTime, myDate).encoded;
        dis = useInputStream
        ? new DerInputStream(new ByteArrayInputStream(encoded))
        : new DerInputStream(encoded);
        assertEquals("100ms", myDate, gTime.decode(dis));
    }
View Full Code Here

    private final void runTest(boolean useInputStream)
        throws IOException, ParseException {
        Date myDate = new Date(1101980374187L);
        byte[] encoded =
            new DerOutputStream(uTime, myDate).encoded;
        DerInputStream dis = useInputStream
        ? new DerInputStream(new ByteArrayInputStream(encoded))
        : new DerInputStream(encoded);
        // the difference only fractional-seconds
        assertEquals(187, (myDate.getTime()-((Date)uTime.decode(dis)).getTime()));

        // midnight
        myDate = new SimpleDateFormat("MM.dd.yyyy HH:mm").
            parse("06.06.2004 00:00");
        encoded =
            new DerOutputStream(uTime, myDate).encoded;
        dis = useInputStream
        ? new DerInputStream(new ByteArrayInputStream(encoded))
        : new DerInputStream(encoded);
        assertEquals(myDate, uTime.decode(dis));
    }
View Full Code Here

        throws IOException, ParseException {
        // full fractional seconds
        Date myDate = new Date(1101980374187L);
        byte[] encoded =
            new DerOutputStream(gTime, myDate).encoded;
        DerInputStream dis = useInputStream
        ? new DerInputStream(new ByteArrayInputStream(encoded))
        : new DerInputStream(encoded);
        assertEquals("full", myDate, gTime.decode(dis));

        // 2 digit fractional seconds (last 0 must be trimmed out)
        myDate = new Date(1101980374180L);
        encoded =
            new DerOutputStream(gTime, myDate).encoded;
        dis = useInputStream
        ? new DerInputStream(new ByteArrayInputStream(encoded))
        : new DerInputStream(encoded);
        assertEquals("2 fraction", myDate, gTime.decode(dis));

        // 1 digit fractional seconds (last 2 0s must be trimmed out)
        myDate = new Date(1101980374100L);
        encoded =
            new DerOutputStream(gTime, myDate).encoded;
        dis = useInputStream
        ? new DerInputStream(new ByteArrayInputStream(encoded))
        : new DerInputStream(encoded);
        assertEquals("1 fraction", myDate, gTime.decode(dis));

        // no fractional seconds (last 3 0s and "." must be trimmed out)
        myDate = new Date(1101980374000L);
        encoded =
            new DerOutputStream(gTime, myDate).encoded;
        dis = useInputStream
        ? new DerInputStream(new ByteArrayInputStream(encoded))
        : new DerInputStream(encoded);
        assertEquals("no fraction", myDate, gTime.decode(dis));

        // midnight
        myDate = new SimpleDateFormat("MM.dd.yyyy HH:mm").
            parse("06.06.2004 00:00");
        encoded =
            new DerOutputStream(gTime, myDate).encoded;
        dis = useInputStream
        ? new DerInputStream(new ByteArrayInputStream(encoded))
        : new DerInputStream(encoded);
        assertEquals("midnight", myDate, gTime.decode(dis));

        // date 100 ms
        myDate = new Date(100L);
        encoded =
            new DerOutputStream(gTime, myDate).encoded;
        dis = useInputStream
        ? new DerInputStream(new ByteArrayInputStream(encoded))
        : new DerInputStream(encoded);
        assertEquals("100ms", myDate, gTime.decode(dis));
    }
View Full Code Here

        this.hexString = hexString;
        this.encoded = encoded;

        try {
            DerInputStream in = new DerInputStream(encoded);

            tag = in.tag;

            if (DirectoryString.ASN1.checkTag(tag)) {
                // has string representation
View Full Code Here

                socket.receive(resp);

                bytesRead = resp.getLength();
                out.write(buf, resp.getOffset(), bytesRead);
            }
            DerInputStream in = new DerInputStream(out.toByteArray());

            if (in.tag == KDCReply.AS_REP_ASN1.constrId) { //TODO AS reply
                throw new RuntimeException();//FIXME
            } else if (in.tag == KerberosErrorMessage.ASN1.constrId) {
                KerberosErrorMessage errMsg = KerberosErrorMessage.decode(in);
View Full Code Here

TOP

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

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.