blob: 001b6b31602b57039d2e0f3e5c3e5fb84ad6c7f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
""""""
from mailman.config import config as mailman_config, config
from mailman.database.types import Enum, SAUnicode
from mailman.interfaces.action import Action
from mailman.model.mailinglist import MailingList
from public import public
from sqlalchemy import Boolean, Column, Integer
from mailman_pgp.model.base import Base
from mailman_pgp.pgp.keygen import KeyGenerator
@public
class EncryptedMailingList(Base):
__tablename__ = 'encrypted_lists'
id = Column(Integer, primary_key=True)
list_id = Column(SAUnicode, index=True)
_key_fingerprint = Column('key_fingerprint', SAUnicode)
unsigned_msg_action = Column(Enum(Action))
nonencrypted_msg_action = Column(Enum(Action))
strip_original_signature = Column(Boolean)
sign_outgoing = Column(Boolean)
def __init__(self, mlist):
super().__init__()
self.list_id = mlist.list_id
self._mlist = mlist
self._pubkey = None
self._key_generator = self._create_generator(mlist)
self._key_generator.start()
def _create_generator(self, mlist):
return KeyGenerator(mlist.list_id, mlist.fqdn_listname)
@property
def key_fingerprint(self):
if self._key_fingerprint is None:
if self._key_generator.has_key:
self._key_fingerprint = self._key_generator.key_fingerprint
else:
if not self._key_generator.is_alive():
# TODO this is not the best solution, we should lookup the
# key by mlist.fqdn_listname, if it actually got created
# and key generator didn't receive it.
self._key_generator = self._create_generator(self.mlist)
self._key_generator.start()
return self._key_fingerprint
@property
def mlist(self):
if self._mlist is not None:
return self._mlist
return mailman_config.db.query(MailingList).filter_by(
_list_id=self.list_id).first()
@property
def pubkey(self):
if self._pubkey is None:
if self._key_fingerprint is None:
return None
self._pubkey = config.gpg.export_keys(self._key_fingerprint)
return self._pubkey
|