For the latest news and information visit
The GNU Crypto project

gnu.crypto.der
Class DERReader

java.lang.Object
  extended by gnu.crypto.der.DERReader
All Implemented Interfaces:
DER

public final class DERReader
extends Object
implements DER

This class decodes DER sequences into Java objects. The methods of this class do not have knowledge of higher-levels of structure in the DER stream -- such as ASN.1 constructions -- and it is therefore up to the calling application to determine if the data are structured properly by inspecting the DERValue that is returned.

Author:
Casey Marshall (rsdio@metastatic.org)

Field Summary
 
Fields inherited from interface gnu.crypto.der.DER
ANY, APPLICATION, BIT_STRING, BMP_STRING, BOOLEAN, CONSTRUCTED, CONSTRUCTED_VALUE, CONTEXT, ENUMERATED, GENERAL_STRING, GENERALIZED_TIME, GRAPHIC_STRING, IA5_STRING, INTEGER, ISO646_STRING, NULL, NUMERIC_STRING, OBJECT_IDENTIFIER, OCTET_STRING, PRINTABLE_STRING, PRIVATE, REAL, RELATIVE_OID, SEQUENCE, SET, T61_STRING, UNIVERSAL, UNIVERSAL_STRING, UTC_TIME, UTF8_STRING, VIDEOTEX_STRING
 
Constructor Summary
DERReader(byte[] in)
          Create a new DER reader from a byte array.
DERReader(byte[] in, int off, int len)
           
DERReader(InputStream in)
          Create a new DER readed from an input stream.
 
Method Summary
 DERValue read()
          Decode a single value from the input stream, returning it in a new DERValue.
static DERValue read(byte[] encoded)
          Convenience method for reading a single primitive value from the given byte array.
 void skip(int bytes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DERReader

public DERReader(byte[] in)
Create a new DER reader from a byte array.

Parameters:
in - The encoded bytes.

DERReader

public DERReader(byte[] in,
                 int off,
                 int len)

DERReader

public DERReader(InputStream in)
Create a new DER readed from an input stream.

Parameters:
in - The encoded bytes.
Method Detail

read

public static DERValue read(byte[] encoded)
                     throws IOException
Convenience method for reading a single primitive value from the given byte array.

Parameters:
encoded - The encoded bytes.
Throws:
IOException - If the bytes do not represent an encoded object.

skip

public void skip(int bytes)
          throws IOException
Throws:
IOException

read

public DERValue read()
              throws IOException
Decode a single value from the input stream, returning it in a new DERValue. By "single value" we mean any single type in its entirety -- including constructed types such as SEQUENCE and all the values they contain. Usually it is sufficient to call this method once to parse and return the top-level structure, then to inspect the returned value for the proper contents.

Returns:
The parsed DER structure.
Throws:
IOException - If an error occurs reading from the input stream.
DEREncodingException - If the input does not represent a valid DER stream.

For the latest news and information visit
The GNU Crypto project

Copyright © 2001, 2002, 2003 Free Software Foundation, Inc. All Rights Reserved.