# enamine_credentials.py - script functions developed for integration with Enamine server
# Use of this code is subject to the terms of the StarDrop License Agreement and use, copying or redistribution of
# this file for use by other persons or organisations is prohibited
# Copyright(C) Optibrium Ltd 2026
# support@optibrium.com
#
"""
Module handles user access credentials to the Enamine server.
"""


class CredentialsManager:
    """Class to store credentials."""

    def __init__(self, username, password):
        """Create a CredentialsManager. Throws ValueError if user and password not specified.
        :param: user: The Enamine username.
        :param: password: The Enamine password.
        """
        if username == "" or password == "":
            self.clear()
            raise ValueError("User and password must be completed")

        self._username = username
        self._password = password
        self.configured = True

    def get_user(self):
        """Get the username.
        :return: Username
        """
        return self._username

    def get_password(self):
        """Get the password.
        :return: Password
        """
        return self._password

    def clear(self):
        """Clear the current credentials after a login failure."""
        self._username = ""
        self._password = ""
        self.configured = False
