[Zope3-checkins] SVN: ldapauth/trunk/ Added interface ILDAPManager for to manage principals

Roger Ineichen roger at projekt01.ch
Wed Jul 21 17:18:40 EDT 2004


Log message for revision 26660:
  Added interface ILDAPManager for to manage principals
  Added LDAPManager adapter
  Split browser/configure.zcml in principal.zcml and source.zcml
  --> work in progress


Changed:
  U   ldapauth/trunk/browser/configure.zcml
  A   ldapauth/trunk/browser/principal.zcml
  A   ldapauth/trunk/browser/source.zcml
  U   ldapauth/trunk/configure.zcml
  U   ldapauth/trunk/interfaces.py
  A   ldapauth/trunk/manager.py


-=-
Modified: ldapauth/trunk/browser/configure.zcml
===================================================================
--- ldapauth/trunk/browser/configure.zcml	2004-07-21 18:17:18 UTC (rev 26659)
+++ ldapauth/trunk/browser/configure.zcml	2004-07-21 21:18:39 UTC (rev 26660)
@@ -2,66 +2,7 @@
     xmlns:zope="http://namespaces.zope.org/zope"
     xmlns="http://namespaces.zope.org/browser">
 
-    <!-- LDAPPrincipalSource -->
-    <addMenuItem
-        title="Add LDAP Principal Source"
-        class="ldapauth.source.LDAPPrincipalSource"
-        permission="zope.ManageServices" />
+    <include file="source.zcml" />
+    <include file="principal.zcml" />
 
-    <addform
-        schema="ldapauth.interfaces.ILDAPBasedPrincipalSource" 
-        label="Add LDAP-based Principal Source" 
-        name="AddLDAPPrincipalSourceForm" 
-        permission="zope.ManageContent" />
-
-    <!-- provide a own Contents view without add and delete functions 
-         Perhaps we enhance this view later. At this time we use thos view
-         instead of the inherited Contents view from the ocntainer. -->
-    <page
-        for="ldapauth.interfaces.ILDAPBasedPrincipalSource"
-        name="principals.html"
-        attribute="principals"
-        class=".principals.Principals"
-        menu="zmi_views" title="Contents"
-        permission="zope.ManageContent"/>
-
-    <editform 
-        schema="ldapauth.interfaces.ILDAPBasedPrincipalSource" 
-        label="Edit LDAP-based Principal Source" 
-        name="edit.html"        
-        menu="zmi_views" title="Edit"
-        fields="host port basedn login_attribute manager_dn manager_passwd" 
-        permission="zope.ManageContent" />
-
-    <!-- connetion test view -->
-    <page
-        for="ldapauth.interfaces.ILDAPBasedPrincipalSource"
-        name="check.html"
-        attribute="check"
-        class=".check.CheckLDAPView"
-        menu="zmi_views" title="Test"
-        permission="zope.ManageServices"/>
-
-    <pages
-        for="ldapauth.interfaces.ILDAPBasedPrincipalSource"
-        permission="zope.ManageBindings"
-        class="zope.app.cache.browser.cacheable.CacheableView"
-        >
-
-    <page
-        name="Caching.html"
-        attribute="form"  
-        menu="zmi_views" title="Caching"
-        />
-    <page
-        name="ChangeCaching.html"
-        attribute="action"
-        />
-    <page
-        name="InvalidateCache.html"
-        attribute="invalidate"
-        />
-
-    </pages>
-
 </configure>

Added: ldapauth/trunk/browser/principal.zcml
===================================================================
--- ldapauth/trunk/browser/principal.zcml	2004-07-21 18:17:18 UTC (rev 26659)
+++ ldapauth/trunk/browser/principal.zcml	2004-07-21 21:18:39 UTC (rev 26660)
@@ -0,0 +1,8 @@
+<configure
+    xmlns:zope="http://namespaces.zope.org/zope"
+    xmlns="http://namespaces.zope.org/browser">
+
+    <!-- LDAP principal manager -->
+
+
+</configure>


Property changes on: ldapauth/trunk/browser/principal.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: ldapauth/trunk/browser/source.zcml
===================================================================
--- ldapauth/trunk/browser/source.zcml	2004-07-21 18:17:18 UTC (rev 26659)
+++ ldapauth/trunk/browser/source.zcml	2004-07-21 21:18:39 UTC (rev 26660)
@@ -0,0 +1,67 @@
+<configure
+    xmlns:zope="http://namespaces.zope.org/zope"
+    xmlns="http://namespaces.zope.org/browser">
+
+    <!-- LDAPPrincipalSource -->
+    <addMenuItem
+        title="Add LDAP Principal Source"
+        class="ldapauth.source.LDAPPrincipalSource"
+        permission="zope.ManageServices" />
+
+    <addform
+        schema="ldapauth.interfaces.ILDAPBasedPrincipalSource" 
+        label="Add LDAP-based Principal Source" 
+        name="AddLDAPPrincipalSourceForm" 
+        permission="zope.ManageContent" />
+
+    <!-- provide a own Contents view without add and delete functions 
+         Perhaps we enhance this view later. At this time we use thos view
+         instead of the inherited Contents view from the ocntainer. -->
+    <page
+        for="ldapauth.interfaces.ILDAPBasedPrincipalSource"
+        name="principals.html"
+        attribute="principals"
+        class=".principals.Principals"
+        menu="zmi_views" title="Contents"
+        permission="zope.ManageContent"/>
+
+    <editform 
+        schema="ldapauth.interfaces.ILDAPBasedPrincipalSource" 
+        label="Edit LDAP-based Principal Source" 
+        name="edit.html"        
+        menu="zmi_views" title="Edit"
+        fields="host port basedn login_attribute manager_dn manager_passwd" 
+        permission="zope.ManageContent" />
+
+    <!-- connetion test view -->
+    <page
+        for="ldapauth.interfaces.ILDAPBasedPrincipalSource"
+        name="check.html"
+        attribute="check"
+        class=".check.CheckLDAPView"
+        menu="zmi_views" title="Test"
+        permission="zope.ManageServices"/>
+
+    <pages
+        for="ldapauth.interfaces.ILDAPBasedPrincipalSource"
+        permission="zope.ManageBindings"
+        class="zope.app.cache.browser.cacheable.CacheableView"
+        >
+
+    <page
+        name="Caching.html"
+        attribute="form"  
+        menu="zmi_views" title="Caching"
+        />
+    <page
+        name="ChangeCaching.html"
+        attribute="action"
+        />
+    <page
+        name="InvalidateCache.html"
+        attribute="invalidate"
+        />
+
+    </pages>
+
+</configure>


