Revize 805077f5
Přidáno uživatelem David Friesecký před asi 4 roky(ů)
src/dao/certificate_repository.py | ||
---|---|---|
18 | 18 |
self.connection = connection |
19 | 19 |
self.cursor = cursor |
20 | 20 |
|
21 |
def create(self, certificate: Certificate) -> bool:
|
|
21 |
def create(self, certificate: Certificate): |
|
22 | 22 |
""" |
23 | 23 |
Creates a certificate. |
24 | 24 |
For root certificate (CA) the parent certificate id is modified to the same id (id == parent_id). |
... | ... | |
65 | 65 |
self.connection.commit() |
66 | 66 |
except Error as e: |
67 | 67 |
print(e) |
68 |
return False
|
|
68 |
return None
|
|
69 | 69 |
|
70 |
return True
|
|
70 |
return last_id
|
|
71 | 71 |
|
72 |
def read(self, certificate_id: int) -> Certificate:
|
|
72 |
def read(self, certificate_id: int): |
|
73 | 73 |
""" |
74 | 74 |
Reads (selects) a certificate. |
75 | 75 |
|
... | ... | |
107 | 107 |
print(e) |
108 | 108 |
return None |
109 | 109 |
|
110 |
return certificate |
|
110 |
if len(certificate_row) > 0: |
|
111 |
return certificate |
|
112 |
else: |
|
113 |
return None |
|
111 | 114 |
|
112 | 115 |
def update(self, certificate_id: int, certificate: Certificate) -> bool: |
113 | 116 |
""" |
... | ... | |
137 | 140 |
certificate.pem_data, |
138 | 141 |
certificate.private_key_id, |
139 | 142 |
certificate.type_id, |
140 |
certificate.parent_id] |
|
143 |
certificate.parent_id, |
|
144 |
certificate_id] |
|
141 | 145 |
self.cursor.execute(sql, values) |
142 | 146 |
self.connection.commit() |
143 | 147 |
|
src/dao/private_key_repository.py | ||
---|---|---|
17 | 17 |
self.connection = connection |
18 | 18 |
self.cursor = cursor |
19 | 19 |
|
20 |
def create(self, private_key: PrivateKey) -> bool:
|
|
20 |
def create(self, private_key: PrivateKey): |
|
21 | 21 |
""" |
22 | 22 |
Creates a private key. |
23 | 23 |
|
... | ... | |
34 | 34 |
values = [private_key.private_key, |
35 | 35 |
private_key.password] |
36 | 36 |
self.cursor.execute(sql, values) |
37 |
last_id = self.cursor.lastrowid |
|
37 | 38 |
self.connection.commit() |
38 |
|
|
39 | 39 |
except Error as e: |
40 | 40 |
print(e) |
41 |
return False
|
|
41 |
return None
|
|
42 | 42 |
|
43 |
return True
|
|
43 |
return last_id
|
|
44 | 44 |
|
45 | 45 |
def read(self, private_key_id: int): |
46 | 46 |
""" |
... | ... | |
65 | 65 |
print(e) |
66 | 66 |
return None |
67 | 67 |
|
68 |
return private_key |
|
68 |
if len(private_key_row) > 0: |
|
69 |
return private_key |
|
70 |
else: |
|
71 |
return None |
|
69 | 72 |
|
70 | 73 |
def update(self, private_key_id: int, private_key: PrivateKey) -> bool: |
71 | 74 |
""" |
... | ... | |
83 | 86 |
f"{COL_PASSWORD} = ? " |
84 | 87 |
f"WHERE {COL_ID} = ?") |
85 | 88 |
values = [private_key.private_key, |
86 |
private_key.password] |
|
89 |
private_key.password, |
|
90 |
private_key_id] |
|
87 | 91 |
self.cursor.execute(sql, values) |
88 | 92 |
self.connection.commit() |
89 | 93 |
except Error as e: |
src/db_objects/private_key.py | ||
---|---|---|
1 | 1 |
class PrivateKey: |
2 | 2 |
def __init__(self, |
3 |
private_key_id: int, |
|
3 | 4 |
private_key: str, |
4 | 5 |
password: str): |
6 |
self.private_key = private_key_id |
|
5 | 7 |
self.private_key = private_key |
6 | 8 |
self.password = password |
Také k dispozici: Unified diff
Re #8471 - Error correction after review