Coverage Report - org.mule.extras.acegi.AcegiSecurityContextFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
AcegiSecurityContextFactory
75%
6/8
25%
1/4
3
 
 1  
 /*
 2  
  * $Id: AcegiSecurityContextFactory.java 7963 2007-08-21 08:53:15Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.extras.acegi;
 12  
 
 13  
 import org.mule.umo.security.UMOAuthentication;
 14  
 import org.mule.umo.security.UMOSecurityContext;
 15  
 import org.mule.umo.security.UMOSecurityContextFactory;
 16  
 
 17  
 import org.acegisecurity.context.SecurityContext;
 18  
 import org.acegisecurity.context.SecurityContextHolder;
 19  
 import org.acegisecurity.context.SecurityContextImpl;
 20  
 
 21  
 /**
 22  
  * <code>AcegiSecurityContextFactory</code> creates an AcegiSecurityContext for an
 23  
  * UMOAuthentication object
 24  
  */
 25  42
 public class AcegiSecurityContextFactory implements UMOSecurityContextFactory
 26  
 {
 27  
     public UMOSecurityContext create(UMOAuthentication authentication)
 28  
     {
 29  20
         SecurityContext context = new SecurityContextImpl();
 30  20
         context.setAuthentication(((AcegiAuthenticationAdapter)authentication).getDelegate());
 31  
 
 32  20
         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  20
         SecurityContextHolder.setContext(context);
 41  20
         return new AcegiSecurityContext(context);
 42  
     }
 43  
 }