1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.kuali.student.common.ws.security; |
17 |
|
|
18 |
|
import java.util.HashMap; |
19 |
|
import java.util.Map; |
20 |
|
|
21 |
|
import javax.xml.parsers.DocumentBuilder; |
22 |
|
import javax.xml.parsers.DocumentBuilderFactory; |
23 |
|
|
24 |
|
import org.w3c.dom.Document; |
25 |
|
import org.w3c.dom.Element; |
26 |
|
import org.w3c.dom.NodeList; |
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 6 |
Complexity Density: 0.43 |
|
34 |
|
public class AuthenticationService { |
35 |
|
|
36 |
|
private static Map<String, String> passwords; |
37 |
|
private static Map<String, String> personids; |
38 |
|
|
39 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 3 |
Complexity Density: 0.27 |
|
40 |
0
|
static {... |
41 |
0
|
passwords = new HashMap<String, String>(); |
42 |
0
|
personids = new HashMap<String, String>(); |
43 |
|
|
44 |
0
|
try { |
45 |
0
|
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); |
46 |
0
|
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); |
47 |
0
|
Document doc = docBuilder.parse(AuthenticationService.class.getClassLoader().getResourceAsStream("ks.users.xml")); |
48 |
0
|
NodeList users = doc.getElementsByTagName("user"); |
49 |
0
|
for(int s=0; s < users.getLength() ; s++){ |
50 |
0
|
Element user = (Element)users.item(s); |
51 |
0
|
passwords.put(user.getAttribute("username"), user.getAttribute("password")); |
52 |
0
|
personids.put(user.getAttribute("username"), user.getAttribute("personid")); |
53 |
|
} |
54 |
|
} catch (Exception e){ |
55 |
|
} |
56 |
|
} |
57 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
58 |
0
|
public static boolean validateUsernamePassword(String username, String password){... |
59 |
0
|
return password.equals(passwords.get(username)); |
60 |
|
} |
61 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
62 |
0
|
public static String getPasswordForUsername(String username){... |
63 |
0
|
return passwords.get(username); |
64 |
|
} |
65 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
66 |
0
|
public static String getPersonIdForUsername(String username){... |
67 |
0
|
return personids.get(username); |
68 |
|
} |
69 |
|
} |