1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.kuali.student.security.spring; |
17 |
|
|
18 |
|
import org.springframework.security.GrantedAuthority; |
19 |
|
import org.springframework.security.userdetails.User; |
20 |
|
import org.springframework.security.userdetails.UserDetails; |
21 |
|
import org.springframework.security.userdetails.UserDetailsService; |
22 |
|
import org.springframework.security.userdetails.UsernameNotFoundException; |
23 |
|
import org.springframework.security.util.AuthorityUtils; |
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
@author |
29 |
|
|
30 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 4 |
Complexity Density: 0.67 |
|
31 |
|
public class KSDefaultUserDetailsService implements UserDetailsService{ |
32 |
|
|
33 |
|
private User ksuser = null; |
34 |
|
private String password = ""; |
35 |
|
|
36 |
|
private boolean enabled = true; |
37 |
|
private boolean nonlocked = true; |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
private GrantedAuthority[] authorities = |
42 |
|
AuthorityUtils.commaSeparatedStringToAuthorityArray("ROLE_KS_ADMIN, ROLE_KS_USER"); |
43 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
44 |
0
|
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {... |
45 |
|
|
46 |
0
|
if(username==null || username.equals("")){ |
47 |
0
|
throw new UsernameNotFoundException("Username cannot be null or empty"); |
48 |
|
} |
49 |
0
|
password = username; |
50 |
|
|
51 |
0
|
ksuser = new User(username, password, enabled, true, true, nonlocked, authorities); |
52 |
|
|
53 |
0
|
return ksuser; |
54 |
|
} |
55 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
56 |
0
|
public void setAuthorities(String[] roles) {... |
57 |
0
|
this.authorities = AuthorityUtils.stringArrayToAuthorityArray(roles); |
58 |
|
} |
59 |
|
} |