FileDocCategorySizeDatePackage
PasswordCredential.javaAPI DocGlassfish v2 API5344Fri May 04 22:35:38 BST 2007javax.resource.spi.security

PasswordCredential

public final class PasswordCredential extends Object implements Serializable
The class PasswordCredential acts as a holder for username and password.
see
javax.resource.spi.ManagedConnectionFactory
author
Rahul Sharma
version
0.6
since
0.6

Fields Summary
private String
userName
private char[]
password
private javax.resource.spi.ManagedConnectionFactory
mcf
Constructors Summary
public PasswordCredential(String userName, char[] password)
Creates a new PasswordCredential object from the given user name and password.

Note that the given user password is cloned before it is stored in the new PasswordCredential object.

param
userName the user name
param
password the user's password

    this.userName = userName;
    this.password = (char[])password.clone();
  
Methods Summary
public booleanequals(java.lang.Object other)
Compares this PasswordCredential with the specified object for equality. The two PasswordCredential instances are the same if they are equal in username and password.

param
other Object to which PasswordCredential is to be compared
return
true if and if the specified object is a PasswordCredential whose username and password are equal to this instance.

    if (!(other instanceof PasswordCredential))
      return false;

    PasswordCredential pc = (PasswordCredential)other;

    if (!(userName.equals(pc.userName)))
      return false;

    if (password.length != pc.password.length)
      return false;
    
    for (int i = 0; i < password.length;i++) {
      if (password[i] != pc.password[i]) 
	return false;
    }

    return true;
  
public javax.resource.spi.ManagedConnectionFactorygetManagedConnectionFactory()
Gets the target ManagedConnectionFactory for which the user name and password has been set by the application server. A ManagedConnection- Factory uses this field to find out whether PasswordCredential should be used by it for sign-on to the target EIS instance.

return
ManagedConnectionFactory instance for which user name and password have been specified

    return mcf;
  
public char[]getPassword()
Returns the user password.

Note that this method returns a reference to the password. It is the caller's responsibility to zero out the password information after it is no longer needed.

return
the password

    return password;
  
public java.lang.StringgetUserName()
Returns the user name.

return
the user name

    return userName;
  
public inthashCode()
Returns the hash code for this PasswordCredential

return
hash code for this PasswordCredential

    String s = userName;
    s += new String(password);
    return s.hashCode();
  
public voidsetManagedConnectionFactory(javax.resource.spi.ManagedConnectionFactory mcf)
Sets the target ManagedConenctionFactory instance for which the user name and password has been set by the application server.

param
mcf ManagedConnectionFactory instance for which user name and password have been specified

    this.mcf = mcf;