// Path: dropwizard-java8-auth/src/main/java/io/dropwizard/java8/auth/Authenticator.java
// public interface Authenticator<C, P extends Principal> {
//     /**
//      * Given a set of user-provided credentials, return an optional principal.
//      * <p/>
//      * If the credentials are valid and map to a principal, returns an {@code Optional.of(p)}.
//      * <p/>
//      * If the credentials are invalid, returns an {@code Optional.absent()}.
//      *
//      * @param credentials a set of user-provided credentials
//      * @return either an authenticated principal or an absent optional
//      * @throws AuthenticationException if the credentials cannot be authenticated due to an
//      *                                 underlying error
//      */
//     Optional<P> authenticate(C credentials) throws AuthenticationException;
// }


import io.dropwizard.auth.AuthenticationException;
import io.dropwizard.auth.Authorizer;
import io.dropwizard.auth.PrincipalImpl;
import io.dropwizard.auth.basic.BasicCredentials;
import io.dropwizard.java8.auth.Authenticator;
import java.security.Principal;
import java.util.List;
import java.util.Optional;
package io.dropwizard.java8.auth.util;



public class AuthUtil {

    public static Authenticator<BasicCredentials, Principal> getBasicAuthenticator(final List<String> validUsers) {
        return credentials -> {
            if (validUsers.contains(credentials.getUsername()) && "secret".equals(credentials.getPassword())) {
// Path: dropwizard-java8-auth/src/main/java/io/dropwizard/java8/auth/Authenticator.java
// public interface Authenticator<C, P extends Principal> {
//     /**
//      * Given a set of user-provided credentials, return an optional principal.
//      * <p/>
//      * If the credentials are valid and map to a principal, returns an {@code Optional.of(p)}.
//      * <p/>
//      * If the credentials are invalid, returns an {@code Optional.absent()}.
//      *
//      * @param credentials a set of user-provided credentials
//      * @return either an authenticated principal or an absent optional
//      * @throws AuthenticationException if the credentials cannot be authenticated due to an
//      *                                 underlying error
//      */
//     Optional<P> authenticate(C credentials) throws AuthenticationException;
// }


// Path: dropwizard-java8-auth/src/test/java/io/dropwizard/java8/auth/util/AuthUtil.java
import io.dropwizard.auth.AuthenticationException;
import io.dropwizard.auth.Authorizer;
import io.dropwizard.auth.PrincipalImpl;
import io.dropwizard.auth.basic.BasicCredentials;
import io.dropwizard.java8.auth.Authenticator;
import java.security.Principal;
import java.util.List;
import java.util.Optional;

package io.dropwizard.java8.auth.util;



public class AuthUtil {

    public static Authenticator<BasicCredentials, Principal> getBasicAuthenticator(final List<String> validUsers) {
        return credentials -> {
            if (validUsers.contains(credentials.getUsername()) && "secret".equals(credentials.getPassword())) {
                return Optional.<Principal>of(new PrincipalImpl(credentials.getUsername()));