Changeset 5440 for main/waeup.sirp/trunk/src/waeup/sirp
- Timestamp:
- 15 Aug 2010, 15:05:55 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/jambtables/authentication.py
r5435 r5440 36 36 from waeup.sirp.authentication import Account, PrincipalInfo 37 37 from waeup.sirp.jambtables.interfaces import ( 38 IApplicantPrincipalInfo, IApplicantPrincipal) 38 IApplicantPrincipalInfo, IApplicantPrincipal, IApplicantSessionCredentials, 39 IJAMBApplicantSessionCredentials) 39 40 40 41 class PortalUser(grok.Role): … … 121 122 return principal 122 123 123 124 125 # 126 # Credentials plugins and related.... 127 # 128 129 class ApplicantCredentials(object): 130 """Credentials class for ordinary applicants. 131 """ 132 grok.implements(IApplicantSessionCredentials) 133 134 def __init__(self, access_code): 135 self.access_code = access_code 136 137 def getAccessCode(self): 138 """Get the access code. 139 """ 140 return self.access_code 141 142 class JAMBApplicantCredentials(ApplicantCredentials): 143 """Credentials class for JAMB-screened applicants. 144 """ 145 grok.implements(IJAMBApplicantSessionCredentials) 146 147 def __init__(self, access_code, jamb_reg_no): 148 self.access_code = access_code 149 self.jamb_reg_no = jamb_reg_no 150 151 def getJAMBRegNo(self): 152 """Get the JAMB registration no. 153 """ 154 return self.jamb_reg_no 155 124 156 class WAeUPApplicantCredentialsPlugin(grok.GlobalUtility, 125 157 SessionCredentialsPlugin): 158 """A credentials plugin that scans requests for applicant credentials. 159 """ 126 160 grok.provides(ICredentialsPlugin) 127 161 grok.name('applicant_credentials') 128 162 129 163 loginpagename = 'login' 130 loginfield = 'form.login'131 passwordfield = 'form.password'164 accesscode_field = 'form.access_code' 165 jamb_reg_no_field = 'form.jamb_reg_no' 132 166 133 167 def extractCredentials(self, request): 134 168 """Extracts credentials from a session if they exist. 135 136 This is currently the implementation from zope.pluggableauth.137 138 XXX: Make this plugin handle login_pde-like input.139 169 """ 140 170 if not IHTTPRequest.providedBy(request): … … 143 173 sessionData = session.get( 144 174 'zope.pluggableauth.browserplugins') 145 login = request.get(self.loginfield, None)146 password = request.get(self.passwordfield, None)175 access_code = request.get(self.acccesscode_field, None) 176 jamb_reg_no = request.get(self.jamb_reg_no_field, None) 147 177 credentials = None 148 178 149 if login and password: 150 credentials = SessionCredentials(login, password) 179 if access_code and jamb_reg_no: 180 credentials = JAMBApplicantCredentials( 181 access_code, jamb_reg_no) 182 elif access_code: 183 credentials = ApplicantCredentials(access_code) 151 184 elif not sessionData: 152 185 return None … … 159 192 if not credentials: 160 193 return None 161 return {'login': credentials.getLogin(), 162 'password': credentials.getPassword()} 194 if credentials.getJAMBRegNo() is not None: 195 return {'accesscode': credentials.getAccessCode(), 196 'jambregno': credentials.getJAMBRegNo()} 197 return {'accesscode': credentials.getAccessCode()} 163 198 164 199 … … 199 234 """ 200 235 return access_code 201
Note: See TracChangeset for help on using the changeset viewer.