org.eclipse.ecf.core.identity
Class GUID

java.lang.Object
  extended by org.eclipse.ecf.core.identity.BaseID
      extended by org.eclipse.ecf.core.identity.StringID
          extended by org.eclipse.ecf.core.identity.GUID
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable, java.security.Principal, org.eclipse.core.runtime.IAdaptable, ID

public class GUID
extends StringID

Globally unique ID implementation class. Uses SecureRandom to create a unique number of given byte length. Default byte length for secure number is 20 bytes. Default algorithm used for creating a SecureRandom instance is SHA1PRNG.

See Also:
Serialized Form

Nested Class Summary
static class GUID.GUIDNamespace
           
 
Nested classes/interfaces inherited from class org.eclipse.ecf.core.identity.StringID
StringID.StringIDNamespace
 
Field Summary
static int DEFAULT_BYTE_LENGTH
           
protected static java.security.SecureRandom random
           
static java.lang.String SR_DEFAULT_ALGO
           
static java.lang.String SR_DEFAULT_PROVIDER
           
 
Fields inherited from class org.eclipse.ecf.core.identity.StringID
value
 
Fields inherited from class org.eclipse.ecf.core.identity.BaseID
namespace
 
Constructor Summary
protected GUID(Namespace n)
           
protected GUID(Namespace n, int byteLength)
           
protected GUID(Namespace n, java.lang.String value)
           
protected GUID(Namespace n, java.lang.String algo, java.lang.String provider, int byteLength)
          Protected constructor for factory-based construction
 
Method Summary
protected static java.security.SecureRandom getRandom(java.lang.String algo, java.lang.String provider)
          Get SecureRandom instance for creation of random number.
protected static void initializeRandom(java.lang.String algo, java.lang.String provider)
           
 java.lang.String toString()
           
 
Methods inherited from class org.eclipse.ecf.core.identity.StringID
compareTo, equals, getName, getNamespace, hashCode, namespaceCompareTo, namespaceEquals, namespaceGetName, namespaceHashCode, setEmptyNamespace, toExternalForm
 
Methods inherited from class org.eclipse.ecf.core.identity.BaseID
getAdapter, namespaceToExternalForm
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SR_DEFAULT_ALGO

public static final java.lang.String SR_DEFAULT_ALGO

SR_DEFAULT_PROVIDER

public static final java.lang.String SR_DEFAULT_PROVIDER

DEFAULT_BYTE_LENGTH

public static final int DEFAULT_BYTE_LENGTH
See Also:
Constant Field Values

random

protected static transient java.security.SecureRandom random
Constructor Detail

GUID

protected GUID(Namespace n,
               java.lang.String algo,
               java.lang.String provider,
               int byteLength)
        throws IDCreateException
Protected constructor for factory-based construction

Parameters:
n - the Namespace this identity will belong to
provider - the name of the algorithm to use. See SecureRandom
byteLength - the length of the target number (in bytes)
Throws:
IDCreateException

GUID

protected GUID(Namespace n,
               java.lang.String value)

GUID

protected GUID(Namespace n,
               int byteLength)
        throws IDCreateException
Throws:
IDCreateException

GUID

protected GUID(Namespace n)
        throws IDCreateException
Throws:
IDCreateException
Method Detail

getRandom

protected static java.security.SecureRandom getRandom(java.lang.String algo,
                                                      java.lang.String provider)
                                               throws java.lang.Exception
Get SecureRandom instance for creation of random number.

Parameters:
algo - the String algorithm specification (e.g. "SHA1PRNG") for creation of the SecureRandom instance
provider - the provider of the implementation of the given algorighm (e.g. "SUN")
Returns:
SecureRandom
Throws:
java.lang.Exception - thrown if SecureRandom instance cannot be created/accessed

initializeRandom

protected static void initializeRandom(java.lang.String algo,
                                       java.lang.String provider)
                                throws java.lang.Exception
Throws:
java.lang.Exception

toString

public java.lang.String toString()
Specified by:
toString in interface java.security.Principal
Overrides:
toString in class StringID