| 1 |  |   | 
  | 2 |  |   | 
  | 3 |  |   | 
  | 4 |  |   | 
  | 5 |  |   | 
  | 6 |  |   | 
  | 7 |  |   | 
  | 8 |  |   | 
  | 9 |  |   | 
  | 10 |  |   | 
  | 11 |  |   | 
  | 12 |  |   | 
  | 13 |  |   | 
  | 14 |  |   | 
  | 15 |  |   | 
  | 16 |  |  package org.kuali.student.common.ws.security; | 
  | 17 |  |   | 
  | 18 |  |  import javax.xml.ws.WebServiceContext; | 
  | 19 |  |   | 
  | 20 |  |  import org.apache.log4j.Logger; | 
  | 21 |  |   | 
  | 22 |  |   | 
  | 23 |  |   | 
  | 24 |  |   | 
  | 25 |  |   | 
  | 26 |  |   | 
  | 27 | 0 |  public class PrincipalAccessor { | 
  | 28 |  |       | 
  | 29 | 0 |      final static Logger logger = Logger.getLogger(PrincipalAccessor.class); | 
  | 30 |  |       | 
  | 31 |  |      public static PrincipalWrapper getPrincipalFromWebServiceContext(WebServiceContext wsContext){ | 
  | 32 | 0 |          Class<?> principalWrapperImpl = null; | 
  | 33 | 0 |          PrincipalWrapper principal = null; | 
  | 34 |  |                   | 
  | 35 |  |          try { | 
  | 36 | 0 |              principalWrapperImpl =   | 
  | 37 |  |                  (Class.forName("org.kuali.student.common.cxf.security.PrincipalWrapperImpl")); | 
  | 38 | 0 |          } catch (ClassNotFoundException cnfe){ | 
  | 39 |  |              try{ | 
  | 40 | 0 |                  principalWrapperImpl =  | 
  | 41 |  |                      Class.forName("org.kuali.student.common.metro.security.PrincipalWrapperImpl"); | 
  | 42 | 0 |              } catch (ClassNotFoundException cnfe2){ | 
  | 43 | 0 |                  logger.error("PrincpalWraper implementaion could not be found."); | 
  | 44 | 0 |              } | 
  | 45 | 0 |          }  | 
  | 46 |  |           | 
  | 47 |  |          try{ | 
  | 48 | 0 |              principal = (PrincipalWrapper)principalWrapperImpl.newInstance(); | 
  | 49 | 0 |              principal.setPrincipal(wsContext); | 
  | 50 | 0 |          } catch (Exception e){ | 
  | 51 | 0 |              logger.error("Exception occured: ", e);             | 
  | 52 | 0 |          } | 
  | 53 |  |               | 
  | 54 | 0 |          return principal; | 
  | 55 |  |      } | 
  | 56 |  |  } |