Revize 9e6f791a
Přidáno uživatelem Jan Pašek před asi 4 roky(ů)
src/controllers/certificates_controller.py | ||
---|---|---|
12 | 12 |
from src.exceptions.database_exception import DatabaseException |
13 | 13 |
from src.model.subject import Subject |
14 | 14 |
from src.services.certificate_service import CertificateService, RevocationReasonInvalidException, \ |
15 |
CertificateStatusInvalidException, CertificateNotFoundException |
|
15 |
CertificateStatusInvalidException, CertificateNotFoundException, CertificateAlreadyRevokedException
|
|
16 | 16 |
# responsibility. |
17 | 17 |
from src.services.key_service import KeyService |
18 | 18 |
|
... | ... | |
35 | 35 |
|
36 | 36 |
E_NO_ISSUER_FOUND = {"success": False, "data": "No certificate authority with such unique ID exists."} |
37 | 37 |
E_NO_CERTIFICATES_FOUND = {"success": False, "data": "No such certificate found."} |
38 |
E_NO_CERTIFICATE_ALREADY_REVOKED = {"success": False, "data": "Certificate is already revoked."} |
|
38 | 39 |
E_NO_CERT_PRIVATE_KEY_FOUND = {"success": False, |
39 | 40 |
"data": "Internal server error (certificate's private key cannot be found)."} |
40 | 41 |
E_NOT_JSON_FORMAT = {"success": False, "data": "The request must be JSON-formatted."} |
... | ... | |
340 | 341 |
try: |
341 | 342 |
# set certificate status using certificate_service |
342 | 343 |
self.certificate_service.set_certificate_revocation_status(identifier, status, reason) |
343 |
except (RevocationReasonInvalidException, CertificateStatusInvalidException, CertificateNotFoundException):
|
|
344 |
except (RevocationReasonInvalidException, CertificateStatusInvalidException): |
|
344 | 345 |
# these exceptions are thrown in case invalid status or revocation reason is passed to the controller |
345 | 346 |
return E_WRONG_PARAMETERS, C_BAD_REQUEST |
347 |
except CertificateAlreadyRevokedException: |
|
348 |
return E_NO_CERTIFICATE_ALREADY_REVOKED, C_BAD_REQUEST |
|
349 |
except CertificateNotFoundException: |
|
350 |
return E_NO_CERTIFICATES_FOUND, C_NOT_FOUND |
|
346 | 351 |
return {"success": True, |
347 | 352 |
"data": "Certificate status updated successfully."}, C_SUCCESS |
348 | 353 |
# throw an error in case the request does not contain a json body |
Také k dispozici: Unified diff
Re #8571 - Fixed problems during walk-through code review