Example #1
0
 def __init__(self,
              api,
              name=None,
              secrets=None,
              consumers=None,
              container_ref=None,
              created=None,
              updated=None,
              status=None,
              secret_refs=None):
     self._api = api
     self._secret_manager = secret_manager.SecretManager(api)
     self._name = name
     self._container_ref = container_ref
     self._secret_refs = secret_refs
     self._cached_secrets = dict()
     self._initialize_secrets(secrets)
     if container_ref:
         self._consumers = consumers if consumers else list()
         self._created = parse_isotime(created) if created else None
         self._updated = parse_isotime(updated) if updated else None
         self._status = status
     else:
         self._consumers = list()
         self._created = None
         self._updated = None
         self._status = None
     self._acl_manager = acl_manager.ACLManager(api)
     self._acls = None
Example #2
0
    def __init__(self, session=None, *args, **kwargs):
        """
        Barbican client object used to interact with barbican service.

        :param session: An instance of keystoneclient.session.Session that
            can be either authenticated, or not authenticated.  When using
            a non-authenticated Session, you must provide some additional
            parameters.  When no session is provided it will default to a
            non-authenticated Session.
        :param endpoint: Barbican endpoint url. Required when a session is not
            given, or when using a non-authenticated session.
            When using an authenticated session, the client will attempt
            to get an endpoint from the session.
        :param project_id: The project ID used for context in Barbican.
            Required when a session is not given, or when using a
            non-authenticated session.
            When using an authenticated session, the project ID will be
            provided by the authentication mechanism.
        :param verify: When a session is not given, the client will create
            a non-authenticated session.  This parameter is passed to the
            session that is created.  If set to False, it allows
            barbicanclient to perform "insecure" TLS (https) requests.
            The server's certificate will not be verified against any
            certificate authorities.
            WARNING: This option should be used with caution.
        :param service_type: Used as an endpoint filter when using an
            authenticated keystone session. Defaults to 'key-management'.
        :param service_name: Used as an endpoint filter when using an
            authenticated keystone session.
        :param interface: Used as an endpoint filter when using an
            authenticated keystone session. Defaults to 'public'.
        :param region_name: Used as an endpoint filter when using an
            authenticated keystone session.
        """
        LOG.debug("Creating Client object")

        if not session:
            session = ks_session.Session(verify=kwargs.pop('verify', True))

        if session.auth is None and kwargs.get('auth') is None:
            if not kwargs.get('endpoint'):
                raise ValueError('Barbican endpoint url must be provided when '
                                 'not using auth in the Keystone Session.')

            if kwargs.get('project_id') is None:
                raise ValueError('Project ID must be provided when not using '
                                 'auth in the Keystone Session')

        httpclient = _HTTPClient(session=session, *args, **kwargs)

        self.secrets = secrets.SecretManager(httpclient)
        self.orders = orders.OrderManager(httpclient)
        self.containers = containers.ContainerManager(httpclient)
        self.cas = cas.CAManager(httpclient)
        self.acls = acls.ACLManager(httpclient)
Example #3
0
 def __init__(self,
              api,
              name=None,
              expiration=None,
              algorithm=None,
              bit_length=None,
              mode=None,
              payload=None,
              payload_content_type=None,
              payload_content_encoding=None,
              secret_ref=None,
              created=None,
              updated=None,
              content_types=None,
              status=None,
              secret_type=None,
              creator_id=None):
     """
     Secret objects should not be instantiated directly.  You should use
     the `create` or `get` methods of the
     :class:`barbicanclient.secrets.SecretManager` instead.
     """
     self._api = api
     self._secret_ref = secret_ref
     self._fill_from_data(name=name,
                          expiration=expiration,
                          algorithm=algorithm,
                          bit_length=bit_length,
                          secret_type=secret_type,
                          mode=mode,
                          payload=payload,
                          payload_content_type=payload_content_type,
                          payload_content_encoding=payload_content_encoding,
                          created=created,
                          updated=updated,
                          content_types=content_types,
                          status=status,
                          creator_id=creator_id)
     self._acl_manager = acl_manager.ACLManager(api)
     self._acls = None