Ejemplo n.º 1
0
 def __nonzero__(self):
     nz = bool(self.data)
     if not nz:
         # maybe higher-level utility's annotations will be non-zero
         next = queryNextUtility(self, IPrincipalAnnotationUtility)
         if next is not None:
             annotations = next.getAnnotationsById(self.principalId)
             return bool(next)
     return nz
Ejemplo n.º 2
0
 def __getitem__(self, key):
     try:
         return self.data[key]
     except KeyError:
         # We failed locally: delegate to a higher-level utility.
         next = queryNextUtility(self, IPrincipalAnnotationUtility)
         if next is not None:
             annotations = next.getAnnotationsById(self.principalId)
             return annotations[key]
         raise
Ejemplo n.º 3
0
 def getPrincipal(self, id):
     if not id.startswith(self.prefix):
         next = queryNextUtility(self, IAuthentication)
         if next is None:
             raise PrincipalLookupError(id)
         return next.getPrincipal(id)
     id = id[len(self.prefix):]
     for name, authplugin in self.getAuthenticatorPlugins():
         info = authplugin.principalInfo(id)
         if info is None:
             continue
         info.credentialsPlugin = None
         info.authenticatorPlugin = authplugin
         principal = interfaces.IFoundPrincipalFactory(info)(self)
         principal.id = self.prefix + info.id
         return principal
     next = queryNextUtility(self, IAuthentication)
     if next is not None:
         return next.getPrincipal(self.prefix + id)
     raise PrincipalLookupError(id)
Ejemplo n.º 4
0
    def logout(self, request):
        challengeProtocol = None

        for name, credplugin in self.getCredentialsPlugins():
            protocol = getattr(credplugin, 'challengeProtocol', None)
            if challengeProtocol is None or protocol == challengeProtocol:
                if credplugin.logout(request):
                    if protocol is None:
                        return
                    elif challengeProtocol is None:
                        challengeProtocol = protocol

        if challengeProtocol is None:
            next = queryNextUtility(self, IAuthentication)
            if next is not None:
                next.logout(request)