Package com.nimbusds.oauth2.sdk.device
Class UserCode
java.lang.Object
com.nimbusds.oauth2.sdk.id.Identifier
com.nimbusds.oauth2.sdk.device.UserCode
- All Implemented Interfaces:
Serializable,Comparable<Identifier>,net.minidev.json.JSONAware
User code.
Related specifications:
- OAuth 2.0 Device Authorization Grant (RFC 8628)
- See Also:
-
Field Summary
FieldsFields inherited from class com.nimbusds.oauth2.sdk.id.Identifier
DEFAULT_BYTE_LENGTH, secureRandom -
Constructor Summary
ConstructorsConstructorDescriptionUserCode()Creates a new user code with a randomly generated value with 8 characters fromLETTER_CHAR_SET, in the formWDJB-MJHT.Creates a new user code with the specified value and theLETTER_CHAR_SET.Creates a new user code with a randomly generated value from the specified charset and length.Creates a new user code with the specified value. -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(Identifier other) booleanReturns the character set used by thisUserCode.Returns the value with all invalid characters removed.inthashCode()static StringstripIllegalChars(String value, String charset) Removes all characters fromvaluethat are not incharset.Methods inherited from class com.nimbusds.oauth2.sdk.id.Identifier
getValue, toJSONString, toString, toStringList
-
Field Details
-
LETTER_CHAR_SET
- See Also:
-
DIGIT_CHAR_SET
- See Also:
-
-
Constructor Details
-
UserCode
Creates a new user code with the specified value.- Parameters:
value- The code value. Must not benullor empty string.charset- The character set used by the identifier. The identifier can only contain characters from this set. Ifnull, all characters are allowed.
-
UserCode
Creates a new user code with the specified value and theLETTER_CHAR_SET.- Parameters:
value- The code value. Must not benullor empty string.
-
UserCode
public UserCode()Creates a new user code with a randomly generated value with 8 characters fromLETTER_CHAR_SET, in the formWDJB-MJHT. -
UserCode
Creates a new user code with a randomly generated value from the specified charset and length. A dash is added every 4 characters.- Parameters:
charset- The character set used by the identifier. The identifier will contain characters from this set. Must not benullor empty string.length- The length of the value to generate.
-
-
Method Details
-
getCharset
Returns the character set used by thisUserCode.- Returns:
- The character set, or
nullif unspecified.
-
getStrippedValue
Returns the value with all invalid characters removed.- Returns:
- The value with all invalid characters removed.
-
compareTo
- Specified by:
compareToin interfaceComparable<Identifier>- Overrides:
compareToin classIdentifier
-
hashCode
- Overrides:
hashCodein classIdentifier
-
equals
- Overrides:
equalsin classIdentifier
-
stripIllegalChars
Removes all characters fromvaluethat are not incharset.- Parameters:
value- The code value.charset- The allowed characters invalue. Ifnullall characters are retained.- Returns:
- The
valuewith all invalid characters removed.
-