diff options
author | Simo Sorce <simo@redhat.com> | 2015-06-05 10:56:29 -0400 |
---|---|---|
committer | Simo Sorce <simo@redhat.com> | 2015-06-05 10:56:29 -0400 |
commit | eff99ee7a065e6e122dbd7cee136a2651073d224 (patch) | |
tree | 40761c5cc8ac6ff0cc270b4eb0faa3e62beda368 /custodia/message | |
parent | f68ec64138d5b259788f25b54deec12e80a95ec7 (diff) | |
download | custodia-eff99ee7a065e6e122dbd7cee136a2651073d224.tar.gz custodia-eff99ee7a065e6e122dbd7cee136a2651073d224.tar.xz custodia-eff99ee7a065e6e122dbd7cee136a2651073d224.zip |
Add basic debugging capabilities
If debug is set to True, then custodia's own Exception handlers will
print a stack trace to standard output to aid debugging.
Signed-off-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'custodia/message')
-rw-r--r-- | custodia/message/common.py | 14 | ||||
-rw-r--r-- | custodia/message/kem.py | 5 |
2 files changed, 15 insertions, 4 deletions
diff --git a/custodia/message/common.py b/custodia/message/common.py index 25ce4e7..c538a57 100644 --- a/custodia/message/common.py +++ b/custodia/message/common.py @@ -1,5 +1,7 @@ # Copyright (C) 2015 Custodia Project Contributors - see LICENSE file +from custodia import log + class InvalidMessage(Exception): """Invalid Message. @@ -7,7 +9,9 @@ class InvalidMessage(Exception): This exception is raised when a message cannot be parsed or validated. """ - pass + def __init__(self, message=None): + log.debug(message) + super(InvalidMessage, self).__init__(message) class UnknownMessageType(Exception): @@ -16,7 +20,9 @@ class UnknownMessageType(Exception): This exception is raised when a message is of an unknown type. """ - pass + def __init__(self, message=None): + log.debug(message) + super(UnknownMessageType, self).__init__(message) class UnallowedMessage(Exception): @@ -25,7 +31,9 @@ class UnallowedMessage(Exception): This exception is raise when the message type is know but is not allowed. """ - pass + def __init__(self, message=None): + log.debug(message) + super(UnallowedMessage, self).__init__(message) class MessageHandler(object): diff --git a/custodia/message/kem.py b/custodia/message/kem.py index 3d15e2f..343cb90 100644 --- a/custodia/message/kem.py +++ b/custodia/message/kem.py @@ -3,6 +3,7 @@ from custodia.httpd.authorizers import SimplePathAuthz from custodia.message.common import InvalidMessage from custodia.message.common import MessageHandler +from custodia import log from jwcrypto.common import json_decode from jwcrypto.common import json_encode from jwcrypto.jwe import JWE @@ -19,7 +20,9 @@ KEY_USAGE_MAP = {KEY_USAGE_SIG: 'sig', KEY_USAGE_ENC: 'enc'} class UnknownPublicKey(Exception): - pass + def __init__(self, message=None): + log.debug(message) + super(UnknownPublicKey, self).__init__(message) class KEMKeysStore(SimplePathAuthz): |