pasn.encoding
Class ASN1InputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by pasn.encoding.ASN1InputStream
All Implemented Interfaces:
java.io.Closeable
Direct Known Subclasses:
DefiniteLengthInputStream

public abstract class ASN1InputStream
extends java.io.FilterInputStream

Author:
ncottin

Field Summary
static long DELAY_UNIT
           
static long NO_DELAY
           
 
Constructor Summary
ASN1InputStream(java.io.File src, ASN1ValueDecoder decoder)
           
ASN1InputStream(java.io.File src, ASN1ValueDecoder decoder, long maxLength)
           
ASN1InputStream(java.io.InputStream in, ASN1ValueDecoder decoder)
           Creates an unlimited length ASN.1 input stream.
ASN1InputStream(java.io.InputStream in, ASN1ValueDecoder decoder, boolean extraAllowed)
           
ASN1InputStream(java.io.InputStream in, ASN1ValueDecoder decoder, long maxLength)
           Creates an ASN.1 input stream constrained with a maximum number of octets to read.
ASN1InputStream(java.io.InputStream in, ASN1ValueDecoder decoder, long maxLength, boolean extraAllowed)
           
ASN1InputStream(java.io.InputStream in, ASN1ValueDecoder decoder, long maxLength, long startIndex, boolean extraAllowed)
           
ASN1InputStream(java.io.InputStream in, ASN1ValueDecoder decoder, long maxLength, long startIndex, boolean extraAllowed, long delay, long delayUnit)
           
ASN1InputStream(java.lang.String srcPath, ASN1ValueDecoder decoder)
           
ASN1InputStream(java.lang.String srcPath, ASN1ValueDecoder decoder, long maxLength)
           
 
Method Summary
abstract  ASN1DecodedObject decode()
           
 ASN1ValueDecoder getDecoder()
           
 long getDelay()
           
 long getDelayUnit()
           
 java.io.InputStream getInputStream()
           
 long getMaxLength()
           
 long getReadLength()
           
 long getStartIndex()
           
 boolean isDelayed()
           
 boolean isExtraAllowed()
           
 boolean isLengthConstrained()
           
 int readByte()
           
 int readByte(byte[] dest)
           
 void setDelay(long delay, long unit)
           Initializes a waiting delay to receive expected data from the input stream.
 void setExtraAllowed(boolean extraAllowed)
           
 void setInputStream(java.io.InputStream in)
           
 void setMaxLength(long maxLength)
           
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, read, read, reset, skip
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_DELAY

public static final long NO_DELAY
See Also:
Constant Field Values

DELAY_UNIT

public static final long DELAY_UNIT
See Also:
Constant Field Values
Constructor Detail

ASN1InputStream

public ASN1InputStream(java.io.InputStream in,
                       ASN1ValueDecoder decoder)

Creates an unlimited length ASN.1 input stream. No extra remaining octet is tolerated (once the decoding process has terminated) and no waiting delay applies

Parameters:
in - The source (ASN.1 encoded) stream to decode from
decoder - The primitive types decoder which corresponds to this ASN.1 input stream

ASN1InputStream

public ASN1InputStream(java.io.InputStream in,
                       ASN1ValueDecoder decoder,
                       long maxLength)

Creates an ASN.1 input stream constrained with a maximum number of octets to read. No extra remaining octet is tolerated (once the decoding process has terminated) and no waiting delay applies

Parameters:
in - The source (ASN.1 encoded) stream to decode from
decoder - The primitive types decoder which corresponds to this ASN.1 input stream
maxLength - Maximum number of octets expected. This value is an upper limit and may not correspond to the number of decoded octets. ASN1Constants.NO_VALUE must be used when this limit is not known

ASN1InputStream

public ASN1InputStream(java.io.InputStream in,
                       ASN1ValueDecoder decoder,
                       long maxLength,
                       boolean extraAllowed)

ASN1InputStream

public ASN1InputStream(java.io.InputStream in,
                       ASN1ValueDecoder decoder,
                       long maxLength,
                       long startIndex,
                       boolean extraAllowed)

ASN1InputStream

public ASN1InputStream(java.io.InputStream in,
                       ASN1ValueDecoder decoder,
                       boolean extraAllowed)
Parameters:
in - The source (ASN.1 encoded) stream to decode from
decoder - The primitive types decoder which corresponds to this ASN.1 input stream
extraAllowed - Indicates that the given input stream may not terminate after the decoding process (extra octets may be encountered). Setting to false specifies that no extra byte is expected at the end of the stream

ASN1InputStream

public ASN1InputStream(java.io.InputStream in,
                       ASN1ValueDecoder decoder,
                       long maxLength,
                       long startIndex,
                       boolean extraAllowed,
                       long delay,
                       long delayUnit)

ASN1InputStream

public ASN1InputStream(java.io.File src,
                       ASN1ValueDecoder decoder)
                throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException

ASN1InputStream

public ASN1InputStream(java.lang.String srcPath,
                       ASN1ValueDecoder decoder)
                throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException

ASN1InputStream

public ASN1InputStream(java.io.File src,
                       ASN1ValueDecoder decoder,
                       long maxLength)
                throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException

ASN1InputStream

public ASN1InputStream(java.lang.String srcPath,
                       ASN1ValueDecoder decoder,
                       long maxLength)
                throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException
Method Detail

setDelay

public final void setDelay(long delay,
                           long unit)

Initializes a waiting delay to receive expected data from the input stream. This delay is useful when the stream is provided by an external process (a socket for example)

Parameters:
delay - Maximum amount of milliseconds to raise a timer error if no input data received
unit - Waitig delay (in milliseconds) before any further attempt to read from the input stream

getDelay

public final long getDelay()

getDelayUnit

public final long getDelayUnit()

isDelayed

public final boolean isDelayed()

getDecoder

public final ASN1ValueDecoder getDecoder()

setInputStream

public final void setInputStream(java.io.InputStream in)

getInputStream

public final java.io.InputStream getInputStream()

getStartIndex

public final long getStartIndex()

setMaxLength

public final void setMaxLength(long maxLength)

getMaxLength

public final long getMaxLength()

getReadLength

public final long getReadLength()

isLengthConstrained

public final boolean isLengthConstrained()

setExtraAllowed

public final void setExtraAllowed(boolean extraAllowed)

isExtraAllowed

public final boolean isExtraAllowed()

readByte

public final int readByte()
                   throws java.io.IOException,
                          ASN1SecurityException,
                          ASN1TimerException
Throws:
java.io.IOException
ASN1SecurityException
ASN1TimerException

readByte

public final int readByte(byte[] dest)
                   throws java.io.IOException,
                          ASN1DecodingException,
                          ASN1SecurityException,
                          ASN1TimerException
Throws:
java.io.IOException
ASN1DecodingException
ASN1SecurityException
ASN1TimerException

decode

public abstract ASN1DecodedObject decode()
                                  throws java.io.IOException,
                                         ASN1DecodingException,
                                         EndOfContentFoundException,
                                         ASN1SecurityException,
                                         ASN1TimerException
Throws:
java.io.IOException
ASN1DecodingException
EndOfContentFoundException
ASN1SecurityException
ASN1TimerException