<commit_before>package org.andersonkmi.service;

import org.andersonkmi.data.Usuario;
import org.andersonkmi.data.UsuarioDAO;

public class LoginService {
	private UsuarioDAO usuarioDAO;
	
	public LoginService() {
		usuarioDAO = new UsuarioDAO();
	}
	
	public void login(String user, String password) throws InvalidLoginOrPasswordException {
		System.out.println("Validando senha para usuario/senha: " + user + "/" + password);
		String vcapServices = System.getenv("VCAP_SERVICES");
		if(vcapServices != null) {
			productionLogin(user, password);
		}
		developmentLogin(user, password);
	}
	
	private void developmentLogin(String user, String password) throws InvalidLoginOrPasswordException {
		if(user.isEmpty() || password.isEmpty()) {
			throw new InvalidLoginOrPasswordException("Invalid login or password");	
		}
	}
	
	private void productionLogin(String user, String password) throws InvalidLoginOrPasswordException {
		System.out.println("***** Usando procedimento produtivo *****");
		Usuario usuario = findUser(user);
		
		if(usuario != null) {
			System.out.println("Usuario encontrado na base");
			System.out.println("TRACE: password = '" + usuario.getPassword() + "'");
			if(!isPasswordValid(password, usuario.getPassword())) {
				System.err.println("Senha invalida");
				throw new InvalidLoginOrPasswordException("Invalid login or password");
			} else {
				registerCurrentAccess(usuario);<commit_msg>Removed trace code<commit_after>package org.andersonkmi.service;

import org.andersonkmi.data.Usuario;
import org.andersonkmi.data.UsuarioDAO;

public class LoginService {
	private UsuarioDAO usuarioDAO;
	
	public LoginService() {
		usuarioDAO = new UsuarioDAO();
	}
	
	public void login(String user, String password) throws InvalidLoginOrPasswordException {
		String vcapServices = System.getenv("VCAP_SERVICES");
		if(vcapServices != null) {
			productionLogin(user, password);
		}
		developmentLogin(user, password);
	}
	
	private void developmentLogin(String user, String password) throws InvalidLoginOrPasswordException {
		if(user.isEmpty() || password.isEmpty()) {
			throw new InvalidLoginOrPasswordException("Invalid login or password");	
		}
	}
	
	private void productionLogin(String user, String password) throws InvalidLoginOrPasswordException {
		System.out.println("***** Usando procedimento produtivo *****");
		Usuario usuario = findUser(user);
		
		if(usuario != null) {
			System.out.println("Usuario encontrado na base");
			if(!isPasswordValid(password, usuario.getPassword())) {
				System.err.println("Senha invalida");
				throw new InvalidLoginOrPasswordException("Invalid login or password");
			} else {
				registerCurrentAccess(usuario);
{'fraction_non_alphanumeric': 0.11350949013770004, 'fraction_numerical': 0.0, 'mean_word_length': 5.430622009569378, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5827906', 'n_tokens_mistral': 870, 'n_tokens_neox': 788, 'n_words': 176}