[Erp5-report] r15621 - in /erp5/trunk/products/ERP5SyncML: ./ Conduit/ dtml/ tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Aug 13 11:15:31 CEST 2007


Author: fabien
Date: Mon Aug 13 11:15:30 2007
New Revision: 15621

URL: http://svn.erp5.org?rev=15621&view=rev
Log:
remove the field "authentication required", now authentication is always require
d

Modified:
    erp5/trunk/products/ERP5SyncML/Conduit/VCardConduit.py
    erp5/trunk/products/ERP5SyncML/Publication.py
    erp5/trunk/products/ERP5SyncML/PublicationSynchronization.py
    erp5/trunk/products/ERP5SyncML/Subscription.py
    erp5/trunk/products/ERP5SyncML/SynchronizationTool.py
    erp5/trunk/products/ERP5SyncML/dtml/explainSynchronizationTool.dtml
    erp5/trunk/products/ERP5SyncML/dtml/managePublications.dtml
    erp5/trunk/products/ERP5SyncML/dtml/manage_addPublication.dtml
    erp5/trunk/products/ERP5SyncML/tests/testERP5SyncML.py

Modified: erp5/trunk/products/ERP5SyncML/Conduit/VCardConduit.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/Conduit/VCardConduit.py?rev=15621&r1=15620&r2=15621&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/Conduit/VCardConduit.py (original)
+++ erp5/trunk/products/ERP5SyncML/Conduit/VCardConduit.py Mon Aug 13 11:15:30 2007
@@ -140,10 +140,13 @@
     """
     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, 

Modified: erp5/trunk/products/ERP5SyncML/Publication.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/Publication.py?rev=15621&r1=15620&r2=15621&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/Publication.py (original)
+++ erp5/trunk/products/ERP5SyncML/Publication.py Mon Aug 13 11:15:30 2007
@@ -144,7 +144,7 @@
   # 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 @@
     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)
@@ -189,18 +188,6 @@
       return the 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):
     """

Modified: erp5/trunk/products/ERP5SyncML/PublicationSynchronization.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/PublicationSynchronization.py?rev=15621&r1=15620&r2=15621&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/PublicationSynchronization.py (original)
+++ erp5/trunk/products/ERP5SyncML/PublicationSynchronization.py Mon Aug 13 11:15:30 2007
@@ -110,78 +110,66 @@
       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 @@
         #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:

Modified: erp5/trunk/products/ERP5SyncML/Subscription.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/Subscription.py?rev=15621&r1=15620&r2=15621&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/Subscription.py (original)
+++ erp5/trunk/products/ERP5SyncML/Subscription.py Mon Aug 13 11:15:30 2007
@@ -999,12 +999,6 @@
     """
     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

Modified: erp5/trunk/products/ERP5SyncML/SynchronizationTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/SynchronizationTool.py?rev=15621&r1=15620&r2=15621&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/SynchronizationTool.py (original)
+++ erp5/trunk/products/ERP5SyncML/SynchronizationTool.py Mon Aug 13 11:15:30 2007
@@ -179,7 +179,7 @@
             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 @@
     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 @@
   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 @@
     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)

Modified: erp5/trunk/products/ERP5SyncML/dtml/explainSynchronizationTool.dtml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/dtml/explainSynchronizationTool.dtml?rev=15621&r1=15620&r2=15621&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/dtml/explainSynchronizationTool.dtml (original)
+++ erp5/trunk/products/ERP5SyncML/dtml/explainSynchronizationTool.dtml Mon Aug 13 11:15:30 2007
@@ -100,7 +100,6 @@
         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>

Modified: erp5/trunk/products/ERP5SyncML/dtml/managePublications.dtml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/dtml/managePublications.dtml?rev=15621&r1=15620&r2=15621&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/dtml/managePublications.dtml (original)
+++ erp5/trunk/products/ERP5SyncML/dtml/managePublications.dtml Mon Aug 13 11:15:30 2007
@@ -181,16 +181,6 @@
       <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">
         Authentication Format
         </label></div>
         </td>

Modified: erp5/trunk/products/ERP5SyncML/dtml/manage_addPublication.dtml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/dtml/manage_addPublication.dtml?rev=15621&r1=15620&r2=15621&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/dtml/manage_addPublication.dtml (original)
+++ erp5/trunk/products/ERP5SyncML/dtml/manage_addPublication.dtml Mon Aug 13 11:15:30 2007
@@ -176,17 +176,6 @@
   <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">
     Authentication Format
     </label></div>
     </td>

Modified: erp5/trunk/products/ERP5SyncML/tests/testERP5SyncML.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/tests/testERP5SyncML.py?rev=15621&r1=15620&r2=15621&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/tests/testERP5SyncML.py (original)
+++ erp5/trunk/products/ERP5SyncML/tests/testERP5SyncML.py Mon Aug 13 11:15:30 2007
@@ -85,7 +85,7 @@
   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 @@
         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 @@
         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 @@
         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 @@
         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 @@
     """
     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 @@
     """
     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 @@
     #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)




More information about the Erp5-report mailing list