
com.roskart.dropwizard.jaxws.example.auth.BasicAuthenticator Maven / Gradle / Ivy
package com.roskart.dropwizard.jaxws.example.auth;
import com.google.common.base.Optional;
import com.roskart.dropwizard.jaxws.example.core.User;
import io.dropwizard.auth.AuthenticationException;
import io.dropwizard.auth.Authenticator;
import io.dropwizard.auth.basic.BasicCredentials;
/**
* BasicAuthenticator is copied from dropwizard-example.
*/
public class BasicAuthenticator implements Authenticator {
@Override
public Optional authenticate(BasicCredentials credentials) throws AuthenticationException {
if ("secret".equals(credentials.getPassword())) {
return Optional.of(new User(credentials.getUsername()));
}
throw new AuthenticationException("Invalid credentials");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy