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
public final class Username extends BaseIdentifier
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
Fields Modifier and Type Field Description static String
LEGAL_USERNAME_RE
The regular expression string used to match legal usernames.-
Fields inherited from class com.nimbusds.common.id.BaseIdentifier
DEFAULT_BYTE_LENGTH, SECURE_RANDOM
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object object)
OverridesObject.equals()
.static boolean
isLegal(String value)
Checks whether the specified username value is legal.static boolean
isLegal(String value, Pattern re)
Checks whether the specified username value is legal.-
Methods inherited from class com.nimbusds.common.id.BaseIdentifier
compareTo, hashCode, toJSONString, toString
-
-
-
-
Field Detail
-
LEGAL_USERNAME_RE
public static final String LEGAL_USERNAME_RE
The regular expression string used to match legal usernames.- See Also:
- Constant Field Values
-
-
Method Detail
-
isLegal
public static boolean isLegal(String value)
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
public static boolean isLegal(String value, Pattern re)
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
public boolean equals(Object object)
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
.
-
-