|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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) | |||
| Result | |||
|
0.46153846
|
net.sourceforge.pebble.security.DefaultUserDetailsServiceTest.testLoadByUsername
net.sourceforge.pebble.security.DefaultUserDetailsServiceTest.testLoadByUsername
|
1 PASS | |
|
0.46153846
|
net.sourceforge.pebble.security.DefaultUserDetailsServiceTest.testLoadByUsernameThrowsExceptionWhenUserDoesntExist
net.sourceforge.pebble.security.DefaultUserDetailsServiceTest.testLoadByUsernameThrowsExceptionWhenUserDoesntExist
|
1 PASS | |
|
0.46153846
|
net.sourceforge.pebble.security.DefaultUserDetailsServiceTest.testLoadByUsernameThrowsExceptionWhenUserDoesntExist
net.sourceforge.pebble.security.DefaultUserDetailsServiceTest.testLoadByUsernameThrowsExceptionWhenUserDoesntExist
|
1 PASS | |
|
0.46153846
|
net.sourceforge.pebble.security.DefaultUserDetailsServiceTest.testLoadByUsername
net.sourceforge.pebble.security.DefaultUserDetailsServiceTest.testLoadByUsername
|
1 PASS | |
|
0.15384616
|
net.sourceforge.pebble.security.DefaultUserDetailsServiceTest.testSecurityRealm
net.sourceforge.pebble.security.DefaultUserDetailsServiceTest.testSecurityRealm
|
1 PASS | |
|
0.15384616
|
net.sourceforge.pebble.security.DefaultUserDetailsServiceTest.testSecurityRealm
net.sourceforge.pebble.security.DefaultUserDetailsServiceTest.testSecurityRealm
|
1 PASS | |
| 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 |
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 |
public SecurityRealm getSecurityRealm() { |
| 42 | 2 | return securityRealm; |
| 43 | } | |
| 44 | ||
| 45 | 6 |
public void setSecurityRealm(SecurityRealm securityRealm) { |
| 46 | 6 | this.securityRealm = securityRealm; |
| 47 | } | |
| 48 | ||
| 49 | } | |
|
||||||||||||