DB server side improved some problems when showing bookings remain
[RRRRHHHH_Code] / ruralHouses / src / businessLogic / LoginManager.java
1 package businessLogic;
2
3 import java.rmi.RemoteException;
4 import java.rmi.server.UnicastRemoteObject;
5 import java.util.Vector;
6
7 import common.LoginInterface;
8
9 import dataAccess.DB4oManager;
10 import domain.Account;
11
12 public class LoginManager extends UnicastRemoteObject implements LoginInterface {
13
14         /**
15          * 
16          */
17         private static final long serialVersionUID = 1L;
18         DB4oManager dbMngr;
19
20         public LoginManager() throws RemoteException {
21                 super();
22                 try {
23                         dbMngr = DB4oManager.getInstance();
24                 } catch (Exception e) {
25                         e.printStackTrace();
26                 }
27         }
28
29         @Override
30         public Account checkCredentials(String usr, String pwd) {
31                 Account ac = new Account(SecurityManager.getInstance().calculateHash(
32                                 usr));
33                 try {
34                         Vector<Account> account = dbMngr.getAccount(ac);
35                         if (account.isEmpty())
36                                 return null;
37                         if (SecurityManager.getInstance().isExpectedPassword(
38                                         pwd.toCharArray(), account.get(0).getSalt(),
39                                         account.get(0).getPassword())) {
40
41                                 return account.get(0);
42                         }
43                         return null;
44
45                 } catch (Exception e) {
46                         e.printStackTrace();
47                 }
48                 return null;
49         }
50 }