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

de.factoryfx.server.user.persistent.PersistentUserManagement Maven / Gradle / Ivy

package de.factoryfx.server.user.persistent;

import java.util.List;
import java.util.Optional;

import de.factoryfx.server.user.AuthorizedUser;
import de.factoryfx.server.user.User;
import de.factoryfx.server.user.UserManagement;

public class PersistentUserManagement implements UserManagement {

    private final List users;

    public PersistentUserManagement(List users) {
        this.users = users;
    }

    @Override
    public Optional authenticate(String user, String password) {
        for (User existingUser: users){
            if (existingUser.matchUser(user, password)){
                return Optional.of(existingUser.toAuthorizedUser());
            }
        }

        return Optional.empty();
    }

    @Override
    public boolean authorisationRequired() {
        return true;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy