17 Barbican exception subclasses
20 from barbican
import i18n
as u
22 _FATAL_EXCEPTION_FORMAT_ERRORS =
False
26 """Base Barbican Exception
28 To correctly use this class, inherit from it and define
29 a 'message' property. That message will get printf'd
30 with the keyword arguments provided to the constructor.
32 message = u._(
"An unknown exception occurred")
34 def __init__(self, message_arg=None, *args, **kwargs):
36 message_arg = self.
messagemessage
38 self.
messagemessage = message_arg % kwargs
39 except Exception
as e:
40 if _FATAL_EXCEPTION_FORMAT_ERRORS:
49 """Base Barbican Exception to handle HTTP responses
51 To correctly use this class, inherit from it and define the following
54 - message: The message that will be displayed in the server log.
55 - client_message: The message that will actually be outputted to the
57 - status_code: The HTTP status code that should be returned.
58 The default status code is 500.
60 client_message = u._(
"failure seen - please contact site administrator.")
63 def __init__(self, message_arg=None, client_message=None, *args, **kwargs):
64 if not client_message:
68 except Exception
as e:
69 if _FATAL_EXCEPTION_FORMAT_ERRORS:
74 super(BarbicanHTTPException, self).
__init__(
79 message = u._(
"Missing required argument.")
83 message = u._(
"Missing required metadata field for %(required)s")
84 client_message = message
89 message = u._(
"Invalid Metadata. Keys and Values must be Strings.")
90 client_message = message
95 message = u._(
"Invalid Key. Key must be URL safe.")
96 client_message = message
101 message = u._(
"Invalid subject DN: %(subject_dn)s")
102 client_message = message
107 message = u._(
"Invalid container: %(reason)s")
108 client_message = message
113 message = u._(
"Invalid extensions data.")
114 client_message = message
119 message = u._(
"Invalid CMC Data")
120 client_message = message
125 message = u._(
"Invalid PKCS10 Data: %(reason)s")
126 client_message = message
131 message = u._(
"Invalid Certificate Request Type")
132 client_message = message
137 message = u._(
"Extensions are not yet supported. "
138 "Specify a valid profile instead.")
139 client_message = message
144 message = u._(
"Full CMC Requests are not yet supported.")
145 client_message = message
150 message = u._(
"An object with the specified identifier was not found.")
154 message = u._(
"A defined SQL constraint check failed: %(error)s")
158 message = u._(
"Operation is not supported.")
162 message = u._(
"Data supplied was not valid.")
166 message = u._(
"No data supplied to process.")
167 client_message = message
172 message = u._(
"The request returned a 413 Request Entity Too Large. This "
173 "generally means that rate limiting or a quota threshold "
175 client_message = u._(
"Provided information too large to process")
179 super(LimitExceeded, self).
__init__(*args, **kwargs)
180 self.
retry_afterretry_after = (int(kwargs[
'retry'])
if kwargs.get(
'retry')
191 "schema '{schema}': "
192 "{reason}. Invalid property: "
193 "'{property}'").format(*args, **kwargs)
195 super(InvalidObject, self).
__init__(*args, **kwargs)
200 message = u._(
"Error while attempting to decode payload.")
201 client_message = u._(
"Unable to decode request data.")
205 message = u._(
"No support for value set on field '%(field)s' on "
206 "schema '%(schema)s': %(reason)s")
207 client_message = u._(
"Provided field value is not supported")
211 super(UnsupportedField, self).
__init__(*args, **kwargs)
216 message = u._(
"Feature not implemented for value set on field "
217 "'%(field)s' on " "schema '%(schema)s': %(reason)s")
220 super(FeatureNotImplemented, self).
__init__(*args, **kwargs)
225 message = u._(
"Container %(container_id)s does not exist for stored "
226 "key certificate generation.")
230 message = u._(
"Container %(container_id)s does not reference a private "
231 "key needed for stored key certificate generation.")
235 message = u._(
"Provided Transport key %(transport_key_id)s "
236 "could not be found")
237 client_message = u._(
"Provided transport key was not found.")
242 message = u._(
"Invalid CA_ID: %(ca_id)s")
243 client_message = u._(
"The ca_id provided in the request is invalid")
248 message = u._(
"CA specified by ca_id %(ca_id)s not defined for project: "
250 client_message = u._(
"The ca_id provided in the request is not defined "
256 message = u._(
"Quota reached for project %(external_project_id)s. Only "
257 "%(quota)s %(resource_type)s are allowed.")
258 client_message = u._(
"Creation not allowed because a quota has "
263 super(QuotaReached, self).
__init__(*args, **kwargs)
265 self.
quotaquota = kwargs.get(
'quota')
270 message = u._(
"Invalid Parent CA: %(parent_ca_ref)s")
271 client_message = message
276 message = u._(
"Plugin does not support generation of subordinate CAs")
277 client_message = message
282 message = u._(
"Errors in creating subordinate CA: %(name)")
283 client_message = message
287 message = u._(
"Only subordinate CAs can be deleted.")
292 message = u._(
"Subordinate CA is not owned by this project")
293 client_message = message
298 message = u._(
"A new project preferred CA must be set "
299 "before this one can be deleted.")
304 message = u._(
"Errors returned by CA when attempting to "
305 "create subordinate CA: %(reason)s")
306 client_message = message
311 message = u._(
"Errors returned by CA when attempting to create "
312 "subordinate CA: %(reason)s")
313 client_message = message
317 message = u._(
"Errors returned by CA when attempting to delete "
318 "subordinate CA: %(reason)s")
319 client_message = message
323 message = u._(
"There was an error with the PKCS#11 library.")
327 message = u._(
"More than one key found for label")
331 message = u._(
"General exception")
335 message = u._(
"No key handle was found")
339 message = u._(
"No token was found in slot %(slot_id)s")
343 """Raised when a preferred plugin is missing in service configuration."""
345 super(MultipleStorePreferredPluginMissing, self).
__init__(
346 u._(
"Preferred Secret Store plugin '{store_name}' is not "
347 "currently set in service configuration. This is probably a "
348 "server misconfiguration.").format(
349 store_name=store_name)
355 """Raised when a used plugin is missing in service configuration."""
357 super(MultipleStorePluginStillInUse, self).
__init__(
358 u._(
"Secret Store plugin '{store_name}' is still in use and can "
359 "not be removed. Its missing in service configuration. This is"
360 " probably a server misconfiguration.").format(
361 store_name=store_name)
367 """Raised when a plugin lookup suffix is missing during config read."""
369 msg = u._(
"Plugin lookup property 'stores_lookup_suffix' is not "
370 "defined in service configuration")
371 super(MultipleSecretStoreLookupFailed, self).
__init__(msg)
375 """Raised when a global default for only one plugin is not set to True."""
379 msg = u._(
"There are {count} plugins with global default as "
380 "True in service configuration. Only one plugin can have"
381 " this as True").format(count=occurrence)
383 msg = u._(
"There is no plugin defined with global default as True."
384 " One of plugin must be identified as global default")
386 super(MultipleStoreIncorrectGlobalDefault, self).
__init__(msg)
390 """Raised when a store plugin value is missing in service configuration."""
392 super(MultipleStorePluginValueMissing, self).
__init__(
393 u._(
"In section '{0}', secret_store_plugin value is missing"
394 ).format(section_name)
def __init__(self, message_arg=None, *args, **kwargs)
def __init__(self, message_arg=None, client_message=None, *args, **kwargs)
def __init__(self, *args, **kwargs)
def __init__(self, *args, **kwargs)
def __init__(self, *args, **kwargs)
def __init__(self, occurrence)
def __init__(self, store_name)
def __init__(self, section_name)
def __init__(self, store_name)
def __init__(self, *args, **kwargs)
def __init__(self, *args, **kwargs)