Examples of DerInputStream


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

    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

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

                        "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

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

        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

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

    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

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

        // oid decoder/encoder for testing
        ASN1Boolean asn1 = ASN1Boolean.getInstance();

        // decoding false
        DerInputStream in = new DerInputStream(eFalse);
        assertEquals("Decoding false value", Boolean.FALSE, asn1.decode(in));

        // decoding true
        in = new DerInputStream(eTrue);
        assertEquals("Decoding true value", Boolean.TRUE, asn1.decode(in));

        // encoding false
        DerOutputStream out = new DerOutputStream(asn1, Boolean.FALSE);
        assertTrue("Encoding false value", Arrays.equals(eFalse, out.encoded));
View Full Code Here

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

                // wrong content: content is not 0x01 or 0xFF
                new byte[] { 0x01, 0x01, 0x33 } };

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

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

    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], sequenceOf
                        .decode(in));
            } catch (ASN1Exception e) {
                fail("Test case: " + i + "\n" + e.getMessage());
            }
View Full Code Here

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

                        "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

Examples of org.bouncycastle.asn1.DERInputStream

    {
  super("X.509");
  try {
      if ( encoding.equals( "PkiPath" ) )
      {
    DERInputStream derInStream = new DERInputStream(inStream);
    DERObject derObject = derInStream.readObject();
    if ( derObject == null || ! ( derObject instanceof ASN1Sequence ) )
    {
        throw new CertificateException("input stream does not contain a ASN1 SEQUENCE while reading PkiPath encoded data to load CertPath" );
    }
    Enumeration enumx = ((ASN1Sequence)derObject).getObjects();
View Full Code Here

Examples of org.bouncycastle.asn1.DERInputStream

    private DERObject getEncodedX509Certificate( X509Certificate cert )
  throws CertificateEncodingException
    {
  try {
      ByteArrayInputStream inStream = new ByteArrayInputStream( cert.getEncoded() );
      DERInputStream derInStream = new DERInputStream( inStream );
      return derInStream.readObject();
  } catch ( IOException ex ) {
      throw new CertificateEncodingException( "IOException caught while encoding certificate\n" + ex.toString() );
  }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.