FileDocCategorySizeDatePackage
Oid.javaAPI DocJava SE 5 API5959Fri Aug 26 14:58:26 BST 2005org.ietf.jgss

Oid

public class Oid extends Object
This class represents Universal Object Identifiers (Oids) and their associated operations.

Oids are hierarchically globally-interpretable identifiers used within the GSS-API framework to identify mechanisms and name formats.

The structure and encoding of Oids is defined in ISOIEC-8824 and ISOIEC-8825. For example the Oid representation of Kerberos V5 mechanism is "1.2.840.113554.1.2.2"

The GSSName name class contains public static Oid objects representing the standard name types defined in GSS-API.

author
Mayank Upadhyay
version
1.8, 12/19/03
since
1.4

Fields Summary
private ObjectIdentifier
oid
private byte[]
derEncoding
Constructors Summary
public Oid(String strOid)
Constructs an Oid object from a string representation of its integer components.

param
strOid the dot separated string representation of the oid. For instance, "1.2.840.113554.1.2.2".
exception
GSSException may be thrown when the string is incorrectly formatted


        try {
	    oid = new ObjectIdentifier(strOid);
	    derEncoding = null;
        } catch (Exception e) {
            throw new GSSException(GSSException.FAILURE, 
                          "Improperly formatted Object Identifier String - "
                          + strOid);  
	}
    
public Oid(InputStream derOid)
Creates an Oid object from its ASN.1 DER encoding. This refers to the full encoding including tag and length. The structure and encoding of Oids is defined in ISOIEC-8824 and ISOIEC-8825. This method is identical in functionality to its byte array counterpart.

param
derOid stream containing the DER encoded oid
exception
GSSException may be thrown when the DER encoding does not follow the prescribed format.

	try {
	    DerValue derVal = new DerValue(derOid);
	    derEncoding = derVal.toByteArray();
	    oid = derVal.getOID();
	} catch (IOException e) {
            throw new GSSException(GSSException.FAILURE, 
                          "Improperly formatted ASN.1 DER encoding for Oid");
	}
    
public Oid(byte[] data)
Creates an Oid object from its ASN.1 DER encoding. This refers to the full encoding including tag and length. The structure and encoding of Oids is defined in ISOIEC-8824 and ISOIEC-8825. This method is identical in functionality to its InputStream conterpart.

param
data byte array containing the DER encoded oid
exception
GSSException may be thrown when the DER encoding does not follow the prescribed format.

	try {
	    DerValue derVal = new DerValue(data);
	    derEncoding = derVal.toByteArray();
	    oid = derVal.getOID();
	} catch (IOException e) {
            throw new GSSException(GSSException.FAILURE, 
                          "Improperly formatted ASN.1 DER encoding for Oid");
	}
    
Methods Summary
public booleancontainedIn(org.ietf.jgss.Oid[] oids)
A utility method to test if this Oid value is contained within the supplied Oid array.

param
oids the array of Oid's to search
return
true if the array contains this Oid value, false otherwise

    
        for (int i = 0; i < oids.length; i++) {
            if (oids[i].equals(this))
                return (true);
        }
    
        return (false);
    
public booleanequals(java.lang.Object other)
Tests if two Oid objects represent the same Object identifier value.

return
true if the two Oid objects represent the same value, false otherwise.
param
other the Oid object that has to be compared to this one


        //check if both reference the same object
        if (this == other)
            return (true);

	if (other instanceof Oid)
	    return this.oid.equals(((Oid) other).oid);
	else if (other instanceof ObjectIdentifier)
	    return this.oid.equals(other);
	else
	    return false;
    
public byte[]getDER()
Returns the full ASN.1 DER encoding for this oid object, which includes the tag and length.

return
byte array containing the DER encoding of this oid object.
exception
GSSException may be thrown when the oid can't be encoded

    
        if (derEncoding == null) {
	    DerOutputStream dout = new DerOutputStream();
	    try {
		dout.putOID(oid);
	    } catch (IOException e) {
		throw new GSSException(GSSException.FAILURE, e.getMessage());
	    }
	    derEncoding = dout.toByteArray();
	}

        return derEncoding;
    
static org.ietf.jgss.OidgetInstance(java.lang.String strOid)
Only for calling by initializators used with declarations.

param
strOid

        Oid retVal = null;
        try {
            retVal =  new Oid(strOid); 
        } catch (GSSException e) {
            // squelch it!
        }
        return retVal;
    
public inthashCode()
Returns a hashcode value for this Oid.

return
a hashCode value

	return oid.hashCode();
    
public java.lang.StringtoString()
Returns a string representation of the oid's integer components in dot separated notation.

return
string representation in the following format: "1.2.3.4.5"

	return oid.toString();