summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/keymanager/keys.py
diff options
context:
space:
mode:
authorNavaL <ayoyo@thoughtworks.com>2016-11-29 15:42:28 +0100
committerRuben Pollan <meskio@sindominio.net>2017-12-03 20:43:32 +0100
commit6b5c2e802eef35f1752713d353d3001f43980841 (patch)
treeb7e246c54c221b22f4f726ae031f2c70fe55d1bc /src/leap/bitmask/keymanager/keys.py
parentb7cf7b976fc7e2d857e19ad0dde4681c8c7a8b71 (diff)
[bug] key can tell if it should be renewed
Diffstat (limited to 'src/leap/bitmask/keymanager/keys.py')
-rw-r--r--src/leap/bitmask/keymanager/keys.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/leap/bitmask/keymanager/keys.py b/src/leap/bitmask/keymanager/keys.py
index d26f8b31..1e8d383f 100644
--- a/src/leap/bitmask/keymanager/keys.py
+++ b/src/leap/bitmask/keymanager/keys.py
@@ -30,6 +30,9 @@ from leap.bitmask.keymanager.wrapper import TempGPGWrapper
from leap.bitmask.keymanager.validation import ValidationLevels
from leap.bitmask.keymanager import documents as doc
+TWO_MONTHS = 60
+DEFAULT_THRESHOLD = TWO_MONTHS
+
log = Logger()
@@ -288,9 +291,6 @@ class OpenPGPKey(object):
value = str(value)
return key, value
- def has_expired(self):
- return self.expiry_date and self.expiry_date < datetime.now()
-
def __iter__(self):
return self
@@ -327,6 +327,22 @@ class OpenPGPKey(object):
return False if self.expiry_date is None \
else self.expiry_date < datetime.now()
+ def should_be_renewed(self, before_expiry_threshold=DEFAULT_THRESHOLD):
+ """
+ Indicates if the key reaches the renewal period. For ease of transition
+ keys should be renewed before they expire.
+
+ :param before_expiry_threshold: the amount of days before expiry date
+ whereby the key should be renewed -- default value is 60 days
+ :type before_expiry_threshold: int
+
+ :return: True if the current date is within the threshold
+ :rtype: Boolean
+ """
+
+ days_till_expiry = (self.expiry_date - datetime.now())
+ return days_till_expiry.days < before_expiry_threshold
+
def parse_address(address):
"""