Skip to content

IEnvironmentService

IEnvironmentService is the primary contract for environment/config/user-context access in this library. It defines the public operations that consumers rely on to resolve runtime environment context and retrieve configuration settings, regardless of hosting context.

Purpose

  • Define the environment-resolution and configuration-retrieval contract implemented by EnvironmentServiceBase and consumed directly by application code.

Context

  • Namespace: SAIF.Framework.Security
  • Assembly/package: SAIF.Framework.Security.EnvironmentApi

Public members

Member Signature Purpose
IsClientExternal bool IsClientExternal { get; } Indicates whether the current client request originates from outside the internal network.
IsClientInsideFirewall bool IsClientInsideFirewall { get; } Indicates whether the current client request originates from inside the firewall.
IsDeveloperMachine bool IsDeveloperMachine { get; } Indicates whether the current host is classified as a developer machine (see BR-005).
IsLocalMachine bool IsLocalMachine { get; } Indicates whether the current host is the local machine for the hosting context.
IsProduction bool IsProduction { get; } Indicates whether GetApplicationEnvironment() returns ApplicationEnvironment.Prod.
IsWeb bool IsWeb { get; } Indicates whether the hosting context is a web application.
ApplicationId string ApplicationId { get; } The application identifier used to scope Environment API requests.
MachineName string MachineName { get; } The current machine's name.
User IPrincipal User { get; } The already-authenticated principal for the current request/thread.
GetApplicationTrack string GetApplicationTrack() Returns the current application's deployment track.
GetConfigSetting string GetConfigSetting(string configKey) Retrieves a plain-text configuration value (see Retrieve a configuration setting).
GetConfigSetting\<T> T GetConfigSetting<T>(string configKey) Retrieves a typed configuration value.
GetSecureConfigSetting string GetSecureConfigSetting(string configKey, string systemHashValue) Retrieves an encrypted configuration value using a caller-supplied system hash.
GetSecureConfigSetting\<T> T GetSecureConfigSetting<T>(string configKey, string systemHashValue) Retrieves a typed encrypted configuration value.
GetApplicationEnvironment ApplicationEnvironment GetApplicationEnvironment() Returns the current deployment tier (Dev, Test, Qa, Prod, Global).
LoadSection ConfigurationSettings LoadSection(string section) Fetches and merges an entire named configuration section.
Configurations ConfigurationSettings Configurations { get; } The current in-memory cached configuration settings.

The static class IEnvironmentServiceExtensions (same file) defines one extension method:

Member Signature Purpose
UserId string UserId(this EnvironmentServiceBase service) Returns the user id portion of User.Identity.Name; returns an empty string if resolution fails.

Behavioral notes

  • All implementing types are host-specific concrete subclasses of EnvironmentServiceBase, not direct implementers of this interface*.
  • GetConfigSetting/GetConfigSetting<T> throw ApplicationException if the key cannot be resolved from any source — see BR-001.

Constraints and usage notes

  • Consumers instantiate a concrete *EnvironmentService for their hosting context; there is no dependency-injection container reference in this library*.
  • GetSecureConfigSetting has no internal call sites within this library — it is exposed for consumers to pair with SystemHashUtil-generated hash values.

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • SAIF.Framework.Security.EnvironmentApi\Core\Services\IEnvironmentService.cs