Package jcifs.spnego.asn1

Examples of jcifs.spnego.asn1.DERInputStream


        return decodeOIDDERObjectIdentifier(oid).getId();
    }

    public static DERObjectIdentifier decodeOIDDERObjectIdentifier(byte[] oid) throws IOException {
        ByteArrayInputStream bIn = new ByteArrayInputStream(oid);
        DERInputStream dIn = new DERInputStream(bIn);

        return (DERObjectIdentifier) dIn.readObject();
    }
View Full Code Here


        return decodeOIDDERObjectIdentifier(oid).getId();
    }

    public static DERObjectIdentifier decodeOIDDERObjectIdentifier(byte[] oid) throws IOException {
        ByteArrayInputStream bIn = new ByteArrayInputStream(oid);
        DERInputStream dIn = new DERInputStream(bIn);

        return (DERObjectIdentifier) dIn.readObject();
    }
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

        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

    public void testDecode_Valid() throws IOException {

        for (int i = 0; i < testcases.length; i++) {
            try {
                DerInputStream in = new DerInputStream((byte[]) testcases[i][1]);
                assertEquals("Test case: " + i, testcases[i][0], sequence
                        .decode(in));
            } catch (ASN1Exception e) {
                fail("Test case: " + i + "\n" + e.getMessage());
            }
View Full Code Here

                        "Method getDecodedObject MUST not be invoked");
            }
        };

        for (int i = 0; i < testcases.length; i++) {
            DerInputStream in = new DerInputStream((byte[]) testcases[i][1]);
            in.setVerify();
            seqVerify.decode(in);
        }
    }
View Full Code Here

TOP

Related Classes of jcifs.spnego.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.