com.wm.app.b2b.server
Class Credential

java.lang.Object
  extended by com.wm.app.b2b.server.Credential

public class Credential
extends java.lang.Object

This class represents a generic "thing" which is used for validation. Currently the only two types of Credentials are passwords and digital certificates.

See Also:
Credential

Field Summary
static int CERTIFICATE
          Typecode for digital certificates.
static int PASSWORD
          Typecode for passwords.
static int UNKNOWN
          Typecode for unknown credentials.
 
Constructor Summary
Credential()
          Creates a new credential.
Credential(int type, java.lang.Object cred)
          Creates a new credential with specified type and value.
 
Method Summary
 boolean check(java.lang.Object o)
          Determines if the supplied value matches this one.
 boolean check(java.lang.String pass)
          Determines if the supplied password matches this one.
 boolean equals(Credential c)
          Determines if two credentials are equal.
 int getType()
          Returns the type of this credential.
 java.lang.String getTypeString()
          Returns the type of this credential as a string.
static java.lang.String getTypeString(int type)
          Returns the string name of the supplied type code.
 java.lang.Object getValue()
          Returns the value of this credential.
 void setType(int credType)
          Sets the type of this credential.
 void setValue(java.lang.Object cred)
          Sets the value of this credential.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN

public static final int UNKNOWN
Typecode for unknown credentials.

See Also:
Constant Field Values

PASSWORD

public static final int PASSWORD
Typecode for passwords.

See Also:
Constant Field Values

CERTIFICATE

public static final int CERTIFICATE
Typecode for digital certificates.

See Also:
Constant Field Values
Constructor Detail

Credential

public Credential()
Creates a new credential.


Credential

public Credential(int type,
                  java.lang.Object cred)
Creates a new credential with specified type and value.

Parameters:
type - The type code (see above for the codes).
cred - The value of the credential.
Method Detail

setType

public void setType(int credType)
Sets the type of this credential.

Parameters:
credType - The typecode for this credential.

getType

public int getType()
Returns the type of this credential.

Returns:
The type code.

getTypeString

public java.lang.String getTypeString()
Returns the type of this credential as a string.

Returns:
The type string.

getTypeString

public static java.lang.String getTypeString(int type)
Returns the string name of the supplied type code.

Parameters:
type - the type code.
Returns:
The type string.

setValue

public void setValue(java.lang.Object cred)
Sets the value of this credential.

Parameters:
cred - The new value of the credential.

getValue

public java.lang.Object getValue()
Returns the value of this credential.

Returns:
The value.

equals

public boolean equals(Credential c)
Determines if two credentials are equal. This method relies on the credential object providing an equality method for robust comparisons.


check

public boolean check(java.lang.String pass)
Determines if the supplied password matches this one. Returns false if this is not a password.

Parameters:
pass - Guess for the password.
Returns:
boolean Is this a password and if so, does this guess match.

check

public boolean check(java.lang.Object o)
Determines if the supplied value matches this one. Delegates to the equals message of the objects in question.

Parameters:
o - Guess for the value of this credential.
Returns:
boolean Does the guess match.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object