OpenTAP 9.27
API Reference
Public Member Functions | Properties | List of all members
OpenTap.Authentication.AuthenticationSettings Class Reference

This class stores information about the logged in client. More...

Inheritance diagram for OpenTap.Authentication.AuthenticationSettings:
OpenTap.ComponentSettings< AuthenticationSettings > OpenTap.ValidatingObject OpenTap.IComponentSettings OpenTap.IValidatingObject OpenTap.ITapPlugin

Public Member Functions

HttpClient GetClient (string domain=null, bool withRetryPolicy=false, string baseAddress=null)
 Get a HttpClient with a preconfigued BaseAddress and preconfigured authentication using a Bearer token from Tokens. It is up to the caller of this method to control the lifetime of the HttpClient More...
 
- Public Member Functions inherited from OpenTap.ComponentSettings< AuthenticationSettings >
void Save ()
 Saves the settings held by this class to an XML file in the ComponentSettings.SetSettingsProfile(string, string).
 
void Invalidate ()
 Invalidates the cache of this type of component setting.
 
void Reload ()
 Forces the reload of this type of component setting from the XML file the next time the setting is used.
 
virtual void Initialize ()
 Called if a new ComponentSettings is instantiated and there are no corresponding settings XML.
 
- Public Member Functions inherited from OpenTap.ValidatingObject
void OnPropertyChanged (string propertyName)
 Triggers the PropertyChanged event. More...
 

Properties

IList< TokenInfoTokens = new List<TokenInfo>() [getset]
 Token store containing access and refresh tokens. These tokens are used in the HttpClients returned by GetClient to authenticate requests.
 
string BaseAddress [getset]
 A well formed absolute URL used as as BaseAddress in HttpClients returned by GetClient. This setting determines what relative URLs (e.g. a package repository URL) are relative to. Can be null.
 
- Properties inherited from OpenTap.ComponentSettings< AuthenticationSettings >
static T Current [get]
 Get the currently loaded ComponentSettings instance for this class.
 
string? GroupName [get]
 Settings group of this settings class.
 
static string SettingsDirectoryRoot [getset]
 Where settings files are located. Usually this is at "[Executable location]\Settings", but it can be set to different locations. Setting this will invalidate loaded settings.
 
- Properties inherited from OpenTap.ValidatingObject
ValidationRuleCollection Rules [get]
 All the validation rules. Add new rules to this in order to get runtime value validation.
 
string Error [get]
 Gets the error messages for each invalid rule and joins them with a newline.
 
- Properties inherited from OpenTap.IValidatingObject
ValidationRuleCollection Rules [get]
 A collection of all the currently defined validation rules. Add new rules here in order to get runtime value validation.
 

Additional Inherited Members

- Static Public Member Functions inherited from OpenTap.ComponentSettings< AuthenticationSettings >
static ComponentSettings GetCurrent (Type settingsType)
 Gets current settings for a specified component. This is either an instance of the settings class previously loaded, or a new instance loaded from the associated file. More...
 
static ComponentSettings GetCurrent (ITypeData settingsType)
 Gets current settings for a specified component. This is either an instance of the settings class previously loaded, or a new instance loaded from the associated file. More...
 
static string GetSettingsDirectory (string groupName, bool isProfile=true)
 The directory where the settings are loaded from / saved to. More...
 
static void EnsureSettingsDirectoryExists (string groupName, bool isProfile=true)
 Ensures that the Settings directory exists and that the specified groupName sub directory exists. This might throw an exception if the settings directory was configured to something invalid. Like 'AUX', 'NUL', .... More...
 
static void SetSettingsProfile (string groupName, string profileName)
 Sets the directory in which settings groups are loaded from / saved to. More...
 
static void SaveAllCurrentSettings ()
 Saves all ComponentSettings objects that have been loaded.
 
static string GetSaveFilePath (Type type)
 Gets the current file location where a ComponentSettings type is saved. More...
 
static void SetCurrent (Stream xmlFileStream)
 Sets current settings for a component setting based on a stream of the file contents of a ComponentSettings XML file. More...
 
static void SetCurrent (Stream xmlFileStream, out IEnumerable< XmlError > errors)
 Sets current settings for a component setting based on a stream of the file contents of a ComponentSettings XML file. More...
 
static ComponentSettings GetCurrentFromCache (Type settingsType)
 Gets current settings for a specified component from cache. More...
 
- Static Public Attributes inherited from OpenTap.ComponentSettings< AuthenticationSettings >
static bool PersistSettingGroups
 Gets or sets if settings groups should be persisted between processes.
 
- Protected Member Functions inherited from OpenTap.ValidatingObject
virtual string GetError (string propertyName=null)
 Return the error for a given property
 
void ThrowOnValidationError (bool ignoreDisabledProperties)
 Checks all validation rules on this object (Rules) and throws an AggregateException on errors. More...
 
- Events inherited from OpenTap.ComponentSettings< AuthenticationSettings >
EventHandler CacheInvalidated
 Invokes when the cache for this settings item is invalidated for this item. The way to handle it is usually to fetch the new instance using ComponentSettings.GetCurrent(sender.GetType()).
 
- Events inherited from OpenTap.ValidatingObject
PropertyChangedEventHandler PropertyChanged
 Standard PropertyChanged event object.
 

Detailed Description

This class stores information about the logged in client.

Member Function Documentation

◆ GetClient()

HttpClient OpenTap.Authentication.AuthenticationSettings.GetClient ( string  domain = null,
bool  withRetryPolicy = false,
string  baseAddress = null 
)
inline

Get a HttpClient with a preconfigued BaseAddress and preconfigured authentication using a Bearer token from Tokens. It is up to the caller of this method to control the lifetime of the HttpClient

Parameters
domainThis value is compared to TokenInfo.Domain to find the token from Tokens to use as Bearer token for requests. If unspecified, the host part of the request URI is used.
withRetryPolicyIf the request should be retried in case of transient errors.
baseAddressThe base address used in the returned client. A relative URL given here will be relative to BaseAddress. Default is BaseAddress.
Returns
A preconfigued HttpClient object

OpenTAP 9.27 API built Wed Jan 8 2025 13:53:59