Commit ae799a09 authored by Kevin Deldycke's avatar Kevin Deldycke

I apologize, it was a big mistake.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4230 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b69416c1
##############################################################################
#
# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
# Klaus Wlfel <k.woelfel_AT_gmx_DOT_de>
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights
# Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# 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.
#
##############################################################################
""" Classes: ERP5GroupManager
......@@ -63,7 +50,7 @@ class ERP5GroupManager(BasePlugin):
meta_type = 'ERP5 Group Manager'
security = ClassSecurityInfo()
def __init__(self, id, title=None):
self._id = self.id = id
......@@ -77,41 +64,41 @@ class ERP5GroupManager(BasePlugin):
"""
def _getGroupsForPrincipal(user_name, path):
security_group_list = []
# because we aren't logged in, we have to create our own
# SecurityManager to be able to access the Catalog
newSecurityManager(self, self.getPortalObject().getOwner())
base_category_list = self.getPortalObject().getPortalAssignmentBaseCategoryList()
user_name = principal.getId()
person_module = self.getPortalObject().getDefaultModule('Person')
person_object = getattr(person_module, user_name, None)
# return no groups if the username is not registered in person module
if not person_object:
return ()
# Fetch category values from assignment
category_list = self.ERP5Type_getSecurityCategoryFromAssignment(base_category_list, user_name, self, '')
# return no groups if we there are no Security Categories
if not category_list:
return ()
# Get group names from category values
for c_dict in category_list:
security_group_list.append(self.ERP5Type_asSecurityGroupId(category_order=base_category_list, **c_dict))
LOG('erp5_groups', 0, 'user %s is member of %s' %(user_name, str(security_group_list)))
return tuple(security_group_list)
_getGroupsForPrincipal = CachingMethod(_getGroupsForPrincipal, id='ERP5GroupManager_getGroupsForPrincipal')
return _getGroupsForPrincipal(user_name=principal.getId(), path=self.getPhysicalPath())
classImplements( ERP5GroupManager
, IGroupsPlugin
)
......
##############################################################################
#
# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
# Klaus Wlfel <k.woelfel_AT_gmx_DOT_de>
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights
# Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# 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.
#
##############################################################################
""" Classes: ERP5RoleManager
......@@ -50,7 +37,7 @@ def addERP5RoleManager( dispatcher, id, title=None, REQUEST=None ):
'?manage_tabs_message='
'ERP5RoleManager+added.'
% dispatcher.absolute_url())
class ERP5RoleManager( BasePlugin ):
""" PAS plugin to add 'Member' as default
......@@ -64,7 +51,7 @@ class ERP5RoleManager( BasePlugin ):
self._id = self.id = id
self.title = title
#
# IRolesPlugin implementation
#
......@@ -73,9 +60,9 @@ class ERP5RoleManager( BasePlugin ):
""" See IRolesPlugin.
We only ever return Member for every principal
"""
return ('Member',)
classImplements( ERP5RoleManager
, IRolesPlugin
)
......
##############################################################################
#
# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
# Klaus Wlfel <k.woelfel_AT_gmx_DOT_de>
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights
# Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# 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.
#
##############################################################################
""" Classes: ERP5UserManager
......@@ -75,45 +62,45 @@ class ERP5UserManager(BasePlugin):
security.declarePrivate( 'authenticateCredentials' )
def authenticateCredentials(self, credentials):
""" See IAuthenticationPlugin.
o We expect the credentials to be those returned by
ILoginPasswordExtractionPlugin.
"""
def _authenticateCredentials(login, password, path):
if login is None or password is None:
return None
user_list = self.getUserByLogin(login)
if not user_list:
return None
user = user_list[0]
if user.getPassword() == password:
LOG('authenticateCredentials', 0, user.getId())
return user.getId(), login
return None
_authenticateCredentials = CachingMethod(_authenticateCredentials, id='ERP5UserManager_authenticateCredentials')
return _authenticateCredentials(login=credentials.get('login'), password=credentials.get('password'), path=self.getPhysicalPath())
#
# IUserEnumerationPlugin implementation
#
security.declarePrivate( 'enumerateUsers' )
def enumerateUsers(self, id=None, login=None, exact_match=False, sort_by=None, max_results=None, **kw):
""" See IUserEnumerationPlugin.
"""
"""
def _enumerateUsers(t_id, path):
user_info = []
user_objects = []
plugin_id = self.getId()
if isinstance(t_id, str):
t_id = (t_id,)
if t_id:
person_module = self.getPortalObject()\
.getDefaultModule('Person')
......@@ -122,42 +109,42 @@ class ERP5UserManager(BasePlugin):
if user:
if user.getCareerRole() == 'internal':
user_objects.append(user)
elif login:
for user in self.getUserByLogin(login):
if user.getCareerRole() == 'internal':
if user.getCareerRole() == 'internal':
user_objects.append(user)
for user in user_objects:
LOG('enumerateUsers', 0, user.getId())
info = { 'id' : user.getId()
, 'login' : user.getReference()
, 'pluginid' : plugin_id
}
}
user_info.append(info)
return tuple(user_info)
_enumerateUsers = CachingMethod(_enumerateUsers, id='ERP5UserManager_enumerateUsers')
if isinstance(id, list):
id = tuple(id)
return _enumerateUsers(t_id=id, path=self.getPhysicalPath())
def getUserByLogin(self, login):
"""
"""
Search the Catalog for login and return a list of person objects
login can be a string list or a list of strings
"""
"""
# because we aren't logged in, we have to create our own
# SecurityManager to be able to access the Catalog
newSecurityManager(self, self.getPortalObject().portal_catalog.getOwner())
result = self.getPortalObject().portal_catalog(portal_type="Person", reference=login)
return [item.getObject() for item in result]
classImplements( ERP5UserManager
, IAuthenticationPlugin
, IUserEnumerationPlugin
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment