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

fr.mmarie.core.auth.GitLabAuthenticator Maven / Gradle / Ivy

The newest version!
package fr.mmarie.core.auth;

import com.google.common.base.Optional;
import io.dropwizard.auth.AuthenticationException;
import io.dropwizard.auth.Authenticator;
import lombok.NonNull;

import java.security.Principal;

public class GitLabAuthenticator implements Authenticator {

    private final String password;

    public GitLabAuthenticator(@NonNull String password) {
        this.password = password;
    }

    @Override
    public Optional authenticate(GitLabCredentials credentials) throws AuthenticationException {
        if(password.contentEquals(credentials.getPassword())) {
            return Optional.of(credentials::getService);
        } else {
            return Optional.absent();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy