com.nimbusds.oauth2.sdk.auth
Class Secret

java.lang.Object
  extended by com.nimbusds.oauth2.sdk.auth.Secret

public class Secret
extends Object

Secret or password. The secret should be erased when no longer in use.

Author:
Vladimir Dzhuvinov

Constructor Summary
Secret()
          Creates a new secret with a randomly generated value.
Secret(byte[] value)
          Creates a new secret with the specified value.
Secret(byte[] value, Date expDate)
          Creates a new secret with the specified value and expiration date.
Secret(int length)
          Creates a new secret with a randomly generated value of the specified length.
Secret(String value)
          Creates a new secret with the specified value.
Secret(String value, Date expDate)
          Creates a new secret with the specified value and expiration date.
 
Method Summary
 boolean equals(Object object)
          Overrides Object.equals().
 void erase()
          Erases of the value of this secret.
 boolean expired()
          Checks is this secret has expired.
 Date getExpirationDate()
          Gets the expiration date of this secret.
 String getValue()
          Gets the value of this secret.
 byte[] getValueBytes()
          Gets the value of this secret.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Secret

public Secret(String value)
Creates a new secret with the specified value.

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

Secret

public Secret(byte[] value)
Creates a new secret with the specified value.

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

Secret

public Secret(String value,
              Date expDate)
Creates a new secret with the specified value and expiration date.

Parameters:
value - The value. Must be UTF-8 encoded, not null or * empty string.
expDate - The expiration date, null if not specified.

Secret

public Secret(byte[] value,
              Date expDate)
Creates a new secret with the specified value and expiration date.

Parameters:
value - The value. Must not be null or empty string.
expDate - The expiration date, null if not specified.

Secret

public Secret(int length)
Creates a new secret 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.

Secret

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

Method Detail

getValue

public String getValue()
Gets the value of this secret.

Returns:
The value as a UTF-8 encoded string, null if it has been erased.

getValueBytes

public byte[] getValueBytes()
Gets the value of this secret.

Returns:
The value as a byte array, null if it has been erased.

erase

public void erase()
Erases of the value of this secret.


getExpirationDate

public Date getExpirationDate()
Gets the expiration date of this secret.

Returns:
The expiration date, null if not specified.

expired

public boolean expired()
Checks is this secret has expired.

Returns:
true if the secret has an associated expiration date which is in the past (according to the current system time), else returns false.

equals

public boolean equals(Object object)
Overrides Object.equals().

Overrides:
equals in class Object
Parameters:
object - The object to compare to.
Returns:
true if the objects are secrets the same value, otherwise false.


Copyright © 2013 NimbusDS. All Rights Reserved.