Example #1
0
 def getAssociation(self, server_url, handle=None):
     assocs = []
     if handle is not None:
         assocs = Association.objects.filter(
             server_url = server_url, handle = handle
         )
     else:
         assocs = Association.objects.filter(
             server_url = server_url
         )
     if not assocs:
         return None
     associations = []
     for assoc in assocs:
         association = OIDAssociation(
             assoc.handle, base64.decodestring(assoc.secret), assoc.issued,
             assoc.lifetime, assoc.assoc_type
         )
         if association.getExpiresIn() == 0:
             self.removeAssociation(server_url, assoc.handle)
         else:
             associations.append((association.issued, association))
     if not associations:
         return None
     return associations[-1][1]
Example #2
0
    def txn_getAssociation(self, server_url, handle=None):
        """Get the most recent association that has been set for this
        server URL and handle.

        str -> NoneType or Association
        """
        if handle is not None:
            self.db_get_assoc(server_url, handle)
        else:
            self.db_get_assocs(server_url)

        rows = self.cur.fetchall()
        if len(rows) == 0:
            return None
        else:
            associations = []
            for values in rows:
                assoc = Association(*values)
                assoc.secret = self.blobDecode(assoc.secret)
                if assoc.getExpiresIn() == 0:
                    self.txn_removeAssociation(server_url, assoc.handle)
                else:
                    associations.append((assoc.issued, assoc))

            if associations:
                associations.sort()
                return associations[-1][1]
            else:
                return None
Example #3
0
    def txn_getAssociation(self, server_url, handle=None):
        """Get the most recent association that has been set for this
        server URL and handle.

        str -> NoneType or Association
        """
        if handle is not None:
            self.db_get_assoc(server_url, handle)
        else:
            self.db_get_assocs(server_url)

        rows = self.cur.fetchall()
        if len(rows) == 0:
            return None
        else:
            associations = []
            for values in rows:
                assoc = Association(*values)
                assoc.secret = self.blobDecode(assoc.secret)
                if assoc.getExpiresIn() == 0:
                    self.txn_removeAssociation(server_url, assoc.handle)
                else:
                    associations.append((assoc.issued, assoc))

            if associations:
                associations.sort()
                return associations[-1][1]
            else:
                return None
Example #4
0
 def getAssociation(self, server_url, handle=None):
     assocs = []
     if handle is not None:
         assocs = Association.objects.filter(server_url=server_url,
                                             handle=handle)
     else:
         assocs = Association.objects.filter(server_url=server_url)
     if not assocs:
         return None
     associations = []
     for assoc in assocs:
         association = OIDAssociation(assoc.handle,
                                      base64.decodestring(assoc.secret),
                                      assoc.issued, assoc.lifetime,
                                      assoc.assoc_type)
         if association.getExpiresIn() == 0:
             self.removeAssociation(server_url, assoc.handle)
         else:
             associations.append((association.issued, association))
     if not associations:
         return None
     return associations[-1][1]