Changeset 5818


Ignore:
Timestamp:
8 Mar 2011, 02:33:18 (14 years ago)
Author:
uli
Message:
  • Try to remove all JAMB related code
  • Remove unused imports
File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/authentication.py

    r5806 r5818  
    2828from zope.pluggableauth.factories import Principal
    2929from zope.pluggableauth.interfaces import (
    30     ICredentialsPlugin, IAuthenticatorPlugin, IPrincipalInfo,
     30    ICredentialsPlugin, IAuthenticatorPlugin,
    3131    IAuthenticatedPrincipalFactory, AuthenticatedPrincipalCreated)
    3232from zope.pluggableauth.plugins.session import SessionCredentialsPlugin
     
    3434from zope.publisher.interfaces.http import IHTTPRequest
    3535from zope.session.interfaces import ISession
    36 from waeup.sirp.authentication import Account, PrincipalInfo
     36from waeup.sirp.accesscodes import get_access_code
    3737from waeup.sirp.applicants.interfaces import (
    3838    IApplicantPrincipalInfo, IApplicantPrincipal, IApplicantSessionCredentials,
    3939    IJAMBApplicantSessionCredentials)
    40 from waeup.sirp.applicants import (
    41     get_applicant_data, application_exists,
    42     )
    43 from waeup.sirp.accesscodes import get_access_code
     40from waeup.sirp.applicants import get_applicant_data
     41
    4442
    4543class PortalUser(grok.Role):
     
    5452    grok.implements(IApplicantPrincipalInfo)
    5553
    56     def __init__(self, access_code, jamb_reg_no=None):
    57         self.id = principal_id(access_code, jamb_reg_no)
     54    def __init__(self, access_code):
     55        self.id = principal_id(access_code)
    5856        self.title = u'Applicant'
    5957        self.description = u'An Applicant'
    6058        self.credentialsPlugin = None
    6159        self.authenticatorPlugin = None
    62         self.reg_no = jamb_reg_no
    6360        self.access_code = access_code
    6461
     
    7269    grok.implements(IApplicantPrincipal)
    7370
    74     def __init__(self, access_code, reg_no, prefix=None):
    75         self.id = principal_id(access_code, reg_no)
     71    def __init__(self, access_code, prefix=None):
     72        self.id = principal_id(access_code)
    7673        if prefix is not None:
    7774            self.id = '%s.%s' % (prefix, self.id)
     
    7976        self.description = u'An applicant'
    8077        self.groups = []
    81         self.reg_no = reg_no
    8278        self.access_code = access_code
    8379
     
    10399        principal = ApplicantPrincipal(
    104100            self.info.access_code,
    105             self.info.reg_no,
    106101            authentication.prefix,
    107102            )
     
    144139    grok.implements(IJAMBApplicantSessionCredentials)
    145140
    146     def __init__(self, access_code, jamb_reg_no):
    147         self.access_code = access_code
    148         self.jamb_reg_no = jamb_reg_no
    149 
    150     def getJAMBRegNo(self):
    151         """Get the JAMB registration no.
    152         """
    153         return self.jamb_reg_no
     141    def __init__(self, access_code):
     142        self.access_code = access_code
    154143
    155144class WAeUPApplicantCredentialsPlugin(grok.GlobalUtility,
     
    164153    accesscode_series_field = 'form.ac_series'
    165154    accesscode_number_field = 'form.ac_number'
    166     jamb_reg_no_field = 'form.jamb_reg_no'
    167155
    168156    def extractCredentials(self, request):
     
    177165        access_code_series = request.get(self.accesscode_series_field, None)
    178166        access_code_no = request.get(self.accesscode_number_field, None)
    179         jamb_reg_no = request.get(self.jamb_reg_no_field, None)
    180167        access_code = '%s-%s-%s' % (
    181168            access_code_prefix, access_code_series, access_code_no)
     
    184171        credentials = None
    185172
    186         if access_code and jamb_reg_no:
    187             credentials = JAMBApplicantCredentials(
    188                 access_code, jamb_reg_no)
    189         elif access_code:
     173        if access_code:
    190174            credentials = ApplicantCredentials(access_code)
    191175        elif not sessionData:
     
    204188            # its structure.
    205189            return None
    206         if not IJAMBApplicantSessionCredentials.providedBy(credentials):
    207             # Entered credentials are ordinary applicant credentials,
    208             # not JAMB-screened applicant credentials
    209             return {'accesscode': credentials.getAccessCode()}
    210         return {'accesscode': credentials.getAccessCode(),
    211                 'jambregno': credentials.getJAMBRegNo()}
     190
     191        # Entered credentials are ordinary applicant credentials,
     192        # not JAMB-screened applicant credentials
     193        return {'accesscode': credentials.getAccessCode()}
    212194
    213195
     
    226208            return None
    227209        accesscode = credentials.get('accesscode', None)
    228         jambregno = credentials.get('jambregno', None)
    229210        if accesscode is None:
    230211            return None
    231         applicant_data, ac = get_applicant_data(jambregno, accesscode)
     212        applicant_data = get_applicant_data(accesscode)
     213        ac = get_access_code(accesscode) # Get the real access code object
    232214        appl_ac = getattr(applicant_data, 'access_code', None)
    233         #print "AUTH", accesscode, jambregno
    234215        if ac is None:
    235216            return None
    236         if jambregno is not None and applicant_data is None:
    237             return None
    238217        if ac.invalidation_date is not None and appl_ac != ac.representation:
    239218            return None
    240219        if appl_ac is not None and appl_ac != ac.representation:
    241220            return None
    242         return ApplicantPrincipalInfo(accesscode, jambregno)
     221        return ApplicantPrincipalInfo(accesscode)
    243222
    244223    def principalInfo(self, id):
     
    254233        return None
    255234
    256 def principal_id(access_code, jamb_reg_no=None):
     235def principal_id(access_code):
    257236    """Get a principal ID for applicants.
    258237
Note: See TracChangeset for help on using the changeset viewer.