/*
 * 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.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) {
            throw new NotFoundException("Identifiaction or authentification failed");
        }
        this.member = tmp;
        this.key = UUID.randomUUID();
    }

    public UUID getKey() {
        return key;
    }

    public Member getMember() {
        return member;
    }

}

@@ -818,16 +818,47 @@
 ption;%0A%0A
+import com.bloatit.common.Log;%0A
 import c
@@ -928,20 +928,17 @@
 Token %7B%0A
-    
+%09
 private 
@@ -958,20 +958,17 @@
 member;%0A
-    
+%09
 private 
@@ -984,20 +984,17 @@
 D key;%0A%0A
-    
+%09
 public A
@@ -1060,24 +1060,18 @@
 ption %7B%0A
-        
+%09%09
 final Me
@@ -1135,24 +1135,18 @@
 sword);%0A
-        
+%09%09
 if (tmp 
@@ -1160,20 +1160,86 @@
 ) %7B%0A
-            
+%09%09%09Log.framework().warn(%22Authentication error %22 + login + %22 %22 + password);%0A%09%09%09
 thro
@@ -1289,18 +1289,16 @@
 authenti
-fi
 cation f
@@ -1310,26 +1310,14 @@
 %22);%0A
-        %7D%0A        
+%09%09%7D%0A%09%09
 this
@@ -1331,24 +1331,18 @@
  = tmp;%0A
-        
+%09%09
 this.key
@@ -1363,27 +1363,21 @@
 UUID();%0A
-    %7D%0A%0A    
+%09%7D%0A%0A%09
 public U
@@ -1387,32 +1387,26 @@
  getKey() %7B%0A
-        
+%09%09
 return key;%0A
@@ -1409,19 +1409,13 @@
 ey;%0A
-    %7D%0A%0A    
+%09%7D%0A%0A%09
 publ
@@ -1442,16 +1442,10 @@
 ) %7B%0A
-        
+%09%09
 retu
@@ -1459,12 +1459,9 @@
 er;%0A
-    
+%09
 %7D%0A%0A%7D

fix spelling + add log