// Path: el-bombillo-service-registry/src/main/java/org/bitionaire/elbombillo/registry/api/model/Credentials.java
// @EqualsAndHashCode @ToString(of = "username")
// public class Credentials {
// 
//     @JsonProperty
//     @Getter private String username;
// 
//     @JsonProperty
//     @Getter private String password;
// 
//     @JsonCreator
//     public Credentials(@JsonProperty("username") final String username,
//                        @JsonProperty("password") final String password) {
//         Preconditions.checkNotNull(username, "the username may not be null");
//         Preconditions.checkNotNull(password, "the password may not be null");
// 
//         this.username = username;
//         this.password = password;
//     }
// 
// }


import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import io.dropwizard.auth.AuthenticationException;
import io.dropwizard.auth.Authenticator;
import io.dropwizard.auth.basic.BasicCredentials;
import org.bitionaire.elbombillo.registry.api.model.Credentials;
package org.bitionaire.elbombillo.registry.core.auth;


public class ServiceRegistryAuthenticator implements Authenticator<BasicCredentials, ServiceRegistryCaller> {

    private final Credentials credentials;

    public ServiceRegistryAuthenticator(final Credentials credentials) {
        Preconditions.checkNotNull("auth credentials may not be null");
        this.credentials = credentials;
    }

    @Override
    public Optional<ServiceRegistryCaller> authenticate(final BasicCredentials credentials) throws AuthenticationException {
// Path: el-bombillo-service-registry/src/main/java/org/bitionaire/elbombillo/registry/api/model/Credentials.java
// @EqualsAndHashCode @ToString(of = "username")
// public class Credentials {
// 
//     @JsonProperty
//     @Getter private String username;
// 
//     @JsonProperty
//     @Getter private String password;
// 
//     @JsonCreator
//     public Credentials(@JsonProperty("username") final String username,
//                        @JsonProperty("password") final String password) {
//         Preconditions.checkNotNull(username, "the username may not be null");
//         Preconditions.checkNotNull(password, "the password may not be null");
// 
//         this.username = username;
//         this.password = password;
//     }
// 
// }


// Path: el-bombillo-service-registry/src/main/java/org/bitionaire/elbombillo/registry/core/auth/ServiceRegistryAuthenticator.java
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import io.dropwizard.auth.AuthenticationException;
import io.dropwizard.auth.Authenticator;
import io.dropwizard.auth.basic.BasicCredentials;
import org.bitionaire.elbombillo.registry.api.model.Credentials;

package org.bitionaire.elbombillo.registry.core.auth;


public class ServiceRegistryAuthenticator implements Authenticator<BasicCredentials, ServiceRegistryCaller> {

    private final Credentials credentials;

    public ServiceRegistryAuthenticator(final Credentials credentials) {
        Preconditions.checkNotNull("auth credentials may not be null");
        this.credentials = credentials;
    }

    @Override
    public Optional<ServiceRegistryCaller> authenticate(final BasicCredentials credentials) throws AuthenticationException {
        if (this.credentials.getUsername().equals(credentials.getUsername()) &&