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

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

Go to download

Mule Acegi Support exposes Acegi Authentication providers and Method interceptors to authentication event traffic via endpoints and method level authorisation on components.

There is a newer version: 3.1.2
Show newest version
/*
 * $Id: AcegiSecurityContextFactory.java 7976 2007-08-21 14:26:13Z dirk.olmes $
 * --------------------------------------------------------------------------------------
 * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 *
 * The software in this package is published under the terms of the CPAL v1.0
 * license, a copy of which has been included with this distribution in the
 * LICENSE.txt file.
 */

package org.mule.extras.acegi;

import org.mule.umo.security.UMOAuthentication;
import org.mule.umo.security.UMOSecurityContext;
import org.mule.umo.security.UMOSecurityContextFactory;

import org.acegisecurity.context.SecurityContext;
import org.acegisecurity.context.SecurityContextHolder;
import org.acegisecurity.context.SecurityContextImpl;

/**
 * AcegiSecurityContextFactory creates an AcegiSecurityContext for an
 * UMOAuthentication object
 */
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