diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2016-05-04 17:50:06 -0400 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2016-05-04 17:50:06 -0400 |
commit | 62b6802c2924abee56cc4620415dd6fc3d302040 (patch) | |
tree | dd27319727a9cce3731dbf6c11cd9a4f058fec46 /keymanager | |
parent | 99352eb18acac2c3b1c73c2d79d42421f26ca834 (diff) | |
parent | fc8bc28ffa85f7393fe1741a08618817c6e0f315 (diff) |
Merge branch 'develop' into release/0.5.1
Diffstat (limited to 'keymanager')
-rw-r--r-- | keymanager/MANIFEST.in | 2 | ||||
-rw-r--r-- | keymanager/changes/bug-serializable-keys | 1 | ||||
-rw-r--r-- | keymanager/src/leap/keymanager/keys.py | 27 |
3 files changed, 29 insertions, 1 deletions
diff --git a/keymanager/MANIFEST.in b/keymanager/MANIFEST.in index d1a0e9a..8a66511 100644 --- a/keymanager/MANIFEST.in +++ b/keymanager/MANIFEST.in @@ -1,5 +1,5 @@ include pkg/* include versioneer.py include LICENSE -include CHANGELOG +include CHANGELOG.rst include src/leap/keymanager/_version.py diff --git a/keymanager/changes/bug-serializable-keys b/keymanager/changes/bug-serializable-keys new file mode 100644 index 0000000..0885fd2 --- /dev/null +++ b/keymanager/changes/bug-serializable-keys @@ -0,0 +1 @@ +- encryption keys can now be serialized to json using key.get_dict() diff --git a/keymanager/src/leap/keymanager/keys.py b/keymanager/src/leap/keymanager/keys.py index 38d66b5..1955d54 100644 --- a/keymanager/src/leap/keymanager/keys.py +++ b/keymanager/src/leap/keymanager/keys.py @@ -192,6 +192,11 @@ class EncryptionKey(object): __metaclass__ = ABCMeta + __slots__ = ('address', 'uids', 'fingerprint', 'key_data', + 'private', 'length', 'expiry_date', 'validation', + 'last_audited_at', 'refreshed_at', + 'encr_used', 'sign_used', '_index') + def __init__(self, address=None, uids=[], fingerprint="", key_data="", private=False, length=0, expiry_date=None, validation=ValidationLevels.Weak_Chain, last_audited_at=None, @@ -212,6 +217,7 @@ class EncryptionKey(object): self.refreshed_at = refreshed_at self.encr_used = encr_used self.sign_used = sign_used + self._index = len(self.__slots__) def get_json(self): """ @@ -258,6 +264,27 @@ class EncryptionKey(object): KEY_TAGS_KEY: [KEYMANAGER_ACTIVE_TAG], }) + def next(self): + if self._index == 0: + self._index = len(self.__slots__) + raise StopIteration + + self._index -= 1 + key = self.__slots__[self._index] + + if key.startswith('_'): + return self.next() + + value = getattr(self, key) + if key == "validation": + value = str(value) + elif key in ["expiry_date", "last_audited_at", "refreshed_at"]: + value = str(value) + return key, value + + def __iter__(self): + return self + def __repr__(self): """ Representation of this class |