package com.example.helloworld.auth; import com.example.helloworld.core.User; import io.dropwizard.auth.AuthenticationException; import io.dropwizard.auth.basic.BasicCredentials; import io.dropwizard.java8.auth.Authenticator; import java.util.Optional; public class ExampleAuthenticator implements Authenticator<BasicCredentials, User> { @Override public Optional<User> authenticate(BasicCredentials credentials) throws AuthenticationException { if ("secret".equals(credentials.getPassword())) { return Optional.of(new User(credentials.getUsername())); } return Optional.empty(); } }