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