[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security - BasicAuthAdapter.py:1.1.2.2 ILoginPassword.py:1.1.2.2 LoginPassword.py:1.1.2.2

Guido van Rossum guido@python.org
Thu, 13 Dec 2001 15:45:17 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/Security
In directory cvs.zope.org:/tmp/cvs-serv27544

Modified Files:
      Tag: Zope-3x-branch
	BasicAuthAdapter.py ILoginPassword.py LoginPassword.py 
Log Message:
Add needLogin(realm) method to ILoginPassword interface and its implementations.

=== Zope3/lib/python/Zope/App/Security/BasicAuthAdapter.py 1.1.2.1 => 1.1.2.2 ===
 
+from Zope.Publisher.HTTP.IHTTPCredentials import IHTTPCredentials
 from LoginPassword import LoginPassword
 
 class BasicAuthAdapter(LoginPassword):
 
+    __used_for__ = IHTTPCredentials
+
+    __request = None
+
     def __init__(self, request):
+        self.__request = request
         # XXX base64 decoding should be done here, not in request
         lpw = request._authUserPW()
         if lpw is None:
@@ -12,4 +18,6 @@
         else:
             login, password = lpw
         LoginPassword.__init__(self, login, password)
-    
+
+    def needLogin(self, realm):
+        self.__request.unauthorized("basic realm=%s" % realm)


=== Zope3/lib/python/Zope/App/Security/ILoginPassword.py 1.1.2.1 => 1.1.2.2 ===
         """Return password, or None if no login name found.
         If there's a login but no password, return empty string."""
+
+    def needLogin(realm):
+        """Indicate that a login is needed.  The realm argument
+        is the name of the principal registry."""


=== Zope3/lib/python/Zope/App/Security/LoginPassword.py 1.1.2.1 => 1.1.2.2 ===
     def getPassword(self):
         return self.__password
+
+    def needLogin(self, realm):
+        pass