Files
PrimAITE/src/primaite/simulator/domain/account.py

71 lines
1.8 KiB
Python
Raw Normal View History

2023-08-02 13:43:31 +01:00
"""User account simulation."""
from enum import Enum
2023-08-07 10:55:29 +01:00
from typing import Dict
2023-08-02 13:43:31 +01:00
from primaite import getLogger
from primaite.simulator.core import SimComponent
_LOGGER = getLogger(__name__)
class AccountType(Enum):
"""Whether the account is intended for a user to log in or for a service to use."""
service = 1
"Service accounts are used to grant permissions to software on nodes to perform actions"
user = 2
"User accounts are used to allow agents to log in and perform actions"
class AccountStatus(Enum):
"""Whether the account is active."""
enabled = 1
disabled = 2
class PasswordPolicyLevel(Enum):
"""Complexity requirements for account passwords."""
low = 1
medium = 2
high = 3
2023-08-02 13:43:31 +01:00
class Account(SimComponent):
"""User accounts."""
num_logons: int = 0
"The number of times this account was logged into since last reset."
num_logoffs: int = 0
"The number of times this account was logged out of since last reset."
num_group_changes: int = 0
"The number of times this account was moved in or out of an AccountGroup."
username: str
"Account username."
password: str
"Account password."
account_type: AccountType
"Account Type, currently this can be service account (used by apps) or user account."
status: AccountStatus = AccountStatus.disabled
2023-08-07 10:55:29 +01:00
def describe_state(self) -> Dict:
"""Describe state for agent observations."""
return super().describe_state()
def enable(self):
2023-08-02 13:43:31 +01:00
"""Set the status to enabled."""
self.status = AccountStatus.enabled
def disable(self):
2023-08-02 13:43:31 +01:00
"""Set the status to disabled."""
self.status = AccountStatus.disabled
2023-08-07 10:55:29 +01:00
def log_on(self) -> None:
"""TODO."""
self.num_logons += 1
def log_off(self) -> None:
"""TODO."""
self.num_logoffs += 1