Clover Coverage Report - Kuali Student 1.1 (Aggregated)
Coverage timestamp: Sun Mar 6 2011 20:32:39 EST
../../../../../../img/srcFileCovDistChart0.png 53% of files have more coverage
10   45   4   10
6   24   0.4   1
1     4  
1    
 
  AuthenticationServiceImpl       Line # 26 10 0% 4 17 0% 0.0
 
No Tests
 
1    /*
2    * Copyright 2008-2009 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10    * Unless required by applicable law or agreed to in writing, software
11    * distributed under the License is distributed on an "AS IS" BASIS,
12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    * See the License for the specific language governing permissions and
14    * limitations under the License.
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   
 
26    public class AuthenticationServiceImpl implements AuthenticationService {
27   
 
28  0 toggle 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    //This is actually the user Id
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    }