KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: AcegiSecurityContext.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.mule.umo.security.UMOAuthentication;
16 import org.mule.umo.security.UMOSecurityContext;
17
18 /**
19  * <code>AcegiSecurityContext</code> is a UMOSecurityContext wrapper used to
20  * interface with an Acegi SecurityContext
21  */

22
23 public class AcegiSecurityContext implements UMOSecurityContext
24 {
25     private SecurityContext delegate;
26     private AcegiAuthenticationAdapter authentication;
27
28     public AcegiSecurityContext(SecurityContext delegate)
29     {
30         this.delegate = delegate;
31         SecurityContextHolder.setContext(this.delegate);
32     }
33
34     public void setAuthentication(UMOAuthentication authentication)
35     {
36         this.authentication = ((AcegiAuthenticationAdapter)authentication);
37         delegate.setAuthentication(this.authentication.getDelegate());
38         SecurityContextHolder.setContext(delegate);
39     }
40
41     public UMOAuthentication getAuthentication()
42     {
43         return this.authentication;
44     }
45 }
46
Popular Tags