Commit 8821800f authored by Enrico Zini's avatar Enrico Zini
Browse files

Removed unused keyring.models.UserKey

parent 93716ca4
......@@ -523,71 +523,6 @@ class KeycheckUidResult(object):
self.sigs_bad.append(sig)
class UserKey(object):
"""
Manage a temporary keyring use to work with the key of a user that is not
in any of the main keyrings.
"""
def __init__(self, fpr):
"""
Create/access a temporary keyring dir for the given fingerprint.
IMPORTANT: make sure that fpr is validated to a sequence of A-Fa-f0-9, as
it will be passed to os.path.join unchecked
"""
self.fpr = fpr
self.pathname = os.path.join(KEYRINGS_TMPDIR, fpr)
require_dir(self.pathname, mode=0o770)
self.gpg = GPG(homedir=self.pathname)
self.keyring = os.path.join(self.pathname, "user.gpg")
def has_key(self):
"""
Check if we already have the key
"""
return self.gpg.has_key(self.keyring, self.fpr)
def refresh(self):
"""
Fetch/refresh the key
"""
self.gpg.fetch_key(self.fpr, self.keyring)
def want_key(self):
"""
Make sure that we have the key, no matter how old
"""
if not self.has_key():
self.refresh()
def getmtime(self):
"""
Return the modification time of the keyring. This can be used to check
how fresh is the key.
Returns 0 if the file is not there.
"""
try:
return os.path.getmtime(self.keyring)
except OSError as e:
import errno
if e.errno == errno.ENOENT:
return 0
raise
def encrypt(self, data):
"""
Encrypt the given data with this key, returning the ascii-armored
encrypted result.
"""
cmd = self.gpg.keyring_cmd(self.keyring, "--encrypt", "--armor", "--no-default-recipient",
"--trust-model=always", "--recipient", self.fpr)
stdout, stderr, result = self.gpg.run_cmd(cmd, input=data)
if result != 0:
raise RuntimeError("gpg exited with status %d: %s" % (result, stderr.strip()))
return stdout
class Changelog(object):
re_date = re.compile("^\d+-\d+-\d+$")
re_datetime = re.compile("^\d+-\d+-\d+ \d+:\d+:\d+$")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment