Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.yammer.dropwizard.auth.basic;
 
 
 
 import static com.google.common.base.Preconditions.checkNotNull;

A set of user-provided Basic Authentication credentials, consisting of a username and a password.
public class BasicCredentials {
    private final String username;
    private final String password;

    
Creates a new BasicCredentials with the given username and password.

Parameters:
username the username
password the password
    public BasicCredentials(String usernameString password) {
        this. = checkNotNull(username);
        this. = checkNotNull(password);
    }

    
Returns the credentials' username.

Returns:
the credentials' username
    public String getUsername() {
        return ;
    }

    
Returns the credentials' password.

Returns:
the credentials' password
    public String getPassword() {
        return ;
    }
    @Override
    public boolean equals(Object obj) {
        if (this == obj) { return true; }
        if ((obj == null) || (getClass() != obj.getClass())) { return false; }
        final BasicCredentials that = (BasicCredentialsobj;
        // N.B.: Do a constant-time comparison here to prevent timing attacks.
        final byte[] thisBytes = .getBytes(.);
        final byte[] thatBytes = that.password.getBytes(.);
        return .equals(that.username) && MessageDigest.isEqual(thisBytesthatBytes);
    }
    @Override
    public int hashCode() {
        return (31 * .hashCode()) + .hashCode();
    }
    @Override
    public String toString() {
        return Objects.toStringHelper(this)
                      .add("username")
                      .add("password""**********")
                      .toString();
    }
New to GrepCode? Check out our FAQ X