Clover Coverage Report - KS Security 1.1-SNAPSHOT (Aggregated)
Coverage timestamp: Thu Mar 3 2011 04:57:05 EST
../../../../../img/srcFileCovDistChart0.png 6% of files have more coverage
6   59   4   3
2   26   0.67   2
2     2  
1    
 
  KSDefaultUserDetailsService       Line # 31 6 0% 4 10 0% 0.0
 
No Tests
 
1    /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10    * software distributed under the License is distributed on an "AS IS"
11    * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12    * or implied. See the License for the specific language governing
13    * permissions and limitations under the License.
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    * This is a description of what this class does - Rich don't forget to fill this in.
27    *
28    * @author Kuali Student Team
29    *
30    */
 
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    // Spring Security requires roles to have a prefix of ROLE_ ,
40    // look in org.springframework.security.vote.RoleVoter to change.
41    private GrantedAuthority[] authorities =
42    AuthorityUtils.commaSeparatedStringToAuthorityArray("ROLE_KS_ADMIN, ROLE_KS_USER");
43   
 
44  0 toggle 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   
 
56  0 toggle public void setAuthorities(String[] roles) {
57  0 this.authorities = AuthorityUtils.stringArrayToAuthorityArray(roles);
58    }
59    }