1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.module.acegi; |
8 | |
|
9 | |
import org.mule.api.security.Authentication; |
10 | |
import org.mule.api.security.SecurityContext; |
11 | |
import org.mule.api.security.SecurityContextFactory; |
12 | |
|
13 | |
import org.acegisecurity.context.SecurityContextHolder; |
14 | |
import org.acegisecurity.context.SecurityContextImpl; |
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | 0 | public class AcegiSecurityContextFactory implements SecurityContextFactory |
21 | |
{ |
22 | |
public SecurityContext create(Authentication authentication) |
23 | |
{ |
24 | 0 | org.acegisecurity.context.SecurityContext context = new SecurityContextImpl(); |
25 | 0 | context.setAuthentication(((AcegiAuthenticationAdapter)authentication).getDelegate()); |
26 | |
|
27 | 0 | if (authentication.getProperties() != null) |
28 | |
{ |
29 | 0 | if ((authentication.getProperties().containsKey("securityMode"))) |
30 | |
{ |
31 | 0 | SecurityContextHolder.setStrategyName((String)authentication.getProperties().get( |
32 | |
"securityMode")); |
33 | |
} |
34 | |
} |
35 | 0 | SecurityContextHolder.setContext(context); |
36 | 0 | return new AcegiSecurityContext(context); |
37 | |
} |
38 | |
} |