All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.federecio.dropwizard.sample.SampleBasicAuthenticator Maven / Gradle / Ivy

package io.federecio.dropwizard.sample;

import java.util.Optional;
import io.dropwizard.auth.AuthenticationException;
import io.dropwizard.auth.Authenticator;
import io.dropwizard.auth.PrincipalImpl;
import io.dropwizard.auth.basic.BasicCredentials;

public class SampleBasicAuthenticator
        implements Authenticator {

    @Override
    public Optional authenticate(BasicCredentials credentials)
            throws AuthenticationException {
        if ("secret".equals(credentials.getPassword())) {
            return Optional.of(new PrincipalImpl(credentials.getUsername()));
        }
        return Optional.empty();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy