From ef1b147923de88c433291932554ee1c899e30729 Mon Sep 17 00:00:00 2001 From: Amy Marrich Date: Tue, 7 Jul 2015 10:29:14 -0500 Subject: [PATCH] Completed localization tagging for plugin directory Completed localization for messages under plugin directory Completed localization for Log exceptions raised in plugin directory Updated logging level in kmip_secret_store.py for secret general exception Change-Id: I07ec604ff21da0982c484eb6f021229219d4ac4a Closes-bug: #1468482 --- barbican/plugin/crypto/pkcs11.py | 5 +++-- barbican/plugin/dogtag.py | 8 ++++---- barbican/plugin/kmip_secret_store.py | 6 +++--- barbican/plugin/snakeoil_ca.py | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/barbican/plugin/crypto/pkcs11.py b/barbican/plugin/crypto/pkcs11.py index 90d7e40df..b653d3152 100644 --- a/barbican/plugin/crypto/pkcs11.py +++ b/barbican/plugin/crypto/pkcs11.py @@ -346,7 +346,8 @@ class PKCS11(object): def perform_rng_self_test(self, session): test_random = self.generate_random(100, session) if self.ffi.buffer(test_random, 100)[:] == b"\x00" * 100: - raise P11CryptoPluginException("Apparent RNG self-test failure.") + raise P11CryptoPluginException(u._( + "Apparent RNG self-test failure.")) def open_session(self, slot): session_ptr = self.ffi.new("CK_SESSION_HANDLE *") @@ -409,7 +410,7 @@ class PKCS11(object): val_list.append(self.ffi.new("char []", attr.value)) attributes[index].value_len = len(attr.value) else: - raise TypeError("Unknown attribute type provided.") + raise TypeError(u._("Unknown attribute type provided.")) attributes[index].value = val_list[-1] diff --git a/barbican/plugin/dogtag.py b/barbican/plugin/dogtag.py index 0d49a3e67..173e52788 100644 --- a/barbican/plugin/dogtag.py +++ b/barbican/plugin/dogtag.py @@ -780,8 +780,8 @@ class DogtagCAPlugin(cm.CertificatePluginBase): } if request_type not in jump_table: - raise DogtagPluginNotSupportedException( - "Dogtag plugin does not support %s request type".format( + raise DogtagPluginNotSupportedException(u._( + "Dogtag plugin does not support %s request type").format( request_type)) return jump_table[request_type](order_id, order_meta, plugin_meta, @@ -825,8 +825,8 @@ class DogtagCAPlugin(cm.CertificatePluginBase): :param barbican_meta_dto: :return: cm.ResultDTO """ - raise DogtagPluginNotSupportedException( - "Dogtag plugin does not support %s request type".format( + raise DogtagPluginNotSupportedException(u._( + "Dogtag plugin does not support %s request type").format( cm.CertificateRequestType.FULL_CMC_REQUEST)) @_catch_enrollment_exceptions diff --git a/barbican/plugin/kmip_secret_store.py b/barbican/plugin/kmip_secret_store.py index b1151a955..5f692020d 100644 --- a/barbican/plugin/kmip_secret_store.py +++ b/barbican/plugin/kmip_secret_store.py @@ -256,7 +256,7 @@ class KMIPSecretStore(ss.SecretStoreBase): template_attribute=template_attribute, credential=self.credential) except Exception as e: - LOG.exception("Error opening or writing to client") + LOG.exception(u._LE("Error opening or writing to client")) raise ss.SecretGeneralException(str(e)) else: if result.result_status.enum == enums.ResultStatus.SUCCESS: @@ -315,7 +315,7 @@ class KMIPSecretStore(ss.SecretStoreBase): common_template_attribute=common, credential=self.credential) except Exception as e: - LOG.exception("Error opening or writing to client") + LOG.exception(u._LE("Error opening or writing to client")) raise ss.SecretGeneralException(str(e)) else: if result.result_status.enum == enums.ResultStatus.SUCCESS: @@ -728,7 +728,7 @@ class KMIPSecretStore(ss.SecretStoreBase): reason=result.result_reason, message=result.result_message ) - LOG.debug("ERROR from KMIP server: %s", msg) + LOG.error(u._LE("ERROR from KMIP server: %s"), msg) raise ss.SecretGeneralException(msg) def _validate_keyfile_permissions(self, path): diff --git a/barbican/plugin/snakeoil_ca.py b/barbican/plugin/snakeoil_ca.py index 7c6299ad6..5b4e438a9 100644 --- a/barbican/plugin/snakeoil_ca.py +++ b/barbican/plugin/snakeoil_ca.py @@ -207,7 +207,7 @@ class SnakeoilCACertificatePlugin(cert_manager.CertificatePluginBase): except KeyError: return cert_manager.ResultDTO( cert_manager.CertificateStatus.CLIENT_DATA_ISSUE_SEEN, - status_message="No request_data specified") + status_message=u._("No request_data specified")) csr = crypto.load_certificate_request(crypto.FILETYPE_PEM, encoded_csr) cert = self.cert_manager.make_certificate(csr) cert_enc = crypto.dump_certificate(crypto.FILETYPE_PEM, cert)