16.2.1.4. Container Class¶
The following container types are known to privacyIDEA. All are inherited from the generic tokenclass which is described below.
16.2.1.4.3. Generic¶
- class privacyidea.lib.containerclass.TokenContainerClass(db_container)[source]¶
- add_container_info(key, value)[source]¶
Add a key and a value to the DB tokencontainerinfo
- Parameters
key – key
value – value
- add_states(state_list: List[str])[source]¶
Add states to the container. Previous states are only removed if a new state excludes them. Raises a ParameterError if the state list contains exclusive states.
- Parameters
state_list – List of states as strings
- Returns
Dictionary in the format {state: success}
- add_token(token: privacyidea.lib.tokenclass.TokenClass)[source]¶
Add a token to the container. Raises a ParameterError if the token type is not supported by the container.
- Parameters
token – TokenClass object
- Returns
True if the token was successfully added, False if the token is already in the container
- add_user(user: privacyidea.lib.user.User)[source]¶
Assign a user to the container. Raises a UserError if the user does not exist. Raises a TokenAdminError if the container already has an owner.
- Parameters
user – User object
- Returns
True if the user was assigned
- delete_container_info(key=None)[source]¶
Delete the tokencontainerinfo from the DB
- Parameters
key – key to delete, if None all keys are deleted
- property description¶
- get_container_info()[source]¶
Return the tokencontainerinfo from the DB
- Returns
list of tokencontainerinfo objects
- classmethod get_state_types()[source]¶
Returns the state types that are supported by this container class and the states that are exclusive to each of these states.
- Returns
Dictionary in the format: {state: [excluded_states]}
- classmethod get_supported_token_types()[source]¶
Returns the token types that are supported by the container class.
- property last_seen¶
- property last_updated¶
- property realms¶
- remove_token(serial: str)[source]¶
Remove a token from the container. Raises a ResourceNotFoundError if the token does not exist.
- Parameters
serial – Serial of the token
- Returns
True if the token was successfully removed, False if the token was not found in the container
- remove_user(user: privacyidea.lib.user.User)[source]¶
Remove a user from the container. Raises a ResourceNotFoundError if the user does not exist.
- Parameters
user – User object to be removed
- Returns
True if the user was removed, False if the user was not found in the container
- property serial¶
- set_container_info(info)[source]¶
Set the containerinfo field in the DB. Old values will be deleted.
- Parameters
info – dictionary in the format: {key: value}
- set_realms(realms, add=False)[source]¶
Set the realms of the container. If add is True, the realms will be added to the existing realms, otherwise the existing realms will be removed.
- Parameters
realms – List of realm names
add – False if the existing realms shall be removed, True otherwise
- Returns
Dictionary in the format {realm: success}, the entry ‘deleted’ indicates whether existing realms were deleted.
- set_states(state_list: List[str])[source]¶
Set the states of the container. Previous states will be removed. Raises a ParameterError if the state list contains exclusive states.
- Parameters
state_list – List of states as strings
- Returns
Dictionary in the format {state: success}
- property type¶