Revize 9c704fb1
Přidáno uživatelem Jan Pašek před asi 4 roky(ů)
src/services/certificate_service.py | ||
---|---|---|
279 | 279 |
if reason not in CERTIFICATE_REVOCATION_REASONS: |
280 | 280 |
raise RevocationReasonInvalidException(reason) |
281 | 281 |
|
282 |
updated = False |
|
282 | 283 |
if status == STATUS_VALID: |
283 |
self.certificate_repository.clear_certificate_revocation(id) |
|
284 |
updated = self.certificate_repository.clear_certificate_revocation(id)
|
|
284 | 285 |
elif status == STATUS_REVOKED: |
285 | 286 |
revocation_timestamp = int(time.time()) |
286 |
self.certificate_repository.set_certificate_revoked(id, str(revocation_timestamp), reason) |
|
287 |
updated = self.certificate_repository.set_certificate_revoked(id, str(revocation_timestamp), reason) |
|
288 |
|
|
289 |
if not updated: |
|
290 |
raise CertificateNotFoundException(id) |
|
287 | 291 |
|
288 | 292 |
def get_subject_from_certificate(self, certificate: Certificate) -> Subject: |
289 | 293 |
""" |
... | ... | |
348 | 352 |
|
349 | 353 |
def __str__(self): |
350 | 354 |
return f"Certificate status '{self.status}' is not valid." |
355 |
|
|
356 |
|
|
357 |
class CertificateNotFoundException(Exception): |
|
358 |
""" |
|
359 |
Exception that denotes that the caller was trying to set |
|
360 |
a certificate to an invalid state |
|
361 |
""" |
|
362 |
|
|
363 |
def __init__(self, id): |
|
364 |
self.id = id |
|
365 |
|
|
366 |
def __str__(self): |
|
367 |
return f"Certificate id '{self.id}' does not exist." |
Také k dispozici: Unified diff
Re #8571 - RestAPI testing