Coverage Report - org.mule.module.acegi.AcegiSecurityContextFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
AcegiSecurityContextFactory
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.acegi;
 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.acegisecurity.context.SecurityContextHolder;
 14  
 import org.acegisecurity.context.SecurityContextImpl;
 15  
 
 16  
 /**
 17  
  * <code>AcegiSecurityContextFactory</code> creates an AcegiSecurityContext for an
 18  
  * {@link Authentication} object
 19  
  */
 20  0
 public class AcegiSecurityContextFactory implements SecurityContextFactory
 21  
 {
 22  
     public SecurityContext create(Authentication authentication)
 23  
     {
 24  0
         org.acegisecurity.context.SecurityContext context = new SecurityContextImpl();
 25  0
         context.setAuthentication(((AcegiAuthenticationAdapter)authentication).getDelegate());
 26  
 
 27  0
         if (authentication.getProperties() != null)
 28  
         {
 29  0
             if ((authentication.getProperties().containsKey("securityMode")))
 30  
             {
 31  0
                 SecurityContextHolder.setStrategyName((String)authentication.getProperties().get(
 32  
                     "securityMode"));
 33  
             }
 34  
         }
 35  0
         SecurityContextHolder.setContext(context);
 36  0
         return new AcegiSecurityContext(context);
 37  
     }
 38  
 }