org.ldaptive.asn1
Class DERParser

java.lang.Object
  extended by org.ldaptive.asn1.DERParser

public class DERParser
extends Object

This class provides a SAX-like parsing facility for DER-encoded data where elements of interest in the parse tree may be registered to handlers via the registerHandler(java.lang.String, org.ldaptive.asn1.ParseHandler) methods. DERPath strings are used to map handlers to elements of interest.

Version:
$Revision: 3050 $ $Date: 2014-09-04 14:24:42 -0400 (Thu, 04 Sep 2014) $
Author:
Middleware Services
See Also:
DERPath

Field Summary
protected  org.slf4j.Logger logger
          Logger for this class.
 
Constructor Summary
DERParser()
           
 
Method Summary
 void parse(ByteBuffer encoded)
          Parse a DER-encoded data structure by calling registered handlers when points of interest are encountered in the parse tree.
 int readLength(ByteBuffer encoded)
          Reads the length of a DER-encoded value from the given byte buffer.
 DERTag readTag(ByteBuffer encoded)
          Reads a DER tag from a single byte at the current position of the given buffer.
 void registerHandler(DERPath path, ParseHandler handler)
          Registers the supplied handler to fire when the supplied path is encountered.
 void registerHandler(String path, ParseHandler handler)
          See registerHandler(DERPath, ParseHandler).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.slf4j.Logger logger
Logger for this class.

Constructor Detail

DERParser

public DERParser()
Method Detail

registerHandler

public void registerHandler(String path,
                            ParseHandler handler)
See registerHandler(DERPath, ParseHandler).

Parameters:
path - to register
handler - to associate with the path

registerHandler

public void registerHandler(DERPath path,
                            ParseHandler handler)
Registers the supplied handler to fire when the supplied path is encountered.

Parameters:
path - to register
handler - to associate with the path

parse

public void parse(ByteBuffer encoded)
Parse a DER-encoded data structure by calling registered handlers when points of interest are encountered in the parse tree.

Parameters:
encoded - DER-encoded bytes.

readTag

public DERTag readTag(ByteBuffer encoded)
Reads a DER tag from a single byte at the current position of the given buffer. The buffer position is naturally advanced one byte in this operation.

Parameters:
encoded - Buffer containing DER-encoded bytes positioned at tag.
Returns:
Tag or null if no universal tag or application-specific tag is known that matches the byte read in.

readLength

public int readLength(ByteBuffer encoded)
Reads the length of a DER-encoded value from the given byte buffer. The buffer is expected to be positioned at the byte immediately following the tag byte, which is where the length byte(s) begin(s). Invocation of this method has two generally beneficial side effects:
  1. Buffer is positioned at start of value bytes.
  2. Buffer limit is set to the end of value bytes.

Parameters:
encoded - buffer containing DER-encoded bytes positioned at start of length byte(s).
Returns:
number of bytes occupied by tag value.


Copyright © 2003-2017 Virginia Tech. All Rights Reserved.