Package com.nimbusds.openid.connect.sdk
Class Nonce
- java.lang.Object
-
- com.nimbusds.oauth2.sdk.id.Identifier
-
- com.nimbusds.openid.connect.sdk.Nonce
-
- All Implemented Interfaces:
Serializable
,Comparable<Identifier>
,net.minidev.json.JSONAware
@Immutable public final class Nonce extends Identifier
Nonce. This is a random, unique string value to associate a user-session with an ID Token and to mitigate replay attacks.Example generation of a nonce with eight random mixed-case alphanumeric characters:
Nonce nonce = new Nonce(8);
Related specifications:
- OpenID Connect Core 1.0, section 3.1.2.1. and 15.5.2.
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.nimbusds.oauth2.sdk.id.Identifier
DEFAULT_BYTE_LENGTH, secureRandom
-
-
Constructor Summary
Constructors Constructor Description Nonce()
Creates a new nonce with a randomly generated 256-bit (32-byte) value, Base64URL-encoded.Nonce(int byteLength)
Creates a new nonce with a randomly generated value of the specified byte length, Base64URL-encoded.Nonce(String value)
Creates a new nonce with the specified value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object object)
static Nonce
parse(String s)
Parses a nonce from the specified string.-
Methods inherited from class com.nimbusds.oauth2.sdk.id.Identifier
compareTo, getValue, hashCode, toJSONString, toString, toStringList
-
-
-
-
Constructor Detail
-
Nonce
public Nonce(String value)
Creates a new nonce with the specified value.- Parameters:
value
- The nonce value. Must not benull
or empty string.
-
Nonce
public Nonce(int byteLength)
Creates a new nonce with a randomly generated value of the specified byte length, Base64URL-encoded.- Parameters:
byteLength
- The byte length of the value to generate. Must be greater than one.
-
Nonce
public Nonce()
Creates a new nonce with a randomly generated 256-bit (32-byte) value, Base64URL-encoded.
-
-
Method Detail
-
equals
public boolean equals(Object object)
- Overrides:
equals
in classIdentifier
-
-