diff --git a/product/ERP5SyncML/Conduit/VCardConduit.py b/product/ERP5SyncML/Conduit/VCardConduit.py index 059476433717a56f9d6c91cab26ac4f3bb30fab1..913a145e22ca6fb13a0081cbaeca40bafff302ca 100755 --- a/product/ERP5SyncML/Conduit/VCardConduit.py +++ b/product/ERP5SyncML/Conduit/VCardConduit.py @@ -140,10 +140,13 @@ class VCardConduit(ERP5Conduit, SyncCode): """ vcard_dict = self.vcard2Dict(vcard) gid_from_vcard = [] - gid_from_vcard.append(vcard_dict['first_name']) - gid_from_vcard.append(' ') - gid_from_vcard.append(vcard_dict['last_name']) + if vcard_dict.has_key('first_name'): + gid_from_vcard.append(vcard_dict['first_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) + LOG('gid_from_vcard', 0, gid_from_vcard) return gid_from_vcard def changePropertyEncoding(self, property_parameters_list, diff --git a/product/ERP5SyncML/Publication.py b/product/ERP5SyncML/Publication.py index 3f034f875341d06f56d1731f0dc8a2aff0155808..62646f46ea9d8ec5001250469a071abdd4a5df05 100644 --- a/product/ERP5SyncML/Publication.py +++ b/product/ERP5SyncML/Publication.py @@ -144,7 +144,7 @@ class Publication(Subscription): # Constructor def __init__(self, id, title, publication_url, destination_path, 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, sync_content_type): """ @@ -165,7 +165,6 @@ class Publication(Subscription): self.setConduit(conduit) Folder.__init__(self, id) self.title = title - self.auth_required = auth_required self.authentication_format = authentication_format self.authentication_type = authentication_type self.setSyncContentType(sync_content_type) @@ -190,18 +189,6 @@ class Publication(Subscription): """ 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): """ return the format of authentication diff --git a/product/ERP5SyncML/PublicationSynchronization.py b/product/ERP5SyncML/PublicationSynchronization.py index 2d68b352c65cd246ef7704b3f20f7b1cf66e229b..be5c0486c6bc53e6e1ab1941d8d5fb8c0c21561c 100644 --- a/product/ERP5SyncML/PublicationSynchronization.py +++ b/product/ERP5SyncML/PublicationSynchronization.py @@ -110,78 +110,66 @@ class PublicationSynchronization(XMLSyncUtils): xml(' <SyncBody>\n') - if publication.isAuthenticationRequired(): - #at the begining, the code is initialised at UNAUTHORIZED - auth_code=self.UNAUTHORIZED - LOG('PubSyncInit', INFO, 'authentication required') - if not cred: - auth_code=self.AUTH_REQUIRED - LOG("PubSyncInit there's no credential !!!", INFO,'') - # Prepare the xml message for the Sync initialization package + #at the begining, the code is initialised at UNAUTHORIZED + auth_code=self.UNAUTHORIZED + if not cred: + auth_code=self.AUTH_REQUIRED + LOG("PubSyncInit there's no credential !!!", INFO,'') + # Prepare the xml message for the Sync initialization package + xml(self.SyncMLChal(cmd_id, "SyncHdr", + 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", 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_status, cmd_id = self.SyncMLStatus(xml_client, + self.AUTH_REQUIRED, 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", - 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 subscriber.startSynchronization() @@ -253,12 +241,11 @@ class PublicationSynchronization(XMLSyncUtils): #we log the user authenticated to do the synchronization with him if self.checkMap(xml_client) : self.setRidWithMap(xml_client, subscriber) - if publication.isAuthenticationRequired(): - if subscriber.isAuthenticated(): - uf = self.getPortalObject().acl_users - user = uf.getUserById(subscriber.getUser()).__of__(uf) - newSecurityManager(None, user) - result = self.PubSyncModif(publication, xml_client) + if subscriber.isAuthenticated(): + uf = self.getPortalObject().acl_users + user = uf.getUserById(subscriber.getUser()).__of__(uf) + newSecurityManager(None, user) + result = self.PubSyncModif(publication, xml_client) else: result = self.PubSyncModif(publication, xml_client) elif subscriber is not None: diff --git a/product/ERP5SyncML/Subscription.py b/product/ERP5SyncML/Subscription.py index 20615f721b5575c2a0b0ba4be703b404a73d27a1..9e5cfc5f71e77c6ab2fd90fc6bdd2052e10007f9 100644 --- a/product/ERP5SyncML/Subscription.py +++ b/product/ERP5SyncML/Subscription.py @@ -999,12 +999,6 @@ class Subscription(Folder, SyncCode): """ self.password = new_password - def setAuthentication(self, auth): - """ - set the value of the authentication requirement - """ - self.auth_required = auth - def getAuthenticationFormat(self): """ return the format of authentication diff --git a/product/ERP5SyncML/SynchronizationTool.py b/product/ERP5SyncML/SynchronizationTool.py index a376be15d17194bb1f31d02abd4832acc7456bb2..c378961ddea2d77ac443b07925a27150e783483d 100644 --- a/product/ERP5SyncML/SynchronizationTool.py +++ b/product/ERP5SyncML/SynchronizationTool.py @@ -179,7 +179,7 @@ class SynchronizationTool( SubscriptionSynchronization, destination_path, source_uri, query, xml_mapping, conduit, gpg_key, 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, sync_content_type='application/vnd.syncml+xml', synchronize_with_erp5_sites=True): @@ -194,7 +194,7 @@ class SynchronizationTool( SubscriptionSynchronization, pub = Publication(new_id, title, publication_url, destination_path, source_uri, query, xml_mapping, conduit, gpg_key, synchronization_id_generator, - gid_generator, media_type, auth_required, + gid_generator, media_type, authentication_format, authentication_type, activity_enabled, synchronize_with_erp5_sites, sync_content_type) @@ -243,7 +243,7 @@ class SynchronizationTool( SubscriptionSynchronization, def manage_editPublication(self, title, publication_url, destination_path, source_uri, query, xml_mapping, conduit, gpg_key, synchronization_id_generator, - gid_generator, media_type=None, auth_required=0, + gid_generator, media_type=None, authentication_format='', authentication_type='', RESPONSE=None, activity_enabled=False, sync_content_type='application/vnd.syncml+xml', @@ -264,7 +264,6 @@ class SynchronizationTool( SubscriptionSynchronization, pub.setSynchronizationIdGenerator(synchronization_id_generator) pub.setGidGenerator(gid_generator) pub.setMediaType(media_type) - pub.setAuthentication(auth_required) pub.setAuthenticationFormat(authentication_format) pub.setAuthenticationType(authentication_type) pub.setSyncContentType(sync_content_type) diff --git a/product/ERP5SyncML/dtml/explainSynchronizationTool.dtml b/product/ERP5SyncML/dtml/explainSynchronizationTool.dtml index 4d75aa2b2a9d232222322774f78e6d0cdc820ea6..1dc4b2031795e302b7cf72e71a46a9554ccc9296 100644 --- a/product/ERP5SyncML/dtml/explainSynchronizationTool.dtml +++ b/product/ERP5SyncML/dtml/explainSynchronizationTool.dtml @@ -100,7 +100,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. find a gid from any object</br> <b>Media Type :</b> the type of media exchanged between publication and subscription.</br> - <b>Authentication Required :</b> ask authentication to the clients</br> <b>Authentication Format :</b>the format used to encode the login and password</br> <b>Autentication Type :</b> the type of the authentication</br> diff --git a/product/ERP5SyncML/dtml/managePublications.dtml b/product/ERP5SyncML/dtml/managePublications.dtml index 124b9990908a5c861ac7a4c44887b73a146cbf89..c5616725f71c61ef5c6f2821970d475b3e39e928 100644 --- a/product/ERP5SyncML/dtml/managePublications.dtml +++ b/product/ERP5SyncML/dtml/managePublications.dtml @@ -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" /> </td> </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> <td align="left" valign="top"> <div class="form-label"> diff --git a/product/ERP5SyncML/dtml/manage_addPublication.dtml b/product/ERP5SyncML/dtml/manage_addPublication.dtml index cf30f0ca4decffef87a2dc6a80378f555972d48b..b40cb6b6ccb74f898f4a2078b125eca09cc66510 100644 --- a/product/ERP5SyncML/dtml/manage_addPublication.dtml +++ b/product/ERP5SyncML/dtml/manage_addPublication.dtml @@ -173,17 +173,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. <input type="text" name="media_type" size="40" /> </td> </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> <td align="left" valign="top"> <div class="form-label"> diff --git a/product/ERP5SyncML/tests/testERP5SyncML.py b/product/ERP5SyncML/tests/testERP5SyncML.py index 0d4313e2b6fe749daa67de88820130af463cebea..d549746adeff5aa6a5c760504cc00198500d1b1f 100644 --- a/product/ERP5SyncML/tests/testERP5SyncML.py +++ b/product/ERP5SyncML/tests/testERP5SyncML.py @@ -85,7 +85,7 @@ class TestERP5SyncMLMixin: nb_subscription = 2 nb_publication = 1 nb_synchronization = 3 - nb_message_first_synchronization = 6 + nb_message_first_synchronization = 8 subscription_url1 = 'file://tmp/sync_client1' subscription_url2 = 'file://tmp/sync_client2' publication_url = 'file://tmp/sync_server' @@ -347,7 +347,9 @@ class TestERP5SyncML(TestERP5SyncMLMixin, ERP5TypeTestCase): conduit='ERP5Conduit', gpg_key='', gid_generator='getId', - activity_enabled=False) + activity_enabled=False, + authentication_format='b64', + authentication_type='syncml:auth-basic') pub = portal_sync.getPublication(self.pub_id) self.failUnless(pub is not None) @@ -369,7 +371,9 @@ class TestERP5SyncML(TestERP5SyncMLMixin, ERP5TypeTestCase): conduit='ERP5Conduit', gpg_key='', gid_generator='getId', - activity_enabled=False) + activity_enabled=False, + login='fab', + password='myPassword') sub = portal_sync.getSubscription(self.sub_id1) self.failUnless(sub is not None) @@ -391,7 +395,9 @@ class TestERP5SyncML(TestERP5SyncMLMixin, ERP5TypeTestCase): conduit='ERP5Conduit', gpg_key='', gid_generator='getId', - activity_enabled=False) + activity_enabled=False, + login='fab', + password='myPassword') sub = portal_sync.getSubscription(self.sub_id2) self.failUnless(sub is not None) @@ -1338,7 +1344,9 @@ class TestERP5SyncML(TestERP5SyncMLMixin, ERP5TypeTestCase): gpg_key='', gid_generator='getId', 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) self.assertTrue(sub.isOneWayFromServer()) self.failUnless(sub is not None) @@ -1458,7 +1466,6 @@ wuIFtde33Dp3NkZl9fc2Rmw6fDp8OnX2RmX19fJibDqV1dXcKwwrDCsMKwwrDCsA==' """ portal_sync = self.getSynchronizationTool() pub = portal_sync.getPublication(publication_id) - pub.setAuthentication(True) pub.setLogin(login) pub.setPassword(password) pub.setAuthenticationFormat(auth_format) @@ -1472,7 +1479,6 @@ wuIFtde33Dp3NkZl9fc2Rmw6fDp8OnX2RmX19fJibDqV1dXcKwwrDCsMKwwrDCsA==' """ portal_sync = self.getSynchronizationTool() sub = portal_sync.getSubscription(subscription_id) - sub.setAuthentication(True) sub.setAuthenticated(False) sub.setLogin(login) sub.setPassword(password) @@ -1517,7 +1523,9 @@ wuIFtde33Dp3NkZl9fc2Rmw6fDp8OnX2RmX19fJibDqV1dXcKwwrDCsMKwwrDCsA==' #adding authentication : self.addAuthenticationToPublication(self.pub_id, 'fab', 'myPassword', 'b64', '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 kw = {'first_name':self.first_name2,'last_name':self.last_name2} person1_c.edit(**kw)