Revize 47e0e828
Přidáno uživatelem David Friesecký před asi 4 roky(ů)
src/impl/certificate_repository_impl.py | ||
---|---|---|
9 | 9 |
class CertificateRepositoryImpl(IRepository): |
10 | 10 |
|
11 | 11 |
def create(self, common_name: str, valid_from: str, valid_to: str, pem_data: str, |
12 |
private_key_id: int, type_id: int, usages: Dict[int, bool]) -> bool: |
|
12 |
private_key_id: int, type_id: int, parent_id: int, usages: Dict[int, bool]) -> bool:
|
|
13 | 13 |
sql = (f"INSERT INTO {TAB_CERTIFICATES} ({COL_COMMON_NAME},{COL_VALID_FROM},{COL_VALID_TO},{COL_PEM_DATA}," |
14 |
f"{COL_PRIVATE_KEY_ID},{COL_TYPE_ID})" |
|
14 |
f"{COL_PRIVATE_KEY_ID},{COL_TYPE_ID},{COL_PARENT_ID})"
|
|
15 | 15 |
f"VALUES(?,?,?,?,?,?,?)") |
16 |
result = DBManager.create(sql, [common_name, valid_from, valid_to, pem_data, private_key_id, type_id], usages) |
|
16 |
result = DBManager.create(sql, [common_name, valid_from, valid_to, pem_data, |
|
17 |
private_key_id, type_id, parent_id], usages) |
|
17 | 18 |
return result |
18 | 19 |
|
19 | 20 |
def read(self, certificate_id: int = None): |
... | ... | |
42 | 43 |
certificate_row[4], |
43 | 44 |
certificate_row[5], |
44 | 45 |
certificate_row[6], |
46 |
certificate_row[7], |
|
45 | 47 |
usage_dict)) |
46 | 48 |
|
47 | 49 |
if certificate_id is not None: |
... | ... | |
50 | 52 |
return certificates |
51 | 53 |
|
52 | 54 |
def update(self, certificate_id: int, common_name: str = None, valid_from: str = None, valid_to: str = None, |
53 |
pem_data: str = None, private_key_id: int = None, type_id: int = None, |
|
55 |
pem_data: str = None, private_key_id: int = None, type_id: int = None, parent_id: int = None,
|
|
54 | 56 |
usages: Dict[int, bool] = None) -> bool: |
55 | 57 |
updated_list = [] |
56 | 58 |
values = [] |
... | ... | |
72 | 74 |
if type_id is not None: |
73 | 75 |
updated_list.append(f"{COL_TYPE_ID} = ?") |
74 | 76 |
values.append(type_id) |
77 |
if parent_id is not None: |
|
78 |
updated_list.append(f"{COL_PARENT_ID} = ?") |
|
79 |
values.append(parent_id) |
|
75 | 80 |
|
76 | 81 |
updated_str = ", ".join(updated_list) |
77 | 82 |
sql = f"UPDATE {TAB_CERTIFICATES} SET {updated_str} WHERE {COL_ID} = ?" |
Také k dispozici: Unified diff
Re #8471 - Added FK of parent certificate