Commit 64e73707 authored by Fabien Morin's avatar Fabien Morin

remove the field "authentication required", now authentication is always require

d


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15621 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0a6d8604
...@@ -140,10 +140,13 @@ class VCardConduit(ERP5Conduit, SyncCode): ...@@ -140,10 +140,13 @@ class VCardConduit(ERP5Conduit, SyncCode):
""" """
vcard_dict = self.vcard2Dict(vcard) vcard_dict = self.vcard2Dict(vcard)
gid_from_vcard = [] gid_from_vcard = []
gid_from_vcard.append(vcard_dict['first_name']) if vcard_dict.has_key('first_name'):
gid_from_vcard.append(' ') gid_from_vcard.append(vcard_dict['first_name'])
gid_from_vcard.append(vcard_dict['last_name']) gid_from_vcard.append(' ')
if vcard_dict.has_key('last_name'):
gid_from_vcard.append(vcard_dict['last_name'])
gid_from_vcard = ''.join(gid_from_vcard) gid_from_vcard = ''.join(gid_from_vcard)
LOG('gid_from_vcard', 0, gid_from_vcard)
return gid_from_vcard return gid_from_vcard
def changePropertyEncoding(self, property_parameters_list, def changePropertyEncoding(self, property_parameters_list,
......
...@@ -144,7 +144,7 @@ class Publication(Subscription): ...@@ -144,7 +144,7 @@ class Publication(Subscription):
# Constructor # Constructor
def __init__(self, id, title, publication_url, destination_path, def __init__(self, id, title, publication_url, destination_path,
source_uri, query, xml_mapping, conduit, gpg_key, id_generator, source_uri, query, xml_mapping, conduit, gpg_key, id_generator,
gid_generator, media_type, auth_required, authentication_format, gid_generator, media_type, authentication_format,
authentication_type, activity_enabled, synchronize_with_erp5_sites, authentication_type, activity_enabled, synchronize_with_erp5_sites,
sync_content_type): sync_content_type):
""" """
...@@ -165,7 +165,6 @@ class Publication(Subscription): ...@@ -165,7 +165,6 @@ class Publication(Subscription):
self.setConduit(conduit) self.setConduit(conduit)
Folder.__init__(self, id) Folder.__init__(self, id)
self.title = title self.title = title
self.auth_required = auth_required
self.authentication_format = authentication_format self.authentication_format = authentication_format
self.authentication_type = authentication_type self.authentication_type = authentication_type
self.setSyncContentType(sync_content_type) self.setSyncContentType(sync_content_type)
...@@ -190,18 +189,6 @@ class Publication(Subscription): ...@@ -190,18 +189,6 @@ class Publication(Subscription):
""" """
self.publication_url = publication_url self.publication_url = publication_url
def isAuthenticationRequired(self):
"""
return False if authentication not required, True else
"""
return getattr(self, 'auth_required', False)
def setAuthentication(self, auth):
"""
set the value of the authentication requirement
"""
self.auth_required = auth
def getAuthenticationFormat(self): def getAuthenticationFormat(self):
""" """
return the format of authentication return the format of authentication
......
...@@ -110,78 +110,66 @@ class PublicationSynchronization(XMLSyncUtils): ...@@ -110,78 +110,66 @@ class PublicationSynchronization(XMLSyncUtils):
xml(' <SyncBody>\n') xml(' <SyncBody>\n')
if publication.isAuthenticationRequired(): #at the begining, the code is initialised at UNAUTHORIZED
#at the begining, the code is initialised at UNAUTHORIZED auth_code=self.UNAUTHORIZED
auth_code=self.UNAUTHORIZED if not cred:
LOG('PubSyncInit', INFO, 'authentication required') auth_code=self.AUTH_REQUIRED
if not cred: LOG("PubSyncInit there's no credential !!!", INFO,'')
auth_code=self.AUTH_REQUIRED # Prepare the xml message for the Sync initialization package
LOG("PubSyncInit there's no credential !!!", INFO,'') xml(self.SyncMLChal(cmd_id, "SyncHdr",
# Prepare the xml message for the Sync initialization package publication.getPublicationUrl(), subscriber.getSubscriptionUrl(),
publication.getAuthenticationFormat(),
publication.getAuthenticationType(), auth_code))
cmd_id += 1
# chal message
xml_status, cmd_id = self.SyncMLStatus(xml_client, auth_code,
cmd_id, next_anchor, subscription=subscriber).values()
xml(xml_status)
else:
(authentication_format, authentication_type, data) = \
self.getCred(xml_client)
if authentication_type == publication.getAuthenticationType():
authentication_format = publication.getAuthenticationFormat()
decoded = subscriber.decode(authentication_format, data)
if decoded not in ('', None) and ':' in decoded:
(login, password) = decoded.split(':')
uf = self.getPortalObject().acl_users
for plugin_name, plugin in uf._getOb('plugins').listPlugins(
IAuthenticationPlugin ):
if plugin.authenticateCredentials(
{'login':login, 'password':password}) is not None:
subscriber.setAuthenticated(True)
auth_code=self.AUTH_ACCEPTED
#here we must log in with the user authenticated :
user = uf.getUserById(login).__of__(uf)
newSecurityManager(None, user)
subscriber.setUser(login)
break
else:
auth_code=self.UNAUTHORIZED
#in all others cases, the auth_code is set to UNAUTHORIZED
# Prepare the xml message for the Sync initialization package
if auth_code == self.AUTH_ACCEPTED:
xml_status, cmd_id = self.SyncMLStatus(xml_client, auth_code,
cmd_id, next_anchor, subscription=subscriber).values()
xml(xml_status)
# alert message
xml(self.SyncMLAlert(cmd_id, sync_type, subscriber.getTargetURI(),
subscriber.getSourceURI(), subscriber.getLastAnchor(),
next_anchor))
cmd_id += 1
else:
# chal message
xml(self.SyncMLChal(cmd_id, "SyncHdr", xml(self.SyncMLChal(cmd_id, "SyncHdr",
publication.getPublicationUrl(), subscriber.getSubscriptionUrl(), publication.getPublicationUrl(), subscriber.getSubscriptionUrl(),
publication.getAuthenticationFormat(), publication.getAuthenticationFormat(),
publication.getAuthenticationType(), auth_code)) publication.getAuthenticationType(), auth_code))
cmd_id += 1 cmd_id += 1
# chal message xml_status, cmd_id = self.SyncMLStatus(xml_client,
xml_status, cmd_id = self.SyncMLStatus(xml_client, auth_code, self.AUTH_REQUIRED, cmd_id, next_anchor,
cmd_id, next_anchor, subscription=subscriber).values() subscription=subscriber).values()
xml(xml_status) xml(xml_status)
else:
(authentication_format, authentication_type, data) = \
self.getCred(xml_client)
if authentication_type == publication.getAuthenticationType():
authentication_format = publication.getAuthenticationFormat()
decoded = subscriber.decode(authentication_format, data)
if decoded not in ('', None) and ':' in decoded:
(login, password) = decoded.split(':')
uf = self.getPortalObject().acl_users
for plugin_name, plugin in uf._getOb('plugins').listPlugins(
IAuthenticationPlugin ):
if plugin.authenticateCredentials(
{'login':login, 'password':password}) is not None:
subscriber.setAuthenticated(True)
auth_code=self.AUTH_ACCEPTED
#here we must log in with the user authenticated :
user = uf.getUserById(login).__of__(uf)
newSecurityManager(None, user)
subscriber.setUser(login)
break
else:
auth_code=self.UNAUTHORIZED
#in all others cases, the auth_code is set to UNAUTHORIZED
# Prepare the xml message for the Sync initialization package
if auth_code == self.AUTH_ACCEPTED:
xml_status, cmd_id = self.SyncMLStatus(xml_client, auth_code,
cmd_id, next_anchor, subscription=subscriber).values()
xml(xml_status)
# alert message
xml(self.SyncMLAlert(cmd_id, sync_type, subscriber.getTargetURI(),
subscriber.getSourceURI(), subscriber.getLastAnchor(),
next_anchor))
cmd_id += 1
else:
# chal message
xml(self.SyncMLChal(cmd_id, "SyncHdr",
publication.getPublicationUrl(), subscriber.getSubscriptionUrl(),
publication.getAuthenticationFormat(),
publication.getAuthenticationType(), auth_code))
cmd_id += 1
xml_status, cmd_id = self.SyncMLStatus(xml_client,
self.AUTH_REQUIRED, cmd_id, next_anchor,
subscription=subscriber).values()
xml(xml_status)
elif alert is not None: #if no identification is required :
# syncml header
xml_status, cmd_id = self.SyncMLStatus(xml_client, self.AUTH_ACCEPTED,
cmd_id, next_anchor, subscription=subscriber).values()
xml(xml_status)
# alert message
xml(self.SyncMLAlert(cmd_id, sync_type, subscriber.getTargetURI(),
subscriber.getSourceURI(), subscriber.getLastAnchor(), next_anchor))
cmd_id += 1
# We have to set every object as NOT_SYNCHRONIZED # We have to set every object as NOT_SYNCHRONIZED
subscriber.startSynchronization() subscriber.startSynchronization()
...@@ -253,12 +241,11 @@ class PublicationSynchronization(XMLSyncUtils): ...@@ -253,12 +241,11 @@ class PublicationSynchronization(XMLSyncUtils):
#we log the user authenticated to do the synchronization with him #we log the user authenticated to do the synchronization with him
if self.checkMap(xml_client) : if self.checkMap(xml_client) :
self.setRidWithMap(xml_client, subscriber) self.setRidWithMap(xml_client, subscriber)
if publication.isAuthenticationRequired(): if subscriber.isAuthenticated():
if subscriber.isAuthenticated(): uf = self.getPortalObject().acl_users
uf = self.getPortalObject().acl_users user = uf.getUserById(subscriber.getUser()).__of__(uf)
user = uf.getUserById(subscriber.getUser()).__of__(uf) newSecurityManager(None, user)
newSecurityManager(None, user) result = self.PubSyncModif(publication, xml_client)
result = self.PubSyncModif(publication, xml_client)
else: else:
result = self.PubSyncModif(publication, xml_client) result = self.PubSyncModif(publication, xml_client)
elif subscriber is not None: elif subscriber is not None:
......
...@@ -999,12 +999,6 @@ class Subscription(Folder, SyncCode): ...@@ -999,12 +999,6 @@ class Subscription(Folder, SyncCode):
""" """
self.password = new_password self.password = new_password
def setAuthentication(self, auth):
"""
set the value of the authentication requirement
"""
self.auth_required = auth
def getAuthenticationFormat(self): def getAuthenticationFormat(self):
""" """
return the format of authentication return the format of authentication
......
...@@ -179,7 +179,7 @@ class SynchronizationTool( SubscriptionSynchronization, ...@@ -179,7 +179,7 @@ class SynchronizationTool( SubscriptionSynchronization,
destination_path, source_uri, query, xml_mapping, destination_path, source_uri, query, xml_mapping,
conduit, gpg_key, conduit, gpg_key,
synchronization_id_generator=None, gid_generator=None, synchronization_id_generator=None, gid_generator=None,
media_type=None, auth_required=0, authentication_format='', media_type=None, authentication_format='',
authentication_type='', RESPONSE=None, activity_enabled = False, authentication_type='', RESPONSE=None, activity_enabled = False,
sync_content_type='application/vnd.syncml+xml', sync_content_type='application/vnd.syncml+xml',
synchronize_with_erp5_sites=True): synchronize_with_erp5_sites=True):
...@@ -194,7 +194,7 @@ class SynchronizationTool( SubscriptionSynchronization, ...@@ -194,7 +194,7 @@ class SynchronizationTool( SubscriptionSynchronization,
pub = Publication(new_id, title, publication_url, pub = Publication(new_id, title, publication_url,
destination_path, source_uri, query, xml_mapping, destination_path, source_uri, query, xml_mapping,
conduit, gpg_key, synchronization_id_generator, conduit, gpg_key, synchronization_id_generator,
gid_generator, media_type, auth_required, gid_generator, media_type,
authentication_format, authentication_type, authentication_format, authentication_type,
activity_enabled, synchronize_with_erp5_sites, activity_enabled, synchronize_with_erp5_sites,
sync_content_type) sync_content_type)
...@@ -243,7 +243,7 @@ class SynchronizationTool( SubscriptionSynchronization, ...@@ -243,7 +243,7 @@ class SynchronizationTool( SubscriptionSynchronization,
def manage_editPublication(self, title, publication_url, def manage_editPublication(self, title, publication_url,
destination_path, source_uri, query, xml_mapping, destination_path, source_uri, query, xml_mapping,
conduit, gpg_key, synchronization_id_generator, conduit, gpg_key, synchronization_id_generator,
gid_generator, media_type=None, auth_required=0, gid_generator, media_type=None,
authentication_format='', authentication_type='', authentication_format='', authentication_type='',
RESPONSE=None, activity_enabled=False, RESPONSE=None, activity_enabled=False,
sync_content_type='application/vnd.syncml+xml', sync_content_type='application/vnd.syncml+xml',
...@@ -264,7 +264,6 @@ class SynchronizationTool( SubscriptionSynchronization, ...@@ -264,7 +264,6 @@ class SynchronizationTool( SubscriptionSynchronization,
pub.setSynchronizationIdGenerator(synchronization_id_generator) pub.setSynchronizationIdGenerator(synchronization_id_generator)
pub.setGidGenerator(gid_generator) pub.setGidGenerator(gid_generator)
pub.setMediaType(media_type) pub.setMediaType(media_type)
pub.setAuthentication(auth_required)
pub.setAuthenticationFormat(authentication_format) pub.setAuthenticationFormat(authentication_format)
pub.setAuthenticationType(authentication_type) pub.setAuthenticationType(authentication_type)
pub.setSyncContentType(sync_content_type) pub.setSyncContentType(sync_content_type)
......
...@@ -100,7 +100,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -100,7 +100,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
find a gid from any object</br> find a gid from any object</br>
<b>Media Type :</b> the type of media exchanged between publication <b>Media Type :</b> the type of media exchanged between publication
and subscription.</br> and subscription.</br>
<b>Authentication Required :</b> ask authentication to the clients</br>
<b>Authentication Format :</b>the format used to encode the <b>Authentication Format :</b>the format used to encode the
login and password</br> login and password</br>
<b>Autentication Type :</b> the type of the authentication</br> <b>Autentication Type :</b> the type of the authentication</br>
......
...@@ -178,16 +178,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -178,16 +178,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<input type="text" name="media_type" value="<dtml-var getMediaType>" size="40" /> <input type="text" name="media_type" value="<dtml-var getMediaType>" size="40" />
</td> </td>
</tr> </tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Authentication Required
</label></div>
</td>
<td align="left" valign="top">
<input type="checkbox" name="auth_required" value="1" <dtml-if expr="isAuthenticationRequired()">CHECKED</dtml-if>>
</td>
</tr>
<tr> <tr>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="form-label"> <div class="form-label">
......
...@@ -173,17 +173,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -173,17 +173,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<input type="text" name="media_type" size="40" /> <input type="text" name="media_type" size="40" />
</td> </td>
</tr> </tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Authentication Required
</label></div>
</td>
<td align="left" valign="top">
<input type="checkbox" name="auth_required" value="1">
</td>
</tr>
<tr>
<tr> <tr>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="form-label"> <div class="form-label">
......
...@@ -85,7 +85,7 @@ class TestERP5SyncMLMixin: ...@@ -85,7 +85,7 @@ class TestERP5SyncMLMixin:
nb_subscription = 2 nb_subscription = 2
nb_publication = 1 nb_publication = 1
nb_synchronization = 3 nb_synchronization = 3
nb_message_first_synchronization = 6 nb_message_first_synchronization = 8
subscription_url1 = 'file://tmp/sync_client1' subscription_url1 = 'file://tmp/sync_client1'
subscription_url2 = 'file://tmp/sync_client2' subscription_url2 = 'file://tmp/sync_client2'
publication_url = 'file://tmp/sync_server' publication_url = 'file://tmp/sync_server'
...@@ -347,7 +347,9 @@ class TestERP5SyncML(TestERP5SyncMLMixin, ERP5TypeTestCase): ...@@ -347,7 +347,9 @@ class TestERP5SyncML(TestERP5SyncMLMixin, ERP5TypeTestCase):
conduit='ERP5Conduit', conduit='ERP5Conduit',
gpg_key='', gpg_key='',
gid_generator='getId', gid_generator='getId',
activity_enabled=False) activity_enabled=False,
authentication_format='b64',
authentication_type='syncml:auth-basic')
pub = portal_sync.getPublication(self.pub_id) pub = portal_sync.getPublication(self.pub_id)
self.failUnless(pub is not None) self.failUnless(pub is not None)
...@@ -369,7 +371,9 @@ class TestERP5SyncML(TestERP5SyncMLMixin, ERP5TypeTestCase): ...@@ -369,7 +371,9 @@ class TestERP5SyncML(TestERP5SyncMLMixin, ERP5TypeTestCase):
conduit='ERP5Conduit', conduit='ERP5Conduit',
gpg_key='', gpg_key='',
gid_generator='getId', gid_generator='getId',
activity_enabled=False) activity_enabled=False,
login='fab',
password='myPassword')
sub = portal_sync.getSubscription(self.sub_id1) sub = portal_sync.getSubscription(self.sub_id1)
self.failUnless(sub is not None) self.failUnless(sub is not None)
...@@ -391,7 +395,9 @@ class TestERP5SyncML(TestERP5SyncMLMixin, ERP5TypeTestCase): ...@@ -391,7 +395,9 @@ class TestERP5SyncML(TestERP5SyncMLMixin, ERP5TypeTestCase):
conduit='ERP5Conduit', conduit='ERP5Conduit',
gpg_key='', gpg_key='',
gid_generator='getId', gid_generator='getId',
activity_enabled=False) activity_enabled=False,
login='fab',
password='myPassword')
sub = portal_sync.getSubscription(self.sub_id2) sub = portal_sync.getSubscription(self.sub_id2)
self.failUnless(sub is not None) self.failUnless(sub is not None)
...@@ -1338,7 +1344,9 @@ class TestERP5SyncML(TestERP5SyncMLMixin, ERP5TypeTestCase): ...@@ -1338,7 +1344,9 @@ class TestERP5SyncML(TestERP5SyncMLMixin, ERP5TypeTestCase):
gpg_key='', gpg_key='',
gid_generator='getId', gid_generator='getId',
activity_enabled=False, activity_enabled=False,
alert_code = SyncCode.ONE_WAY_FROM_SERVER) alert_code = SyncCode.ONE_WAY_FROM_SERVER,
login = 'fab',
password = 'myPassword')
sub = portal_sync.getSubscription(self.sub_id1) sub = portal_sync.getSubscription(self.sub_id1)
self.assertTrue(sub.isOneWayFromServer()) self.assertTrue(sub.isOneWayFromServer())
self.failUnless(sub is not None) self.failUnless(sub is not None)
...@@ -1458,7 +1466,6 @@ wuIFtde33Dp3NkZl9fc2Rmw6fDp8OnX2RmX19fJibDqV1dXcKwwrDCsMKwwrDCsA==' ...@@ -1458,7 +1466,6 @@ wuIFtde33Dp3NkZl9fc2Rmw6fDp8OnX2RmX19fJibDqV1dXcKwwrDCsMKwwrDCsA=='
""" """
portal_sync = self.getSynchronizationTool() portal_sync = self.getSynchronizationTool()
pub = portal_sync.getPublication(publication_id) pub = portal_sync.getPublication(publication_id)
pub.setAuthentication(True)
pub.setLogin(login) pub.setLogin(login)
pub.setPassword(password) pub.setPassword(password)
pub.setAuthenticationFormat(auth_format) pub.setAuthenticationFormat(auth_format)
...@@ -1472,7 +1479,6 @@ wuIFtde33Dp3NkZl9fc2Rmw6fDp8OnX2RmX19fJibDqV1dXcKwwrDCsMKwwrDCsA==' ...@@ -1472,7 +1479,6 @@ wuIFtde33Dp3NkZl9fc2Rmw6fDp8OnX2RmX19fJibDqV1dXcKwwrDCsMKwwrDCsA=='
""" """
portal_sync = self.getSynchronizationTool() portal_sync = self.getSynchronizationTool()
sub = portal_sync.getSubscription(subscription_id) sub = portal_sync.getSubscription(subscription_id)
sub.setAuthentication(True)
sub.setAuthenticated(False) sub.setAuthenticated(False)
sub.setLogin(login) sub.setLogin(login)
sub.setPassword(password) sub.setPassword(password)
...@@ -1517,7 +1523,9 @@ wuIFtde33Dp3NkZl9fc2Rmw6fDp8OnX2RmX19fJibDqV1dXcKwwrDCsMKwwrDCsA==' ...@@ -1517,7 +1523,9 @@ wuIFtde33Dp3NkZl9fc2Rmw6fDp8OnX2RmX19fJibDqV1dXcKwwrDCsMKwwrDCsA=='
#adding authentication : #adding authentication :
self.addAuthenticationToPublication(self.pub_id, 'fab', 'myPassword', 'b64', self.addAuthenticationToPublication(self.pub_id, 'fab', 'myPassword', 'b64',
'syncml:auth-basic') 'syncml:auth-basic')
# try to synchronize without authentication on the subscription, it self.addAuthenticationToSubscription(self.sub_id1, 'pouet', 'pouet',
'b64', 'syncml:auth-basic')
# try to synchronize with a wrong authentication on the subscription, it
# should failed # should failed
kw = {'first_name':self.first_name2,'last_name':self.last_name2} kw = {'first_name':self.first_name2,'last_name':self.last_name2}
person1_c.edit(**kw) person1_c.edit(**kw)
......
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