'Convert an association to KV form.
@return: String in KV form suitable for deserialization by
deserialize.
@rtype: str'

def serialize(self):

    data = {'version': '2', 'handle': self.handle, 'secret': oidutil.toBase64(self.secret), 'issued': str(int(self.issued)), 'lifetime': str(int(self.lifetime)), 'assoc_type': self.assoc_type}
    assert (len(data) == len(self.assoc_keys))
    pairs = []
    for field_name in self.assoc_keys:
        pairs.append((field_name, data[field_name]))
    return kvform.seqToKV(pairs, strict=True)
