KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > extras > acegi > AcegiSecurityContextFactory


1 /*
2  * $Id: AcegiSecurityContextFactory.java 3798 2006-11-04 04:07:14Z aperepel $
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 MuleSource MPL
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.acegisecurity.context.SecurityContext;
14 import org.acegisecurity.context.SecurityContextHolder;
15 import org.acegisecurity.context.SecurityContextImpl;
16 import org.mule.umo.security.UMOAuthentication;
17 import org.mule.umo.security.UMOSecurityContext;
18 import org.mule.umo.security.UMOSecurityContextFactory;
19
20 /**
21  * <code>AcegiSecurityContextFactory</code> creates an AcegiSecurityContext for an
22  * UMOAuthentication object
23  */

24 public class AcegiSecurityContextFactory implements UMOSecurityContextFactory
25 {
26     public UMOSecurityContext create(UMOAuthentication authentication)
27     {
28         SecurityContext context = new SecurityContextImpl();
29         context.setAuthentication(((AcegiAuthenticationAdapter)authentication).getDelegate());
30
31         if (authentication.getProperties() != null)
32         {
33             if ((authentication.getProperties().containsKey("securityMode")))
34             {
35                 SecurityContextHolder.setStrategyName((String JavaDoc)authentication.getProperties().get(
36                     "securityMode"));
37             }
38         }
39         SecurityContextHolder.setContext(context);
40         return new AcegiSecurityContext(context);
41     }
42 }
43
Popular Tags