Package org.apache.harmony.security.asn1

Examples of org.apache.harmony.security.asn1.ASN1Explicit


    };

    public void testDecode_Valid() throws IOException {

        for (int i = 0; i < testcases.length; i++) {
            DerInputStream in = new DerInputStream((byte[]) testcases[i][1]);
            assertEquals("Test case: " + i, testcases[i][0], choice.decode(in));
        }
    }
View Full Code Here


     */
    public void testDecodeEncode() throws Exception {

        // decoding byte array
        for (int i = 0; i < validUTCTimes.length; i++) {
            DerInputStream in = new DerInputStream((byte[]) validUTCTimes[i][1]);
            assertEquals("Decoding array for " + validUTCTimes[i][0],
                    validUTCTimes[i][2], //expected
                    utime.decode(in)); //decoded
        }

        // decoding input stream
        for (int i = 0; i < validUTCTimes.length; i++) {
            DerInputStream in = new DerInputStream(new ByteArrayInputStream(
                    (byte[]) validUTCTimes[i][1]));
            assertEquals("Decoding stream for " + validUTCTimes[i][0],
                    validUTCTimes[i][2], //expected
                    utime.decode(in)); //decoded
        }
View Full Code Here

                    new ASN1Implicit(ASN1Constants.CLASS_PRIVATE, 5, sequence) } };

    public void testDecode_Valid() throws IOException {

        for (int i = 0; i < taggedType.length; i++) {
            DerInputStream in = new DerInputStream((byte[]) taggedType[i][1]);
            assertEquals("Test case: " + i, taggedType[i][0],
                    ((ASN1Type) taggedType[i][2]).decode(in));
        }
    }
View Full Code Here

     */
    public void test_Decode_Encode() throws Exception {

        // decoding byte array
        for (int i = 0; i < validGeneralizedTimes.length; i++) {
            DerInputStream in = new DerInputStream(
                    (byte[]) validGeneralizedTimes[i][1]);
            assertEquals("Decoding array for " + validGeneralizedTimes[i][0],
                    validGeneralizedTimes[i][2], //expected
                    gtime.decode(in)); //decoded
        }

        // decoding input stream
        for (int i = 0; i < validGeneralizedTimes.length; i++) {
            DerInputStream in = new DerInputStream(new ByteArrayInputStream(
                    (byte[]) validGeneralizedTimes[i][1]));
            assertEquals("Decoding stream for " + validGeneralizedTimes[i][0],
                    validGeneralizedTimes[i][2], //expected
                    gtime.decode(in)); //decoded
        }
View Full Code Here

        ASN1Oid asn1 = ASN1Oid.getInstance();

        // testing decoding
        for (int i = 0; i < oid.length; i++) {

            int[] decoded = (int[]) asn1.decode(new DerInputStream(
                    (byte[]) oid[i][2]));

            assertTrue("Failed to decode oid: " + oid[i][0], // error message
                    Arrays.equals((int[]) oid[i][1], // expected array
                            decoded));
View Full Code Here

        //FIXME new byte[] { 0x06, 0x02, (byte) 0x80, (byte) 0x01 }
        };

        for (int i = 0; i < invalid.length; i++) {
            try {
                DerInputStream in = new DerInputStream(invalid[i]);
                ASN1Oid.getInstance().decode(in);
                fail("No expected ASN1Exception for:" + i);
            } catch (ASN1Exception e) {
            }
        }
View Full Code Here

       
        // testing decoding
        for (int i = 0; i < oid.length; i++) {
            assertEquals("Failed to decode oid: " + oid[i][0], // error message
                    oid[i][0], // expected string
                    asn1.decode(new DerInputStream((byte[]) oid[i][2])));
        }

        // testing encoding
        for (int i = 0; i < oid.length; i++) {
            assertTrue("Failed to encode oid: " + oid[i][0], // error message
View Full Code Here

    }

    private static byte[] encoded = new byte[] { 0x01, 0x03, 0x11, 0x13, 0x15 };

    public void testDecode() throws IOException {
        DerInputStream in = new DerInputStream(encoded);
        assertTrue(Arrays.equals(encoded, (byte[]) ASN1Any.getInstance()
                .decode(in)));
    }
View Full Code Here

        this.ticket = ticket;
        this.encPart = encPart;
    }

    public void decrypt(SecretKey key) throws IOException {
        DerInputStream in = new DerInputStream(new ByteArrayInputStream(encPart
                .decrypt(key)));

        Object[] values = (Object[]) ENC_AS_REP_PART.decode(in);

        this.key = (EncryptionKey) values[0];
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
                KDCReply reply = (KDCReply) KDCReply.AS_REP_ASN1.decode(in);

                KerberosKey key = new KerberosKey(new KerberosPrincipal(cname
View Full Code Here

TOP

Related Classes of org.apache.harmony.security.asn1.ASN1Explicit

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.