예제 #1
0
def validate_stored_key_rsa_container(project_id, container_ref, req):
        try:
            container_id = hrefs.get_container_id_from_ref(container_ref)
        except Exception:
            reason = u._("Bad Container Reference {ref}").format(
                ref=container_ref
            )
            raise exception.InvalidContainer(reason=reason)

        container_repo = repo.get_container_repository()

        container = container_repo.get_container_by_id(entity_id=container_id,
                                                       suppress_exception=True)
        if not container:
            reason = u._("Container Not Found")
            raise exception.InvalidContainer(reason=reason)

        if container.type != 'rsa':
            reason = u._("Container Wrong Type")
            raise exception.InvalidContainer(reason=reason)

        ctxt = controllers._get_barbican_context(req)
        inst = controllers.containers.ContainerController(container)
        controllers._do_enforce_rbac(inst, req,
                                     controllers.containers.CONTAINER_GET,
                                     ctxt)
예제 #2
0
def validate_stored_key_rsa_container(project_id, container_ref, req):
        try:
            container_id = hrefs.get_container_id_from_ref(container_ref)
        except Exception:
            reason = u._("Bad Container Reference {ref}").format(
                ref=container_ref
            )
            raise exception.InvalidContainer(reason=reason)

        container_repo = repo.get_container_repository()

        container = container_repo.get_container_by_id(entity_id=container_id,
                                                       suppress_exception=True)
        if not container:
            reason = u._("Container Not Found")
            raise exception.InvalidContainer(reason=reason)

        if container.type != 'rsa':
            reason = u._("Container Wrong Type")
            raise exception.InvalidContainer(reason=reason)

        ctxt = controllers._get_barbican_context(req)
        inst = controllers.containers.ContainerController(container)
        controllers._do_enforce_rbac(inst, req,
                                     controllers.containers.CONTAINER_GET,
                                     ctxt)