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

com.roskart.dropwizard.jaxws.example.auth.BasicAuthenticator Maven / Gradle / Ivy

There is a newer version: 1.2.3
Show newest version
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