Clover Coverage Report - Pebble 2.5-SNAPSHOT
Coverage timestamp: Sat Jun 12 2010 09:39:29 EST
../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
8   49   5   2,67
2   27   0,62   3
3     1,67  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  DefaultUserDetailsService       Line # 15 8 0% 5 1 92,3% 0.9230769
 
  (6)
 
1    package net.sourceforge.pebble.security;
2   
3    import org.acegisecurity.userdetails.UserDetails;
4    import org.acegisecurity.userdetails.UserDetailsService;
5    import org.acegisecurity.userdetails.UsernameNotFoundException;
6    import org.apache.commons.logging.Log;
7    import org.apache.commons.logging.LogFactory;
8   
9    /**
10    * Implementation of the UserDetailsService that gets authentication
11    * credentials from a SecurityRealm implementation.
12    *
13    * @author Simon Brown
14    */
 
15    public class DefaultUserDetailsService implements UserDetailsService {
16   
17    private static final Log log = LogFactory.getLog(DefaultUserDetailsService.class);
18   
19    private SecurityRealm securityRealm;
20   
21    /**
22    * Looks up and returns user details for the given username.
23    *
24    * @param username the username to find details for
25    * @return a PebbleUserDetails instance
26    * @throws org.acegisecurity.userdetails.UsernameNotFoundException
27    */
 
28  4 toggle public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
29  4 try {
30  4 PebbleUserDetails user = securityRealm.getUser(username);
31  4 if (user == null) {
32  2 throw new UsernameNotFoundException("A user with username " + username + " does not exist");
33    } else {
34  2 return user;
35    }
36    } catch (SecurityRealmException e) {
37  0 throw new UsernameNotFoundException("User details not found", e);
38    }
39    }
40   
 
41  2 toggle public SecurityRealm getSecurityRealm() {
42  2 return securityRealm;
43    }
44   
 
45  6 toggle public void setSecurityRealm(SecurityRealm securityRealm) {
46  6 this.securityRealm = securityRealm;
47    }
48   
49    }