org.apache.directory.shared.asn1.primitives
Class OID

java.lang.Object
  extended by org.apache.directory.shared.asn1.primitives.OID
All Implemented Interfaces:
java.io.Serializable

public class OID
extends java.lang.Object
implements java.io.Serializable

This class implement an OID (Object Identifier). An OID is encoded as a list of bytes representing integers. An OID has a numeric representation where number are separated with dots : SPNEGO Oid = 1.3.6.1.5.5.2 Translating from a byte list to a dot separated list of number follows the rules : - the first number is in [0..2] - the second number is in [0..39] if the first number is 0 or 1 - the first byte has a value equal to : number 1 * 40 + number two - the upper bit of a byte is set if the next byte is a part of the number For instance, the SPNEGO Oid (1.3.6.1.5.5.2) will be encoded : 1.3 -> 0x2B (1*40 + 3 = 43 = 0x2B) .6 -> 0x06 .1 -> 0x01 .5 -> 0x05 .5 -> 0x05 .2 -> 0x02 The Kerberos V5 Oid (1.2.840.48018.1.2.2) will be encoded : 1.2 -> 0x2A (1*40 + 2 = 42 = 0x2A) 840 -> 0x86 0x48 (840 = 6 * 128 + 72 = (0x06 | 0x80) 0x48 = 0x86 0x48 48018 -> 0x82 0xF7 0x12 (2 * 128 * 128 + 119 * 128 + 18 = (0x02 | 0x80) (0x77 | 0x80) 0x12

Author:
Apache Directory Project
See Also:
Serialized Form

Constructor Summary
OID()
          Creates a new OID object.
OID(byte[] oid)
          Create a new OID object from a byte array
OID(java.lang.String oid)
          Create a new OID object from a String
 
Method Summary
 byte[] getOID()
          Get an array of bytes from the OID
 int getOIDLength()
          Get the number of bytes necessary to store the OID
 long[] getOIDValues()
          Get an array of int from the OID
static boolean isOID(java.lang.String oid)
          Check that an OID is valid
 void setOID(byte[] oid)
          Set the OID.
 void setOID(java.lang.String oid)
          Set the OID.
 java.lang.String toString()
          Get the OID as a String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OID

public OID()
Creates a new OID object.


OID

public OID(byte[] oid)
    throws DecoderException
Create a new OID object from a byte array

Parameters:
oid -
Throws:
DecoderException

OID

public OID(java.lang.String oid)
    throws DecoderException
Create a new OID object from a String

Parameters:
oid - The String which is supposed to be an OID
Throws:
DecoderException
Method Detail

setOID

public void setOID(byte[] oid)
            throws DecoderException
Set the OID. It will be translated from a byte array to an internal representation.

Parameters:
oid - The bytes containing the OID
Throws:
DecoderException

setOID

public void setOID(java.lang.String oid)
            throws DecoderException
Set the OID. It will be translated from a String to an internal representation. The syntax will be controled in respect with this rule : OID = ( [ '0' | '1' ] '.' [ 0 .. 39 ] | '2' '.' int) ( '.' int )*

Parameters:
oid - The String containing the OID
Throws:
DecoderException

getOIDValues

public long[] getOIDValues()
Get an array of int from the OID

Returns:
An array of int representing the OID

getOIDLength

public int getOIDLength()
Get the number of bytes necessary to store the OID

Returns:
An int representing the length of the OID

getOID

public byte[] getOID()
Get an array of bytes from the OID

Returns:
An array of int representing the OID

toString

public java.lang.String toString()
Get the OID as a String

Overrides:
toString in class java.lang.Object
Returns:
A String representing the OID

isOID

public static boolean isOID(java.lang.String oid)
Check that an OID is valid

Parameters:
oid - The oid to be checked
Returns:
true if the OID is valid


Copyright © 2004-2012. All Rights Reserved.