Property changes on: ldapauth/trunk/browser/source.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: ldapauth/trunk/configure.zcml
===================================================================
--- ldapauth/trunk/configure.zcml	2004-07-21 18:17:18 UTC (rev 26659)
+++ ldapauth/trunk/configure.zcml	2004-07-21 21:18:39 UTC (rev 26660)
@@ -10,22 +10,41 @@
         <factory
             id="ldapauth.source.LDAPPrincipalSource" />
 
-        <allow 
-            interface=".interfaces.ILDAPBasedPrincipalSource" />
-
         <implements
             interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
 
-        <require
-            permission="zope.ManageContent"
+        <implements
+            interface="zope.app.container.interfaces.IContainer" />
+
+        <allow
+            interface=".interfaces.ILDAPBasedPrincipalSource" />
+
+        <require
+            permission="zope.ManageContent"
+            interface="zope.app.container.interfaces.IReadContainer" />
+
+        <require
+            permission="zope.ManageServices"
+            interface="zope.app.container.interfaces.IWriteContainer" />
+
+        <require
+            permission="zope.ManageServices" 
             set_schema=".interfaces.ILDAPBasedPrincipalSource" />
 
     </content>
 
+    <!-- Pluggable LDAP manager adapter -->
     <adapter
+        factory="ldapauth.manager.LDAPManagerAdapter"
+        provides="ldapauth.interfaces.ILDAPManager"
+        for=".interfaces.ILDAPBasedPrincipalSource"
+        />
+
+    <!-- LDAP connection test adapter -->
+    <adapter
         factory="ldapauth.check.CheckLDAPAdapter"
         provides="ldapauth.interfaces.ICheckLDAPAdapter"
-        for="*"
+        for=".interfaces.ILDAPBasedPrincipalSource"
         />
 
     <!-- add browser views -->

Modified: ldapauth/trunk/interfaces.py
===================================================================
--- ldapauth/trunk/interfaces.py	2004-07-21 18:17:18 UTC (rev 26659)
+++ ldapauth/trunk/interfaces.py	2004-07-21 21:18:39 UTC (rev 26660)
@@ -21,6 +21,8 @@
 from zope.app.i18n import ZopeMessageIDFactory as _
 from zope.app.pluggableauth.interfaces import IPrincipalSource
 
+
+
 class ILDAPBasedPrincipalSource(IPrincipalSource):
     """Describe LDAP-based authentication sources."""
 
@@ -52,6 +54,20 @@
 
 
 
+class ILDAPManager(Interface):
+    """A LDAP server manager."""
+
+    def addPrincipal(login_attribute, ldap_principal):
+        """Add a principal to the LDAP server."""
+
+    def editPrincipal(login_attribute, ldap_principal):
+        """Edit a principal to the LDAP server."""
+
+    def deletePrincipal(login_attribute):
+        """Delete a principal to the LDAP server."""
+
+
+
 class ICheckLDAPAdapter(Interface):
     """A test adapter for to test the connection between Zope and LDAP."""
 

Added: ldapauth/trunk/manager.py
===================================================================
--- ldapauth/trunk/manager.py	2004-07-21 18:17:18 UTC (rev 26659)
+++ ldapauth/trunk/manager.py	2004-07-21 21:18:39 UTC (rev 26660)
@@ -0,0 +1,47 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""A LDAP manager for the ldapauth plugable authentication module.
+
+$Id$
+"""
+
+from zope.security.proxy import trustedRemoveSecurityProxy
+from zope.interface import implements
+
+from interfaces import ILDAPManager
+
+
+
+class LDAPManagerAdapter:
+    """A LDAP manager adapter."""
+
+    implements(ILDAPManager)
+
+    def __init__(self, source):
+        self.context = source
+    
+    def addPrincipal(self, login_attribute, ldap_principal):
+        source = trustedRemoveSecurityProxy(self.context)
+        # add a principal to the 
+        pass
+
+    def editPrincipal(self, login_attribute, ldap_principal):
+        source = trustedRemoveSecurityProxy(self.context)
+        # replace the principal on the ldap server with the given principal
+        pass
+
+    def deletePrincipal(self, login_attribute):
+        source = trustedRemoveSecurityProxy(self.context)
+        # delete the principal with the given login_attribute
+        pass



More information about the Zope3-Checkins mailing list