Commit 7d847d85 authored by Fabien Morin's avatar Fabien Morin

add the user management :

 - the modification (Add, Replace, Delete) on subscription are made under the 
user logged in zope at the begening of the synchro.
 - the modification on publication are made under the user send by the 
subscriber (the login and password fields in subscription).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15665 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e7109b00
......@@ -999,6 +999,18 @@ class Subscription(Folder, SyncCode):
"""
self.password = new_password
def getZopeUser(self):
"""
This method return the zope user who begin the synchronization session
"""
return getattr(self, 'zope_user_name', None)
def setZopeUser(self, user_name):
"""
This method set the zope user_name
"""
self.zope_user_name = user_name
def getAuthenticationFormat(self):
"""
return the format of authentication
......@@ -1052,6 +1064,9 @@ class Subscription(Folder, SyncCode):
This tries to get the object with the given gid
This uses the query if it exist
"""
#if len(gid)%2 != 0:
#something encode in base 16 is always a even number of number
# return None
signature = self.getSignatureFromGid(gid)
# First look if we do already have the mapping between
# the id and the gid
......
......@@ -44,6 +44,13 @@ class SubscriptionSynchronization(XMLSyncUtils):
cmd_id = 1 # specifies a SyncML message-unique command identifier
subscription.NewAnchor()
subscription.initLastMessageId()
#save the actual user to use it in all the session:
user = self.portal_membership.getAuthenticatedMember().getUserName()
LOG('SubSyncInit, user saved :',DEBUG, user)
subscription.setZopeUser(user)
subscription.setAuthenticated(True)
xml_list = []
xml = xml_list.append
xml('<SyncML>\n')
......
......@@ -984,6 +984,9 @@ class SynchronizationTool( SubscriptionSynchronization,
LOG('sync, message_list:', DEBUG, message_list)
if len(message_list) == 0:
for subscription in self.getSubscriptionList():
user = subscription.getZopeUser()
LOG('sync, user :',DEBUG, user)
newSecurityManager(None, user)
LOG('sync, type(subcription):', DEBUG, type(subscription))
self.activate(activity='RAMQueue').SubSync(subscription.getPath())
......@@ -1001,6 +1004,7 @@ class SynchronizationTool( SubscriptionSynchronization,
# the id sync_id, this is not so good, but there is no way yet
# to know if we will call a publication or subscription XXX
gpg_key = ''
LOG('readResponse, sync_id :', DEBUG, sync_id)
for publication in self.getPublicationList():
if publication.getTitle() == sync_id:
gpg_key = publication.getGPGKey()
......@@ -1010,6 +1014,9 @@ class SynchronizationTool( SubscriptionSynchronization,
if subscription.getTitle() == sync_id:
gpg_key = subscription.getGPGKey()
domain = subscription
user = domain.getZopeUser()
LOG('readResponse, user :', DEBUG, user)
newSecurityManager(None, user)
# decrypt the message if needed
if gpg_key not in (None,''):
filename = str(random.randrange(1, 2147483600)) + '.txt'
......
......@@ -1241,6 +1241,7 @@ class XMLSyncUtilsMixin(SyncCode):
elif status_code in (self.SUCCESS, self.ITEM_ADDED):
signature.setStatus(self.SYNCHRONIZED)
elif status_cmd == 'Delete':
has_status_list = 1
if status_code == self.SUCCESS:
signature = subscriber.getSignatureFromGid(object_gid) or \
subscriber.getSignatureFromRid(object_gid)
......@@ -1494,11 +1495,14 @@ class XMLSyncUtils(XMLSyncUtilsMixin):
xml=xml_a,
domain=domain,
content_type=domain.getSyncContentType())
if syncml_data == '':
LOG('this is the end of the synchronisation session !!!', DEBUG, '')
subscriber.setAuthenticated(False)
domain.setAuthenticated(False)
has_response = 1
elif domain.domain_type == self.SUB:
if self.checkAlert(remote_xml) or \
(xml_confirmation,syncml_data) != ('','') or \
has_status_list:
(xml_confirmation,syncml_data) != ('',''):
subscriber.setLastSentMessage(xml_a)
self.sendResponse(
from_url=domain.subscription_url,
......@@ -1507,6 +1511,9 @@ class XMLSyncUtils(XMLSyncUtilsMixin):
xml=xml_a,domain=domain,
content_type=domain.getSyncContentType())
has_response = 1
else:
LOG('this is the end of the synchronisation session !!!', DEBUG, '')
domain.setAuthenticated(False)
return {'has_response':has_response,'xml':xml_a}
def xml2wbxml(self, xml):
......
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