1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
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 | |
|
23 | |
|
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 | |
} |