com.nimbusds.openid.connect.sdk
Class Nonce

java.lang.Object
  extended by com.nimbusds.oauth2.sdk.id.Identifier
      extended by com.nimbusds.openid.connect.sdk.Nonce
All Implemented Interfaces:
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. This class is immutable.

Example generation of a nonce with eight random mixed-case alphanumeric characters:

 Nonce nonce = new Nonce(8);
 

Related specifications:

Author:
Vladimir Dzhuvinov

Constructor Summary
Nonce()
          Creates a new nonce with a randomly generated value.
Nonce(int length)
          Creates a new nonce with a randomly generated value of the specified length.
Nonce(String value)
          Creates a new nonce with the specified value.
 
Method Summary
 boolean equals(Object object)
          Overrides Object.equals().
static Nonce parse(String s)
          Parses a nonce from the specified string.
 
Methods inherited from class com.nimbusds.oauth2.sdk.id.Identifier
getValue, hashCode, toJSONString, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Nonce

public Nonce(String value)
Creates a new nonce with the specified value.

Parameters:
value - The nonce value. Must not be null or empty string.

Nonce

public Nonce(int length)
Creates a new nonce with a randomly generated value of the specified length. The value will be made up of mixed-case alphanumeric ASCII characters.

Parameters:
length - The number of characters. Must be a positive integer.

Nonce

public Nonce()
Creates a new nonce with a randomly generated value. The value will be made up of 32 mixed-case alphanumeric ASCII characters.

Method Detail

equals

public boolean equals(Object object)
Description copied from class: Identifier
Overrides Object.equals().

Specified by:
equals in class Identifier
Parameters:
object - The object to compare to.
Returns:
true if the objects have the same value, otherwise false.

parse

public static Nonce parse(String s)
Parses a nonce from the specified string.

Parameters:
s - The string to parse, null or empty if no nonce is specified.
Returns:
The nonce, null if the parsed string was null or empty.


Copyright © 2013 NimbusDS. All Rights Reserved.