Package com.nimbusds.common.id
Class BaseIdentifier
- java.lang.Object
-
- com.nimbusds.common.id.BaseIdentifier
-
- All Implemented Interfaces:
Identifier
,Comparable<Identifier>
,net.minidev.json.JSONAware
- Direct Known Subclasses:
AuthzId
,CID
,DNIdentity
,IdentifierWithHMAC
,SID
,UID
,Username
public abstract class BaseIdentifier extends Object implements Identifier, Comparable<Identifier>, net.minidev.json.JSONAware
The base class for identifiers (IDs) used in Connect2id software.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_BYTE_LENGTH
The default byte length of generated identifiers.protected static SecureRandom
SECURE_RANDOM
The secure random generator.
-
Constructor Summary
Constructors Constructor Description BaseIdentifier()
Creates a new unique identifier (ID) based on a secure randomly generated 256-bit number, Base64URL-encoded.BaseIdentifier(int byteLength)
Creates a new unique identifier (ID) based on a secure randomly generated number with the specified byte length, Base64URL-encoded.BaseIdentifier(String value)
Creates a new identifier (ID) from the specified string.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
compareTo(Identifier other)
abstract boolean
equals(Object object)
OverridesObject.equals()
.int
hashCode()
OverridesObject.hashCode()
.String
toJSONString()
Returns the JSON string representation of this identifier (ID).String
toString()
Returns the string representation of this identifier (ID).
-
-
-
Field Detail
-
SECURE_RANDOM
protected static final SecureRandom SECURE_RANDOM
The secure random generator.
-
DEFAULT_BYTE_LENGTH
public static final int DEFAULT_BYTE_LENGTH
The default byte length of generated identifiers.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BaseIdentifier
public BaseIdentifier()
Creates a new unique identifier (ID) based on a secure randomly generated 256-bit number, Base64URL-encoded.
-
BaseIdentifier
public BaseIdentifier(int byteLength)
Creates a new unique identifier (ID) based on a secure randomly generated number with the specified byte length, Base64URL-encoded.
-
BaseIdentifier
public BaseIdentifier(String value)
Creates a new identifier (ID) from the specified string. The value is not validated (for legality or uniqueness) in any way.- Parameters:
value
- The identifier (ID) value. Must not benull
.
-
-
Method Detail
-
compareTo
public int compareTo(Identifier other)
- Specified by:
compareTo
in interfaceComparable<Identifier>
-
hashCode
public int hashCode()
OverridesObject.hashCode()
.
-
toJSONString
public String toJSONString()
Returns the JSON string representation of this identifier (ID).- Specified by:
toJSONString
in interfacenet.minidev.json.JSONAware
- Returns:
- The JSON string representation.
-
-