<commit_before>/*
 * Copyright (C) 2010 BloatIt.
 * 
 * This file is part of BloatIt.
 * 
 * BloatIt is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * BloatIt is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with BloatIt. If not, see <http://www.gnu.org/licenses/>.
 */

package com.bloatit.framework;

import java.util.UUID;

import javassist.NotFoundException;

import com.bloatit.common.Log;
import com.bloatit.framework.managers.MemberManager;

public class AuthToken {
	private final Member member;
	private final UUID key;

	public AuthToken(String login, String password) throws NotFoundException {
		final Member tmp = MemberManager.getByLoginAndPassword(login, password);
		if (tmp == null) {
			Log.framework().warn("Authentication error " + login + " " + password);
			throw new NotFoundException("Identifiaction or authentication failed");
		}
		this.member = tmp;
		this.key = UUID.randomUUID();
	}

	public UUID getKey() {
		return key;
	}

	public Member getMember() {
		return member;
	}

}<commit_msg>framework: correct the persistence problem with AuthToken<commit_after>/*
 * Copyright (C) 2010 BloatIt.
 * 
 * This file is part of BloatIt.
 * 
 * BloatIt is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * BloatIt is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with BloatIt. If not, see <http://www.gnu.org/licenses/>.
 */

package com.bloatit.framework;

import java.util.UUID;

import javassist.NotFoundException;

import com.bloatit.common.Log;
import com.bloatit.framework.managers.MemberManager;
import com.bloatit.model.data.util.SessionManager;

public class AuthToken {
    private final Member member;
    private final UUID key;

    public AuthToken(String login, String password) throws NotFoundException {
        final Member tmp = MemberManager.getByLoginAndPassword(login, password);
        if (tmp == null) {
            Log.framework().warn("Authentication error " + login + " " + password);
            throw new NotFoundException("Identifiaction or authentication failed");
        }
        this.member = tmp;
        this.key = UUID.randomUUID();
    }

    public UUID getKey() {
        return key;
    }

    public Member getMember() {
        if (SessionManager.getSessionFactory().getCurrentSession().contains(member.getDao())) {
            return member;
        }
        return MemberManager.getMemberById(member.getId());
    }

}
{'fraction_non_alphanumeric': 0.08450704225352113, 'fraction_numerical': 0.0029967036260113876, 'mean_word_length': 3.5476839237057223, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2885093', 'n_tokens_mistral': 937, 'n_tokens_neox': 902, 'n_words': 352}