Table of Contents

Class BasicAuthenticationService

Namespace
Core.CliniCore.Service
Assembly
Core.CliniCore.dll

Authentication service implementation that delegates to ICredentialRepository. Provides password hashing and verification utilities.

public class BasicAuthenticationService : IAuthenticationService
Inheritance
BasicAuthenticationService
Implements
Inherited Members

Constructors

BasicAuthenticationService(ICredentialRepository, IPatientRepository, IPhysicianRepository, IAdministratorRepository)

Authentication service implementation that delegates to ICredentialRepository. Provides password hashing and verification utilities.

public BasicAuthenticationService(ICredentialRepository credentialRepository, IPatientRepository patientRepository, IPhysicianRepository physicianRepository, IAdministratorRepository administratorRepository)

Parameters

credentialRepository ICredentialRepository
patientRepository IPatientRepository
physicianRepository IPhysicianRepository
administratorRepository IAdministratorRepository

Methods

Authenticate(string, string)

Authenticates a user with username and password

public AuthenticationResult Authenticate(string username, string password)

Parameters

username string

The username to authenticate

password string

The password to verify

Returns

AuthenticationResult

Authentication result with profile on success, or failure reason

ChangePassword(string, string, string)

Changes a user's password

public bool ChangePassword(string username, string currentPassword, string newPassword)

Parameters

username string

The username whose password to change

currentPassword string

The current password for verification

newPassword string

The new password to set

Returns

bool

True if password change successful, false otherwise

GetAllUsernames()

Gets all registered usernames (for debugging/testing only)

public IEnumerable<string> GetAllUsernames()

Returns

IEnumerable<string>

GetLastLoginTime(string)

Gets the last login time for a user

public DateTime? GetLastLoginTime(string username)

Parameters

username string

The username to check

Returns

DateTime?

The last login DateTime, or null if never logged in

HashPassword(string)

Simple password hashing for Assignment 1. Production would use BCrypt, Argon2, or similar.

public static string HashPassword(string password)

Parameters

password string

Returns

string

Register(IUserProfile, string)

Registers a new user in the system

public bool Register(IUserProfile profile, string password)

Parameters

profile IUserProfile

The user profile to register

password string

The password for the new user

Returns

bool

True if registration successful, false otherwise

UserExists(string)

Checks if a username already exists in the system

public bool UserExists(string username)

Parameters

username string

The username to check

Returns

bool

True if username exists, false otherwise

ValidatePasswordStrength(string)

Validates if a password meets security requirements

public bool ValidatePasswordStrength(string password)

Parameters

password string

The password to validate

Returns

bool

True if password meets requirements, false otherwise

VerifyPassword(string, string)

Verifies a password against a hash

public static bool VerifyPassword(string password, string hash)

Parameters

password string
hash string

Returns

bool