Package com.globalmentor.security
Class DefaultNonce
- java.lang.Object
-
- com.globalmentor.security.DefaultNonce
-
-
Field Summary
Fields Modifier and Type Field Description static char
DELIMITER
The character that delimits fields in the nonce.protected static java.lang.String
DELIMITER_STRING
The string version of the character that delimits fields in the nonce.protected static java.util.Random
RANDOM
The shared random number factory.
-
Constructor Summary
Constructors Modifier Constructor Description DefaultNonce(java.lang.String privateKey)
Constructs a new nonce with generated values.protected
DefaultNonce(java.lang.String privateKey, java.util.Date time, long value)
Constructs a nonce from existing information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DefaultNonce
createNonce(java.lang.String string)
Creates a nonce from a formatted string.java.lang.String
getPrivateKey()
java.util.Date
getTime()
long
getValue()
java.lang.String
toString()
-
-
-
Field Detail
-
DELIMITER
public static final char DELIMITER
The character that delimits fields in the nonce.- See Also:
- Constant Field Values
-
DELIMITER_STRING
protected static final java.lang.String DELIMITER_STRING
The string version of the character that delimits fields in the nonce.
-
RANDOM
protected static final java.util.Random RANDOM
The shared random number factory.
-
-
Constructor Detail
-
DefaultNonce
public DefaultNonce(java.lang.String privateKey)
Constructs a new nonce with generated values.- Parameters:
privateKey
- The private key stored in the nonce.
-
DefaultNonce
protected DefaultNonce(java.lang.String privateKey, java.util.Date time, long value) throws java.lang.IllegalArgumentException
Constructs a nonce from existing information.- Parameters:
privateKey
- The private key stored in the nonce. This key must not contain any occurrences of the delimiter.time
- The time stored in the nonce.value
- A random value held by the nonce.- Throws:
java.lang.IllegalArgumentException
- if the private key contains an occurrence of the delimiter.
-
-
Method Detail
-
getPrivateKey
public java.lang.String getPrivateKey()
- Specified by:
getPrivateKey
in interfaceNonce
- Returns:
- The private key stored in the nonce.
-
getTime
public java.util.Date getTime()
-
getValue
public long getValue()
- Returns:
- A random value held by the nonce.
-
createNonce
public DefaultNonce createNonce(java.lang.String string) throws SyntaxException
Creates a nonce from a formatted string.- Parameters:
string
- The string containing the nonce.- Returns:
- A nonce containing values that would generate the same string as the one given.
- Throws:
SyntaxException
- if the given string does not have the correct format for this type of nonce.
-
-