Coverage Report - org.mule.module.spring.security.SpringSecurityContextFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
SpringSecurityContextFactory
0%
0/8
0%
0/4
3
 
 1  
 /*
 2  
  * $Id: SpringSecurityContextFactory.java 20477 2010-12-06 23:38:52Z mike.schilling $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.module.spring.security;
 12  
 
 13  
 import org.mule.api.security.Authentication;
 14  
 import org.mule.api.security.SecurityContext;
 15  
 import org.mule.api.security.SecurityContextFactory;
 16  
 
 17  
 import org.springframework.security.core.context.SecurityContextHolder;
 18  
 import org.springframework.security.core.context.SecurityContextImpl;
 19  
 
 20  
 
 21  
 /**
 22  
  * <code>AcegiSecurityContextFactory</code> creates an AcegiSecurityContext for an
 23  
  * Authentication object
 24  
  */
 25  0
 public class SpringSecurityContextFactory implements SecurityContextFactory
 26  
 {
 27  
     public SecurityContext create(Authentication authentication)
 28  
     {
 29  0
         org.springframework.security.core.context.SecurityContext context = new SecurityContextImpl();        
 30  0
         context.setAuthentication(((SpringAuthenticationAdapter)authentication).getDelegate());
 31  
 
 32  0
         if (authentication.getProperties() != null)
 33  
         {
 34  0
             if ((authentication.getProperties().containsKey("securityMode")))
 35  
             {
 36  0
                 SecurityContextHolder.setStrategyName((String)authentication.getProperties().get(
 37  
                     "securityMode"));
 38  
             }
 39  
         }
 40  0
         SecurityContextHolder.setContext(context);
 41  0
         return new SpringSecurityContext(context);
 42  
     }
 43  
 }