def on_put(self, keystone_id, **kwargs): if not pecan.request.content_type or \ pecan.request.content_type == 'application/json': pecan.abort( 415, u._("Content-Type of '{0}' is not supported for PUT.").format( pecan.request.content_type ) ) secret = self.repo.get(entity_id=self.secret_id, keystone_id=keystone_id, suppress_exception=True) if not secret: _secret_not_found() if secret.encrypted_data: _secret_already_has_data() tenant = res.get_or_create_tenant(keystone_id, self.tenant_repo) content_type = pecan.request.content_type content_encoding = pecan.request.headers.get('Content-Encoding') res.create_encrypted_datum(secret, pecan.request.body, content_type, content_encoding, tenant, self.crypto_manager, self.datum_repo, self.kek_repo)
def on_put(self, req, resp, keystone_id, secret_id): if not req.content_type or req.content_type == 'application/json': _put_accept_incorrect(req.content_type, req, resp) secret = self.repo.get(entity_id=secret_id, keystone_id=keystone_id, suppress_exception=True) if not secret: _secret_not_found(req, resp) if secret.encrypted_data: _secret_already_has_data(req, resp) tenant = res.get_or_create_tenant(keystone_id, self.tenant_repo) payload = None content_type = req.content_type content_encoding = req.get_header('Content-Encoding') try: payload = req.stream.read(api.MAX_BYTES_REQUEST_INPUT_ACCEPTED) except IOError: api.abort(falcon.HTTP_500, 'Read Error') res.create_encrypted_datum(secret, payload, content_type, content_encoding, tenant, self.crypto_manager, self.datum_repo, self.kek_repo) resp.status = falcon.HTTP_200
def on_put(self, req, resp, tenant_id, secret_id): if not req.content_type or req.content_type == 'application/json': _put_accept_incorrect(req.content_type) secret = self.repo.get(entity_id=secret_id, suppress_exception=True) if not secret: _secret_not_found() if secret.mime_type != req.content_type: _client_content_mismatch_to_secret() if secret.encrypted_data: _secret_already_has_data() try: plain_text = req.stream.read() except IOError: abort(falcon.HTTP_500, 'Read Error') resp.status = falcon.HTTP_200 try: create_encrypted_datum(secret, plain_text, tenant_id, self.tenant_secret_repo, self.datum_repo) except ValueError: LOG.error('Problem creating an encrypted datum for the secret.', exc_info=True) _failed_to_create_encrypted_datum()
def on_put(self, keystone_id): if not pecan.request.content_type or \ pecan.request.content_type == 'application/json': pecan.abort( 415, u._("Content-Type of '{0}' is not supported for PUT.").format( pecan.request.content_type ) ) secret = self.repo.get(entity_id=self.secret_id, keystone_id=keystone_id, suppress_exception=True) if not secret: _secret_not_found() if secret.encrypted_data: _secret_already_has_data() tenant = res.get_or_create_tenant(keystone_id, self.tenant_repo) content_type = pecan.request.content_type content_encoding = pecan.request.headers.get('Content-Encoding') res.create_encrypted_datum(secret, pecan.request.body, content_type, content_encoding, tenant, self.crypto_manager, self.datum_repo, self.kek_repo)
def on_put(self, req, resp, keystone_id, secret_id): if not req.content_type or req.content_type == 'application/json': _put_accept_incorrect(req.content_type, req, resp) secret = self.repo.get(entity_id=secret_id, keystone_id=keystone_id, suppress_exception=True) if not secret: _secret_not_found(req, resp) if secret.mime_type != req.content_type: _client_content_mismatch_to_secret(secret.mime_type, req.content_type, req, resp) if secret.encrypted_data: _secret_already_has_data(req, resp) tenant = res.get_or_create_tenant(keystone_id, self.tenant_repo) try: plain_text = req.stream.read(api.MAX_BYTES_REQUEST_INPUT_ACCEPTED) except IOError: api.abort(falcon.HTTP_500, 'Read Error') resp.status = falcon.HTTP_200 try: res.create_encrypted_datum(secret, plain_text, tenant, self.crypto_manager, self.tenant_secret_repo, self.datum_repo) except em.CryptoMimeTypeNotSupportedException as cmtnse: LOG.exception('Secret creation failed - mime-type not supported') _secret_mime_type_not_supported(cmtnse.mime_type, req, resp) except exception.NoDataToProcess: LOG.exception('No secret data to process') _secret_plain_text_empty(req, resp) except exception.LimitExceeded: LOG.exception('Secret data too big to process') _secret_data_too_large(req, resp) except Exception as e: LOG.exception('Secret creation failed - unknown') _failed_to_create_encrypted_datum(req, resp)