Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.yammer.dropwizard.auth.basic;
 import static;

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.

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

Returns the credentials' username.

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

Returns the credentials' password.

the credentials' password
    public String getPassword() {
        return ;
    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);
    public int hashCode() {
        return (31 * .hashCode()) + .hashCode();
    public String toString() {
        return Objects.toStringHelper(this)
New to GrepCode? Check out our FAQ X