All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mule.extras.acegi.AcegiSecurityContextFactory Maven / Gradle / Ivy

/*
 * $Id: AcegiSecurityContextFactory.java 3242 2006-09-27 13:28:29 +0000 (Wed, 27 Sep 2006) Marie.Rizzo $
 * --------------------------------------------------------------------------------------
 * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 *
 * The software in this package is published under the terms of the MuleSource MPL
 * license, a copy of which has been included with this distribution in the
 * LICENSE.txt file.
 */

package org.mule.extras.acegi;

import org.acegisecurity.context.SecurityContext;
import org.acegisecurity.context.SecurityContextHolder;
import org.acegisecurity.context.SecurityContextImpl;
import org.mule.umo.security.UMOAuthentication;
import org.mule.umo.security.UMOSecurityContext;
import org.mule.umo.security.UMOSecurityContextFactory;

/**
 * AcegiSecurityContextFactory creates an Acegisecuritycontext for the
 * a UMOAuthentication object
 * 
 * @author Ross Mason
 * @version $Revision: 3242 $
 */
public class AcegiSecurityContextFactory implements UMOSecurityContextFactory
{
    public UMOSecurityContext create(UMOAuthentication authentication)
    {
        SecurityContext context = new SecurityContextImpl();
        context.setAuthentication(((AcegiAuthenticationAdapter)authentication).getDelegate());
        
        if (authentication.getProperties() != null){
            if ((authentication.getProperties().containsKey("securityMode")))
            {
                SecurityContextHolder.setStrategyName((String)authentication.getProperties().get("securityMode"));
            }
        }   
        SecurityContextHolder.setContext(context);
        return new AcegiSecurityContext(context);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy