FileDocCategorySizeDatePackage
UsernamePasswordCredentials.javaAPI DocAndroid 1.5 API4200Wed May 06 22:41:10 BST 2009org.apache.http.auth

UsernamePasswordCredentials

public class UsernamePasswordCredentials extends Object implements Credentials
Username and password {@link Credentials}
author
Remy Maucherat
author
Sean C. Sullivan
author
Mike Bowler
author
Oleg Kalnichevski
version
$Revision: 658430 $ $Date: 2008-05-20 14:04:27 -0700 (Tue, 20 May 2008) $

Fields Summary
private final BasicUserPrincipal
principal
private final String
password
Constructors Summary
public UsernamePasswordCredentials(String usernamePassword)
The constructor with the username and password combined string argument.

param
usernamePassword the username:password formed string
see
#toString

        super();
        if (usernamePassword == null) {
            throw new IllegalArgumentException("Username:password string may not be null");            
        }
        int atColon = usernamePassword.indexOf(':");
        if (atColon >= 0) {
            this.principal = new BasicUserPrincipal(usernamePassword.substring(0, atColon));
            this.password = usernamePassword.substring(atColon + 1);
        } else {
            this.principal = new BasicUserPrincipal(usernamePassword);
            this.password = null;
        }
    
public UsernamePasswordCredentials(String userName, String password)
The constructor with the username and password arguments.

param
userName the user name
param
password the password

        super();
        if (userName == null) {
            throw new IllegalArgumentException("Username may not be null");            
        }
        this.principal = new BasicUserPrincipal(userName);
        this.password = password;
    
Methods Summary
public booleanequals(java.lang.Object o)

        if (o == null) return false;
        if (this == o) return true;
        if (o instanceof UsernamePasswordCredentials) {
            UsernamePasswordCredentials that = (UsernamePasswordCredentials) o;
            if (LangUtils.equals(this.principal, that.principal)) {
                return true;
            }
        }
        return false;
    
public java.lang.StringgetPassword()

        return password;
    
public java.lang.StringgetUserName()

        return this.principal.getName();
    
public java.security.PrincipalgetUserPrincipal()

        return this.principal;
    
public inthashCode()

        return this.principal.hashCode();
    
public java.lang.StringtoString()

        return this.principal.toString();