com.arsdigita.kernel.security
Class Credential

java.lang.Object
  extended bycom.arsdigita.kernel.security.Credential

public class Credential
extends Object

A unit of data that contains a string value, an expiration date, and a tamper-proof validator. A Credential can be converted to and from a string. Credential objects may expire after construction. Credential objects are immutable: they cannot be changed after construction.

Since:
ACS 4.5
Author:
Sameer Ajmani

Field Summary
static char SEPARATOR
          The character used to separate the value, expiration, and validator.
static String versionId
           
 
Method Summary
static Credential create(String value, long lifetimeMillis)
          Constructs a new credential that expires after the given number of milliseconds.
 Date getExpiration()
          Gets the expiration date of this credential.
 String getValue()
          Gets the value of this credential.
 boolean hasExpired()
          Determines whether this credential has expired.
static Credential parse(String credential)
          Constructs a new credential parsed from the given string.
 String toString()
          Returns the String representation of this credential.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values

SEPARATOR

public static final char SEPARATOR
The character used to separate the value, expiration, and validator.

See Also:
Constant Field Values
Method Detail

toString

public String toString()
Returns the String representation of this credential. Compatible with parse method.

Returns:
the String representation of this credential.

getValue

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

Returns:
the value of this credential.

getExpiration

public Date getExpiration()
Gets the expiration date of this credential.

Returns:
the expiration date of this credential.

hasExpired

public boolean hasExpired()
Determines whether this credential has expired.

Returns:
true if this credential has expired, false otherwise.

create

public static Credential create(String value,
                                long lifetimeMillis)
                         throws CredentialEncodingException
Constructs a new credential that expires after the given number of milliseconds.

Parameters:
value - the value of the credential
lifetimeMillis - the lifetime of this credential in milliseconds
Throws:
CredentialEncodingException - if the value contains the separator character, if the lifetime is negative, or if there is an error creating the validator.

parse

public static Credential parse(String credential)
                        throws CredentialParsingException,
                               CredentialExpiredException
Constructs a new credential parsed from the given string. Compatible with toString() method.

Returns:
a new credential parsed from the given string.
Throws:
CredentialParsingException - if the string does not represent a credential or if the credential is invalid.
CredentialExpiredException - if the parsed credential has expired.


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC