org.apache.directory.api.asn1.util
Class Oid

java.lang.Object
  extended by org.apache.directory.api.asn1.util.Oid

public class Oid
extends Object

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 :


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
 .1    -> 0x01
 .2    -> 0x02
 .2    -> 0x02
 

Author:
Apache Directory Project

Constructor Summary
Oid()
          Creates a new Oid object.
Oid(byte[] oid)
          Create a new Oid object from a byte array
Oid(String oid)
          Create a new Oid object from a String
 
Method Summary
 boolean equals(Object oid)
          
 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 long from the Oid
 int hashCode()
          
static boolean isOid(String oid)
          Check that an Oid is valid
 void setOid(byte[] oid)
          Set the Oid.
 void setOid(String oid)
          Set the Oid.
 String toString()
          Get the Oid as a String
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, 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 - the byte array containing the Oid
Throws:
DecoderException - if the byte array does not contain a valid Oid

Oid

public Oid(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 - if the byte array does not contain a valid Oid
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 - if the byte array does not contains a valid Oid

setOid

public void setOid(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 - if the byte array does not contains a valid Oid

getOidValues

public long[] getOidValues()
Get an array of long from the Oid

Returns:
An array of long 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

isOid

public static boolean isOid(String oid)
Check that an Oid is valid

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

toString

public String toString()
Get the Oid as a String

Overrides:
toString in class Object
Returns:
A String representing the Oid

hashCode

public int hashCode()

Overrides:
hashCode in class Object

equals

public boolean equals(Object oid)

Overrides:
equals in class Object


Copyright © 2003-2013 The Apache Software Foundation. All Rights Reserved.