org.ldaptive.asn1
Class OidType

java.lang.Object
  extended by org.ldaptive.asn1.AbstractDERType
      extended by org.ldaptive.asn1.OidType
All Implemented Interfaces:
DEREncoder

public class OidType
extends AbstractDERType
implements DEREncoder

Converts object identifiers to and from their DER encoded format.

Version:
$Revision: 3068 $ $Date: 2014-10-24 13:22:32 -0400 (Fri, 24 Oct 2014) $
Author:
Middleware Services

Constructor Summary
OidType(DERTag tag, int[] item)
          Creates a new oid type.
OidType(DERTag tag, String item)
          Creates a new oid type.
OidType(int[] item)
          Creates a new oid type.
OidType(String item)
          Creates a new oid type.
 
Method Summary
static String decode(ByteBuffer encoded)
          Converts bytes in the buffer to an OID by reading from the current position to the limit, which assumes the bytes of the integer are in big-endian order.
 byte[] encode()
          Encode this object into it's DER type.
protected static void isValid(int[] oid)
          Checks whether the supplied oid is valid.
static int[] parse(String oid)
          Converts the supplied oid into an array on integers.
protected static int readInt(ByteBuffer buffer)
          Reads the necessary encoded bytes from the supplied buffer to create an integer.
protected static byte[] toBytes(int component)
          Converts the supplied oid component to a byte array.
static byte[] toBytes(int[] oid)
          Converts the supplied list of oid components to a byte array.
 
Methods inherited from class org.ldaptive.asn1.AbstractDERType
encode, readBuffer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OidType

public OidType(String item)
Creates a new oid type.

Parameters:
item - to DER encode

OidType

public OidType(int[] item)
Creates a new oid type.

Parameters:
item - to DER encode

OidType

public OidType(DERTag tag,
               String item)
Creates a new oid type.

Parameters:
tag - der tag associated with this type
item - to DER encode
Throws:
IllegalArgumentException - if the der tag is constructed

OidType

public OidType(DERTag tag,
               int[] item)
Creates a new oid type.

Parameters:
tag - der tag associated with this type
item - to DER encode
Throws:
IllegalArgumentException - if the der tag is constructed
Method Detail

encode

public byte[] encode()
Encode this object into it's DER type.

Specified by:
encode in interface DEREncoder
Returns:
DER encoded object

decode

public static String decode(ByteBuffer encoded)
Converts bytes in the buffer to an OID by reading from the current position to the limit, which assumes the bytes of the integer are in big-endian order.

Parameters:
encoded - buffer containing DER-encoded data where the buffer is positioned at the start of OID bytes and the limit is set beyond the last byte of OID data.
Returns:
decoded bytes as an OID.

toBytes

public static byte[] toBytes(int[] oid)
Converts the supplied list of oid components to a byte array.

Parameters:
oid - to convert
Returns:
byte array
Throws:
IllegalArgumentException - if the oid is not valid. See isValid(int[])

isValid

protected static void isValid(int[] oid)
Checks whether the supplied oid is valid. Oids must meet the following criteria:

Parameters:
oid - to check
Throws:
IllegalArgumentException - if the oid is not valid.

toBytes

protected static byte[] toBytes(int component)
Converts the supplied oid component to a byte array. The length of the byte array is the minimal size needed to contain the oid component.

Parameters:
component - to convert to bytes
Returns:
oid bytes

readInt

protected static int readInt(ByteBuffer buffer)
Reads the necessary encoded bytes from the supplied buffer to create an integer.

Parameters:
buffer - to read
Returns:
OID component integer

parse

public static int[] parse(String oid)
Converts the supplied oid into an array on integers.

Parameters:
oid - to parse
Returns:
array of oid components
Throws:
IllegalArgumentException - if the oid is not valid. See isValid(int[])


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