View Javadoc

1   package org.kuali.mobility.shared;
2   
3   import java.util.HashMap;
4   import java.util.Map;
5   
6   public class LoginServiceImpl implements LoginService {
7   
8       private static final Map<String, String> userMap = new HashMap<String, String>();
9       /*
10  	    Here, there are two set of HashMap's entry. First one is for MD5 encryption and 
11  	    2nd one(commented) is for SHA-1 encryption. So, When You will plan to use MD5 encryption,
12  	    use the 1st HashMap's entry and comment the 2nd set of HashMap's entry and vice-versa.
13      */
14  	/*
15  	    Here, both userName and password fields are same. So, the below users can log in
16  	    using same userName and password. Password fields are stored in encrypted format.
17  	    Use the below HashMap entry if you want to use MD5 encryption
18  	*/
19      static{
20      	userMap.put("nurul", "6968a2c57c3a4fee8fadc79a80355e4d"); 
21  	    userMap.put("joe", "8ff32489f92f33416694be8fdc2d4c22");
22  	    userMap.put("nate", "b396645fffbeb1379510ab1fccadea5d");
23  	    userMap.put("charl", "36ee71a98f85221446f6b12965952c94");
24  	    userMap.put("aniruddha", "6da97bc1d43d22875f1cbcc47cd05d33");
25  	    userMap.put("mitch", "fae53351b9effc708e764e871bef3119");
26      } 
27      /*
28  	    If You want to use SHA-1 hashing encryption, use the below commented
29  	    Hash Map's entry.
30      */
31  //    static{
32  //    	userMap.put("nurul", "06d6571dfa4a4ee157b900f3b11a44034339f2d2");
33  //        userMap.put("joe", "16a9a54ddf4259952e3c118c763138e83693d7fd");
34  //        userMap.put("nate", "4f3407de78bccc8cc160ee4d278d5efe7162e6b5");
35  //        userMap.put("charl", "d0fdfa50ba93c55e700837650403d8c576e9dd22");
36  //        userMap.put("aniruddha", "16bef47ba68b0e0a74efc3286dc0590b5d7d2c26");
37  //        userMap.put("mitch", "b2b9d047cb15a4ee2f66e3be0a97e512d2f22473");
38  //    }
39      
40      
41      
42  	@Override
43  	public boolean isValidUser(String userId) {
44          if(userMap.containsKey(userId)){
45              return true;
46          }
47  		return false;
48  	}
49  
50  	@Override
51  	public boolean isValidLogin(String userId, String passwordHash) {
52          if(isValidUser(userId)){
53          	if(userMap.get(userId).equalsIgnoreCase(passwordHash)){
54          		return true;
55          	}
56          }
57  		return false;
58  	}
59  
60  }