package asa.service.impl;

import asa.service.ConstantsInterface;
import asa.service.LoginService;
import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;


@Service("loginService")
//@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class LoginServiceImpl implements ConstantsInterface,LoginService{

	
	public boolean authenticate(String username, String password){
		
		// TEST FOR ADMIN LOGIN
		boolean usernameAuth=false;
		boolean passwordAuth=false;
		if(username.equals(ConstantsInterface.ADMIN_USR)){
			System.out.println("username authenticated");
			usernameAuth=true;
			
		}
		
		if(password.equals(ConstantsInterface.ADMIN_PWD)){
			System.out.println("password authenticated");
			passwordAuth=true;
		}
		
		if(usernameAuth && passwordAuth){
			return true;
		}
		else{
			return false;
		}
	
	}
	
	
}

@@ -88,24 +88,48 @@
 ginService;%0A
+import asa.dao.UserDAO;%0A
 import org.s
@@ -163,16 +163,80 @@
 ervice;%0A
+import org.springframework.beans.factory.annotation.Autowired;%0A%0A
 //import
@@ -465,16 +465,55 @@
 ervice%7B%0A
+%09%0A%09@Autowired%0A%09private UserDAO userDAO;
 %0A%09%0A%09publ
@@ -515,23 +515,22 @@
 %09public 
-boolean
+String
  authent
@@ -572,16 +572,18 @@
 ord)%7B%0A%09%09
+/*
 %0A%09%09// TE
@@ -661,16 +661,19 @@
 =false;%0A
+%09%09%0A
 %09%09if(use
@@ -1011,19 +1011,842 @@
  false;%0A
-
 %09%09%7D
+%09%09%09%09%0A%09%09*/%0A%09%09boolean usernameAuth=false;%0A%09%09boolean passwordAuth=false;%0A%09%09%0A%09%09userDAO;%0A%09%09User user= userDAO.findByUsername(username);%0A%09%09%0A%09%09// username invalid%0A%09%09if(user==null)%7B%0A%09%09%09System.out.println(%22No User Found%22);%0A%09%09%09passwordAuth=true;%0A%09%09%7D%0A%09%09// username valid%0A%09%09else%7B%0A%09%09%09System.out.println(%22username authenticated%22);%0A%09%09%09usernameAuth=true;%0A%09%09%09%0A%09%09%7D%0A%09%09// password valid%0A%09%09if(password.equals(user.getPassword()))%7B%0A%09%09%09System.out.println(%22password authenticated%22);%0A%09%09%09passwordAuth=true;%0A%09%09%7D%0A%09%09else%7B%0A%09%09%09System.out.println(%22password invalid%22);%0A%09%09%09%0A%09%09%7D%0A%09%09%0A%09%09// both valid%0A%09%09if(usernameAuth && passwordAuth)%7B%0A%09%09%09return %22success%22;%0A%09%09%7D%09%09%0A%09%09// password invalid%0A%09%09else if(usernameAuth)%7B%0A%09%09%09return %22username%22;%0A%09%09%7D%0A%09%09// username invalid%0A%09%09else if(passwordAuth)%7B%0A%09%09%09return %22password%22;%0A%09%09%7D%0A%09%09// both invalid%0A%09%09else%0A%09%09%09return %22failed%22;%0A%09%09%7D%0A%09%09
 %0A%09%0A%09%7D%0A%09%0A

Update LoginServiceImpl.java