Commit b69416c1 authored by Kevin Deldycke's avatar Kevin Deldycke

Use GPL instead of ZPL.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4229 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7a437180
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights # Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
# Reserved. # Klaus Wlfel <k.woelfel_AT_gmx_DOT_de>
# #
# This software is subject to the provisions of the Zope Public License, # WARNING: This program as such is intended to be used by professional
# Version 2.1 (ZPL). A copy of the ZPL should accompany this # programmers who take the whole responsability of assessing all potential
# distribution. # consequences resulting from its eventual inadequacies and bugs
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # End users who are looking for a ready-to-use solution with commercial
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # garantees and support are strongly adviced to contract a Free Software
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # Service Company
# FOR A PARTICULAR PURPOSE. #
# 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.
# #
############################################################################## ##############################################################################
""" Classes: ERP5GroupManager """ Classes: ERP5GroupManager
...@@ -50,7 +63,7 @@ class ERP5GroupManager(BasePlugin): ...@@ -50,7 +63,7 @@ class ERP5GroupManager(BasePlugin):
meta_type = 'ERP5 Group Manager' meta_type = 'ERP5 Group Manager'
security = ClassSecurityInfo() security = ClassSecurityInfo()
def __init__(self, id, title=None): def __init__(self, id, title=None):
self._id = self.id = id self._id = self.id = id
...@@ -64,41 +77,41 @@ class ERP5GroupManager(BasePlugin): ...@@ -64,41 +77,41 @@ class ERP5GroupManager(BasePlugin):
""" """
def _getGroupsForPrincipal(user_name, path): def _getGroupsForPrincipal(user_name, path):
security_group_list = [] security_group_list = []
# because we aren't logged in, we have to create our own # because we aren't logged in, we have to create our own
# SecurityManager to be able to access the Catalog # SecurityManager to be able to access the Catalog
newSecurityManager(self, self.getPortalObject().getOwner()) newSecurityManager(self, self.getPortalObject().getOwner())
base_category_list = self.getPortalObject().getPortalAssignmentBaseCategoryList() base_category_list = self.getPortalObject().getPortalAssignmentBaseCategoryList()
user_name = principal.getId() user_name = principal.getId()
person_module = self.getPortalObject().getDefaultModule('Person') person_module = self.getPortalObject().getDefaultModule('Person')
person_object = getattr(person_module, user_name, None) person_object = getattr(person_module, user_name, None)
# return no groups if the username is not registered in person module # return no groups if the username is not registered in person module
if not person_object: if not person_object:
return () return ()
# Fetch category values from assignment # Fetch category values from assignment
category_list = self.ERP5Type_getSecurityCategoryFromAssignment(base_category_list, user_name, self, '') category_list = self.ERP5Type_getSecurityCategoryFromAssignment(base_category_list, user_name, self, '')
# return no groups if we there are no Security Categories # return no groups if we there are no Security Categories
if not category_list: if not category_list:
return () return ()
# Get group names from category values # Get group names from category values
for c_dict in category_list: for c_dict in category_list:
security_group_list.append(self.ERP5Type_asSecurityGroupId(category_order=base_category_list, **c_dict)) 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))) LOG('erp5_groups', 0, 'user %s is member of %s' %(user_name, str(security_group_list)))
return tuple(security_group_list) return tuple(security_group_list)
_getGroupsForPrincipal = CachingMethod(_getGroupsForPrincipal, id='ERP5GroupManager_getGroupsForPrincipal') _getGroupsForPrincipal = CachingMethod(_getGroupsForPrincipal, id='ERP5GroupManager_getGroupsForPrincipal')
return _getGroupsForPrincipal(user_name=principal.getId(), path=self.getPhysicalPath()) return _getGroupsForPrincipal(user_name=principal.getId(), path=self.getPhysicalPath())
classImplements( ERP5GroupManager classImplements( ERP5GroupManager
, IGroupsPlugin , IGroupsPlugin
) )
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights # Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
# Reserved. # Klaus Wlfel <k.woelfel_AT_gmx_DOT_de>
# #
# This software is subject to the provisions of the Zope Public License, # WARNING: This program as such is intended to be used by professional
# Version 2.1 (ZPL). A copy of the ZPL should accompany this # programmers who take the whole responsability of assessing all potential
# distribution. # consequences resulting from its eventual inadequacies and bugs
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # End users who are looking for a ready-to-use solution with commercial
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # garantees and support are strongly adviced to contract a Free Software
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # Service Company
# FOR A PARTICULAR PURPOSE. #
# 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.
# #
############################################################################## ##############################################################################
""" Classes: ERP5RoleManager """ Classes: ERP5RoleManager
...@@ -37,7 +50,7 @@ def addERP5RoleManager( dispatcher, id, title=None, REQUEST=None ): ...@@ -37,7 +50,7 @@ def addERP5RoleManager( dispatcher, id, title=None, REQUEST=None ):
'?manage_tabs_message=' '?manage_tabs_message='
'ERP5RoleManager+added.' 'ERP5RoleManager+added.'
% dispatcher.absolute_url()) % dispatcher.absolute_url())
class ERP5RoleManager( BasePlugin ): class ERP5RoleManager( BasePlugin ):
""" PAS plugin to add 'Member' as default """ PAS plugin to add 'Member' as default
...@@ -51,7 +64,7 @@ class ERP5RoleManager( BasePlugin ): ...@@ -51,7 +64,7 @@ class ERP5RoleManager( BasePlugin ):
self._id = self.id = id self._id = self.id = id
self.title = title self.title = title
# #
# IRolesPlugin implementation # IRolesPlugin implementation
# #
...@@ -60,9 +73,9 @@ class ERP5RoleManager( BasePlugin ): ...@@ -60,9 +73,9 @@ class ERP5RoleManager( BasePlugin ):
""" See IRolesPlugin. """ See IRolesPlugin.
We only ever return Member for every principal We only ever return Member for every principal
""" """
return ('Member',) return ('Member',)
classImplements( ERP5RoleManager classImplements( ERP5RoleManager
, IRolesPlugin , IRolesPlugin
) )
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights # Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
# Reserved. # Klaus Wlfel <k.woelfel_AT_gmx_DOT_de>
# #
# This software is subject to the provisions of the Zope Public License, # WARNING: This program as such is intended to be used by professional
# Version 2.1 (ZPL). A copy of the ZPL should accompany this # programmers who take the whole responsability of assessing all potential
# distribution. # consequences resulting from its eventual inadequacies and bugs
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # End users who are looking for a ready-to-use solution with commercial
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # garantees and support are strongly adviced to contract a Free Software
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # Service Company
# FOR A PARTICULAR PURPOSE. #
# 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.
# #
############################################################################## ##############################################################################
""" Classes: ERP5UserManager """ Classes: ERP5UserManager
...@@ -62,45 +75,45 @@ class ERP5UserManager(BasePlugin): ...@@ -62,45 +75,45 @@ class ERP5UserManager(BasePlugin):
security.declarePrivate( 'authenticateCredentials' ) security.declarePrivate( 'authenticateCredentials' )
def authenticateCredentials(self, credentials): def authenticateCredentials(self, credentials):
""" See IAuthenticationPlugin. """ See IAuthenticationPlugin.
o We expect the credentials to be those returned by o We expect the credentials to be those returned by
ILoginPasswordExtractionPlugin. ILoginPasswordExtractionPlugin.
""" """
def _authenticateCredentials(login, password, path): def _authenticateCredentials(login, password, path):
if login is None or password is None: if login is None or password is None:
return None return None
user_list = self.getUserByLogin(login) user_list = self.getUserByLogin(login)
if not user_list: if not user_list:
return None return None
user = user_list[0] user = user_list[0]
if user.getPassword() == password: if user.getPassword() == password:
LOG('authenticateCredentials', 0, user.getId()) LOG('authenticateCredentials', 0, user.getId())
return user.getId(), login return user.getId(), login
return None return None
_authenticateCredentials = CachingMethod(_authenticateCredentials, id='ERP5UserManager_authenticateCredentials') _authenticateCredentials = CachingMethod(_authenticateCredentials, id='ERP5UserManager_authenticateCredentials')
return _authenticateCredentials(login=credentials.get('login'), password=credentials.get('password'), path=self.getPhysicalPath()) return _authenticateCredentials(login=credentials.get('login'), password=credentials.get('password'), path=self.getPhysicalPath())
# #
# IUserEnumerationPlugin implementation # IUserEnumerationPlugin implementation
# #
security.declarePrivate( 'enumerateUsers' ) security.declarePrivate( 'enumerateUsers' )
def enumerateUsers(self, id=None, login=None, exact_match=False, sort_by=None, max_results=None, **kw): def enumerateUsers(self, id=None, login=None, exact_match=False, sort_by=None, max_results=None, **kw):
""" See IUserEnumerationPlugin. """ See IUserEnumerationPlugin.
""" """
def _enumerateUsers(t_id, path): def _enumerateUsers(t_id, path):
user_info = [] user_info = []
user_objects = [] user_objects = []
plugin_id = self.getId() plugin_id = self.getId()
if isinstance(t_id, str): if isinstance(t_id, str):
t_id = (t_id,) t_id = (t_id,)
if t_id: if t_id:
person_module = self.getPortalObject()\ person_module = self.getPortalObject()\
.getDefaultModule('Person') .getDefaultModule('Person')
...@@ -109,42 +122,42 @@ class ERP5UserManager(BasePlugin): ...@@ -109,42 +122,42 @@ class ERP5UserManager(BasePlugin):
if user: if user:
if user.getCareerRole() == 'internal': if user.getCareerRole() == 'internal':
user_objects.append(user) user_objects.append(user)
elif login: elif login:
for user in self.getUserByLogin(login): for user in self.getUserByLogin(login):
if user.getCareerRole() == 'internal': if user.getCareerRole() == 'internal':
user_objects.append(user) user_objects.append(user)
for user in user_objects: for user in user_objects:
LOG('enumerateUsers', 0, user.getId()) LOG('enumerateUsers', 0, user.getId())
info = { 'id' : user.getId() info = { 'id' : user.getId()
, 'login' : user.getReference() , 'login' : user.getReference()
, 'pluginid' : plugin_id , 'pluginid' : plugin_id
} }
user_info.append(info) user_info.append(info)
return tuple(user_info) return tuple(user_info)
_enumerateUsers = CachingMethod(_enumerateUsers, id='ERP5UserManager_enumerateUsers') _enumerateUsers = CachingMethod(_enumerateUsers, id='ERP5UserManager_enumerateUsers')
if isinstance(id, list): if isinstance(id, list):
id = tuple(id) id = tuple(id)
return _enumerateUsers(t_id=id, path=self.getPhysicalPath()) return _enumerateUsers(t_id=id, path=self.getPhysicalPath())
def getUserByLogin(self, login): def getUserByLogin(self, login):
""" """
Search the Catalog for login and return a list of person objects Search the Catalog for login and return a list of person objects
login can be a string list or a list of strings login can be a string list or a list of strings
""" """
# because we aren't logged in, we have to create our own # because we aren't logged in, we have to create our own
# SecurityManager to be able to access the Catalog # SecurityManager to be able to access the Catalog
newSecurityManager(self, self.getPortalObject().portal_catalog.getOwner()) newSecurityManager(self, self.getPortalObject().portal_catalog.getOwner())
result = self.getPortalObject().portal_catalog(portal_type="Person", reference=login) result = self.getPortalObject().portal_catalog(portal_type="Person", reference=login)
return [item.getObject() for item in result] return [item.getObject() for item in result]
classImplements( ERP5UserManager classImplements( ERP5UserManager
, IAuthenticationPlugin , IAuthenticationPlugin
, IUserEnumerationPlugin , IUserEnumerationPlugin
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights # Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
# Reserved. # Klaus Wlfel <k.woelfel_AT_gmx_DOT_de>
# #
# This software is subject to the provisions of the Zope Public License, # WARNING: This program as such is intended to be used by professional
# Version 2.1 (ZPL). A copy of the ZPL should accompany this # programmers who take the whole responsability of assessing all potential
# distribution. # consequences resulting from its eventual inadequacies and bugs
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # End users who are looking for a ready-to-use solution with commercial
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # garantees and support are strongly adviced to contract a Free Software
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # Service Company
# FOR A PARTICULAR PURPOSE. #
# 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.
# #
############################################################################## ##############################################################################
""" ERP5Security product initialization. """ ERP5Security product initialization.
...@@ -32,7 +45,7 @@ def initialize(context): ...@@ -32,7 +45,7 @@ def initialize(context):
context.registerClass( ERP5UserManager.ERP5UserManager context.registerClass( ERP5UserManager.ERP5UserManager
, permission=ManageUsers , permission=ManageUsers
, constructors=( , constructors=(
ERP5UserManager.manage_addERP5UserManagerForm, ERP5UserManager.manage_addERP5UserManagerForm,
ERP5UserManager.addERP5UserManager, ) ERP5UserManager.addERP5UserManager, )
, visibility=None , visibility=None
, icon='www/portal.gif' , icon='www/portal.gif'
...@@ -41,7 +54,7 @@ def initialize(context): ...@@ -41,7 +54,7 @@ def initialize(context):
context.registerClass( ERP5GroupManager.ERP5GroupManager context.registerClass( ERP5GroupManager.ERP5GroupManager
, permission=ManageGroups , permission=ManageGroups
, constructors=( , constructors=(
ERP5GroupManager.manage_addERP5GroupManagerForm, ERP5GroupManager.manage_addERP5GroupManagerForm,
ERP5GroupManager.addERP5GroupManager, ) ERP5GroupManager.addERP5GroupManager, )
, visibility=None , visibility=None
, icon='www/portal.gif' , icon='www/portal.gif'
......
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