FileDocCategorySizeDatePackage
PasswordCredential.javaAPI DocGlassfish v2 API5125Fri May 04 22:35:26 BST 2007com.sun.enterprise.security.auth.login

PasswordCredential

public class PasswordCredential extends Object
This class holds the user password for the shared password realm and the realm name. This credential is added as a private credential to the JAAS subject.

Fields Summary
private String
username
private String
password
private String
realm
private boolean
readOnly
private byte[]
target_name
Constructors Summary
public PasswordCredential(String user, String password, String realm)
Construct a credential with the specified password and realm name.

param
the password.
param
the realm name. The only value supported for now is "default".


                                  
          
    
	this.username = user;
	this.password = password;
	this.realm = realm;

        if (this.username == null ) { this.username = ""; }
        if (this.password == null ) { this.password = ""; }
        if (this.realm == null ) { this.realm = ""; }
    
public PasswordCredential(String user, String password, String realm, byte[] target_name)
called by SecServerRequestInterceptor The object if created on the server side is readonly

        this(user, password, realm);
	this.target_name = target_name;
        readOnly = true;
    
Methods Summary
public booleanequals(java.lang.Object o)
Compare two instances of the credential and return true if they are the same and false otherwise.

param
the object that this instance is being compared to.
return
true if the instances are equal, false otherwise

	if(o instanceof PasswordCredential) {
	    PasswordCredential pc = (PasswordCredential) o;
	    if(pc.getUser().equals(username) && 
		pc.getPassword().equals(password) && 
		pc.getRealm().equals(realm)) {
		return true;
	    }
	}
	return false;
    
public java.lang.StringgetPassword()
Return the password.

return
the password.

	return password;
    
public java.lang.StringgetRealm()
Return the realm name.

return
the realm name. Only value supported for now is "default".

	return realm;
    
public byte[]getTargetName()
Return the target_name

return
the target_name

	return this.target_name;
    
public java.lang.StringgetUser()
Return the username.

return
the user name.

	return username;
    
public inthashCode()
Return the hashCode computed from the password and realm name.

return
the hash code.

	return username.hashCode() + password.hashCode() + realm.hashCode();
    
public voidsetRealm(java.lang.String realm)

        if(!readOnly){
            this.realm = realm;
        }
    
public java.lang.StringtoString()
The string representation of the credential.

	String s = "Realm=" + realm;
	s = s + " Username=" + username;
	s = s + " Password=" + "########";
	s = s + " TargetName = " + target_name;
	return s;