Package com.nimbusds.common.id
Class Username
java.lang.Object
com.nimbusds.common.id.BaseIdentifier
com.nimbusds.common.id.Username
- All Implemented Interfaces:
Identifier
,Comparable<Identifier>
,net.minidev.json.JSONAware
Represents a username.
The isLegal(java.lang.String)
method is intended for basic validation before
committing to expensive operations such as authentication. It checks whether
the specified string falls outside the typical scope of legal username
characters and length.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The regular expression string used to match legal usernames.Fields inherited from class com.nimbusds.common.id.BaseIdentifier
DEFAULT_BYTE_LENGTH, SECURE_RANDOM
-
Constructor Summary
-
Method Summary
Methods inherited from class com.nimbusds.common.id.BaseIdentifier
compareTo, hashCode, toJSONString, toString
-
Field Details
-
LEGAL_USERNAME_RE
The regular expression string used to match legal usernames.- See Also:
-
-
Constructor Details
-
Username
Creates a new username.- Parameters:
value
- The username value, must not benull
. The value is trimmed (of whitespace) internally.
-
-
Method Details
-
isLegal
Checks whether the specified username value is legal. This is done by performing a regular expression match againstLEGAL_USERNAME_RE
.- Parameters:
value
- The username value to test. It is trimmed before testing. Must not benull
.- Returns:
true
if the username is legal, elsefalse
.
-
isLegal
Checks whether the specified username value is legal. This is done by performing a regular expression match against the specified regular expression.- Parameters:
value
- The username value to test. It is trimmed before testing. Must not benull
.re
- The regular expression for validation, must evaluate totrue
for a legal username value.- Returns:
true
if the username is legal, elsefalse
.
-
equals
Description copied from class:BaseIdentifier
OverridesObject.equals()
.- Specified by:
equals
in classBaseIdentifier
- Parameters:
object
- The object to compare to.- Returns:
true
if the objects have the same value, otherwisefalse
.
-