| 1 |  |  | 
            
  
    | 2 |  |  | 
            
  
    | 3 |  |  | 
            
  
    | 4 |  |  | 
            
  
    | 5 |  |  | 
            
  
    | 6 |  |  | 
            
  
    | 7 |  |  | 
            
  
    | 8 |  |  | 
            
  
    | 9 |  |  | 
            
  
    | 10 |  |  | 
            
  
    | 11 |  |  | 
            
  
    | 12 |  |  | 
            
  
    | 13 |  |  | 
            
  
    | 14 |  |  | 
            
  
    | 15 |  |  | 
            
  
    | 16 |  | package org.kuali.rice.kim.service.impl; | 
            
  
    | 17 |  |  | 
            
  
    | 18 |  | import javax.servlet.http.HttpServletRequest; | 
            
  
    | 19 |  |  | 
            
  
    | 20 |  | import org.kuali.rice.kim.service.AuthenticationService; | 
            
  
    | 21 |  | import org.kuali.student.common.util.security.UserWithId; | 
            
  
    | 22 |  | import org.springframework.security.Authentication; | 
            
  
    | 23 |  | import org.springframework.security.context.SecurityContextHolder; | 
            
  
    | 24 |  | import org.springframework.security.userdetails.UserDetails; | 
            
  
    | 25 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 17 (17) | Complexity: 4 | Complexity Density: 0.4 |  | 
  
  
    | 26 |  | public class AuthenticationServiceImpl implements AuthenticationService { | 
            
  
    | 27 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 16 (16) | Complexity: 4 | Complexity Density: 0.4 |  | 
  
  
    | 28 | 0 |  public String getPrincipalName(HttpServletRequest request) {... | 
            
  
    | 29 | 0 | String username=null; | 
            
  
    | 30 | 0 | Authentication auth = SecurityContextHolder.getContext().getAuthentication(); | 
            
  
    | 31 |  |  | 
            
  
    | 32 | 0 | if(auth!=null){ | 
            
  
    | 33 | 0 | Object obj = auth.getPrincipal(); | 
            
  
    | 34 | 0 | if(obj instanceof UserWithId){ | 
            
  
    | 35 |  |  | 
            
  
    | 36 | 0 | username = ((UserWithId)obj).getUserId(); | 
            
  
    | 37 | 0 | }else if (obj instanceof UserDetails) { | 
            
  
    | 38 | 0 | username = ((UserDetails)obj).getUsername(); | 
            
  
    | 39 |  | } else { | 
            
  
    | 40 | 0 | username = request.getRemoteUser(); | 
            
  
    | 41 |  | } | 
            
  
    | 42 |  | } | 
            
  
    | 43 | 0 | return username; | 
            
  
    | 44 |  | } | 
            
  
    | 45 |  | } |