-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathnoxml.py
More file actions
160 lines (133 loc) · 5.31 KB
/
noxml.py
File metadata and controls
160 lines (133 loc) · 5.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
"""
Copyright 2006-2008 SpringSource (http://springsource.com), All Rights Reserved
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import controller
import view
from springpython.config import *
from springpython.security.cherrypy3 import *
from springpython.security.web import *
from springpython.security.providers import *
from springpython.security.providers.dao import *
from springpython.security.userdetails import *
from springpython.security.vote import *
class SpringWikiClientAndServer(PythonConfig):
def __init__(self):
super(SpringWikiClientAndServer, self).__init__()
@Object
def controller(self):
return controller.SpringWikiController()
@Object
def read(self):
wikiView = view.Springwiki()
wikiView.controller = self.controller()
return wikiView
@Object
def userDetailsService2(self):
service = InMemoryUserDetailsService()
service.user_dict = {"writer": ("comein", ["VET_ANY"], True)}
return service
@Object
def plainEncoder(self):
return PlaintextPasswordEncoder()
@Object
def plainAuthenticationProvider(self):
provider = DaoAuthenticationProvider()
provider.user_details_service = self.userDetailsService2()
provider.password_encoder = self.plainEncoder()
return provider
@Object
def authenticationManager(self):
manager = AuthenticationManager()
manager.auth_providers = [self.plainAuthenticationProvider()]
return manager
@Object
def authenticationProcessingFilter(self):
filter = AuthenticationProcessingFilter()
filter.auth_manager = self.authenticationManager()
filter.alwaysReauthenticate = False
return filter
@Object
def cherrypySessionStrategy(self):
return CP3SessionStrategy()
@Object
def redirectStrategy(self):
return CP3RedirectStrategy()
@Object
def httpContextFilter(self):
filter = HttpSessionContextIntegrationFilter()
filter.sessionStrategy = self.cherrypySessionStrategy()
return filter
@Object
def authenticationProcessingFilterEntryPoint(self):
filter_point = AuthenticationProcessingFilterEntryPoint()
filter_point.loginFormUrl = "/login"
filter_point.redirectStrategy = self.redirectStrategy()
return filter_point
@Object
def accessDeniedHandler(self):
handler = SimpleAccessDeniedHandler()
handler.errorPage = "/accessDenied"
handler.redirectStrategy = self.redirectStrategy()
return handler
@Object
def exceptionTranslationFilter(self):
filter = ExceptionTranslationFilter()
filter.authenticationEntryPoint = self.authenticationProcessingFilterEntryPoint()
filter.accessDeniedHandler = self.accessDeniedHandler()
return filter
@Object
def filterSecurityInterceptor(self):
interceptor = FilterSecurityInterceptor()
interceptor.validate_config_attributes = False
interceptor.auth_manager = self.authenticationManager()
interceptor.access_decision_mgr = self.accessDecisionManager()
interceptor.sessionStrategy = self.cherrypySessionStrategy()
interceptor.obj_def_source = [("/.*", ["VET_ANY", "CUSTOMER_ANY"])]
return interceptor
@Object
def vetRoleVoter(self):
voter = RoleVoter()
voter.role_prefix = "VET"
return voter
@Object
def customerRoleVoter(self):
voter = RoleVoter()
voter.role_prefix = "CUSTOMER"
return voter
@Object
def accessDecisionManager(self):
policy = AffirmativeBased()
policy.allow_if_all_abstain = False
policy.access_decision_voters = [self.vetRoleVoter(), self.customerRoleVoter()]
return policy
@Object
def filterChainProxy(self):
proxy = CP3FilterChainProxy()
proxy.filterInvocationDefinitionSource = [
("/login.*",
["httpContextFilter"]),
("/.*",
["httpContextFilter",
"exceptionTranslationFilter",
"authenticationProcessingFilter",
"filterSecurityInterceptor"]
)]
return proxy
@Object
def loginForm(self):
form = view.CherryPyAuthenticationForm()
form.filter = self.authenticationProcessingFilter()
form.controller = self.controller()
form.authenticationManager = self.authenticationManager()
form.redirectStrategy = self.redirectStrategy()
form.httpContextFilter = self.httpContextFilter()
return form