Index: /main/waeup.sirp/trunk/src/waeup/sirp/jambtables/authentication.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/jambtables/authentication.py	(revision 5459)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/jambtables/authentication.py	(revision 5460)
@@ -248,20 +248,20 @@
         if not isinstance(credentials, dict):
             return None
-        if not 'accesscode' in credentials.keys():
-            return None
-        if not 'jambregno' in credentials.keys():
-            credentials['jambregno'] = None
-        ac = get_access_code(credentials['accesscode'])
+        accesscode = credentials.get('accesscode', None)
+        jambregno = credentials.get('jambregno', None)
+        if accesscode is None:
+            return None
+        applicant_data, ac = get_applicant_data(jambregno, accesscode)
+        appl_ac = getattr(applicant_data, 'access_code', None)
+        #print "AUTH", accesscode, jambregno
         if ac is None:
-            # Invalid access code entered.
-            # XXX: log this.
-            return None
-        if credentials['jambregno'] is not None:
-            # applications of JAMB applicants must exist already
-            if not application_exists(credentials['jambregno']):
-                return None
-        return ApplicantPrincipalInfo(
-            credentials['accesscode'], credentials['jambregno']
-            )
+            return None
+        if jambregno is not None and applicant_data is None:
+            return None
+        if ac.invalidation_date is not None and appl_ac != ac.representation:
+            return None
+        if appl_ac is not None and appl_ac != ac.representation:
+            return None
+        return ApplicantPrincipalInfo(accesscode, jambregno)
 
     def principalInfo(self, id):
