1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.shiro.web.mgt; |
20 | |
|
21 | |
import org.apache.shiro.mgt.DefaultSubjectFactory; |
22 | |
import org.apache.shiro.mgt.SecurityManager; |
23 | |
import org.apache.shiro.session.Session; |
24 | |
import org.apache.shiro.subject.PrincipalCollection; |
25 | |
import org.apache.shiro.subject.Subject; |
26 | |
import org.apache.shiro.subject.SubjectContext; |
27 | |
import org.apache.shiro.web.subject.WebSubjectContext; |
28 | |
import org.apache.shiro.web.subject.support.WebDelegatingSubject; |
29 | |
|
30 | |
import javax.servlet.ServletRequest; |
31 | |
import javax.servlet.ServletResponse; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
public class DefaultWebSubjectFactory extends DefaultSubjectFactory { |
43 | |
|
44 | |
public DefaultWebSubjectFactory() { |
45 | 14 | super(); |
46 | 14 | } |
47 | |
|
48 | |
public Subject createSubject(SubjectContext context) { |
49 | 7 | if (!(context instanceof WebSubjectContext)) { |
50 | 1 | return super.createSubject(context); |
51 | |
} |
52 | 6 | WebSubjectContext wsc = (WebSubjectContext) context; |
53 | 6 | SecurityManager securityManager = wsc.resolveSecurityManager(); |
54 | 6 | Session session = wsc.resolveSession(); |
55 | 6 | boolean sessionEnabled = wsc.isSessionCreationEnabled(); |
56 | 6 | PrincipalCollection principals = wsc.resolvePrincipals(); |
57 | 6 | boolean authenticated = wsc.resolveAuthenticated(); |
58 | 6 | String host = wsc.resolveHost(); |
59 | 6 | ServletRequest request = wsc.resolveServletRequest(); |
60 | 6 | ServletResponse response = wsc.resolveServletResponse(); |
61 | |
|
62 | 6 | return new WebDelegatingSubject(principals, authenticated, host, session, sessionEnabled, |
63 | |
request, response, securityManager); |
64 | |
} |
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
@Deprecated |
71 | |
protected Subject newSubjectInstance(PrincipalCollection principals, boolean authenticated, |
72 | |
String host, Session session, |
73 | |
ServletRequest request, ServletResponse response, |
74 | |
SecurityManager securityManager) { |
75 | 0 | return new WebDelegatingSubject(principals, authenticated, host, session, true, |
76 | |
request, response, securityManager); |
77 | |
} |
78 | |
} |