C# Класс GSF.Security.UserDataCache

Represents a secured inter-process cache for a Dictionary{TKey,TValue} of serialized UserData.
This is a personal user data cache that only contains basic LDAP information for the user. It is used to load the local and Active Directory groups a user is associated with when the user no longer has access to its domain server. This can happen when a laptop that is normally connected to the Active Directory domain gets shutdown then restarted without access to the domain, for example, on an airplane - in this mode the user can successfully still login to the laptop to their using domain account cached by Windows but the groups the user is in will no longer be accessible. If role based security happens to be based on Active Directory groups, this cache will make sure the user can still have needed role based access even when the domain is unavailable. This cache is maintained as a separate user cache from the system level AdoSecurityCache since the user data cache only contains group information and is used by the LdapSecurityProvider which can be used independently of the AdoSecurityProvider.
Наследование: GSF.IO.InterprocessCache
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
GetCurrentCache ( int providerID ) : UserDataCache

Loads the UserDataCache for the current local user.

Save ( ) : void

Initiates inter-process synchronized save of user data cache.

SaveUserData ( string loginID, GSF.Security.UserData userData ) : void

Serializes the userData for the given loginID into the UserDataCache.

This will add an entry into the user data cache for loginID if it doesn't exist; otherwise existing entry will be updated.

Updates are automatically queued up for serialization so user does not need to call Save.

TryGetUserData ( string loginID, GSF.Security.UserData &userData ) : bool

Attempts to retrieve UserData for given loginID.

UserDataCache ( int providerID = LdapSecurityProvider.ProviderID ) : System

Creates a new instance of the UserDataCache.

UserDataCache ( int providerID, int maximumConcurrentLocks ) : System

Creates a new instance of the UserDataCache with the specified number of maximumConcurrentLocks.

this ( string loginID ) : GSF.Security.UserData

Gets or sets UserData for given loginID.

Защищенные методы

Метод Описание
HashLoginID ( string loginID ) : string

Calculates the hash of the loginID used as the key for the user data cache.

For added security, a hash of the loginID is used as the key for UserData in the user data cache instead of the actual loginID. This method allows the consumer to properly calculate this hash when directly using the user data cache.

LoadFileData ( FileStream fileStream ) : byte[]

Handles deserialization of file from disk; virtual method allows customization (e.g., pre-load decryption and/or data merge).

Consumers overriding this method should not directly call InterprocessCache.FileData property to avoid potential dead-locks.

SaveFileData ( FileStream fileStream, byte fileData ) : void

Handles serialization of file to disk; virtual method allows customization (e.g., pre-save encryption and/or data merge).

Consumers overriding this method should not directly call InterprocessCache.FileData property to avoid potential dead-locks.

Приватные методы

Метод Описание
DeserializeCache ( byte data ) : UserData>.Dictionary
SerializeCache ( UserData>.Dictionary cache ) : byte[]
WaitForDataReady ( ) : void

Описание методов

GetCurrentCache() публичный статический Метод

Loads the UserDataCache for the current local user.
public static GetCurrentCache ( int providerID ) : UserDataCache
providerID int Unique security provider ID used to distinguish cached user data that may be different based on provider.
Результат UserDataCache

HashLoginID() защищенный Метод

Calculates the hash of the loginID used as the key for the user data cache.
For added security, a hash of the loginID is used as the key for UserData in the user data cache instead of the actual loginID. This method allows the consumer to properly calculate this hash when directly using the user data cache.
protected HashLoginID ( string loginID ) : string
loginID string Login ID to hash.
Результат string

LoadFileData() защищенный Метод

Handles deserialization of file from disk; virtual method allows customization (e.g., pre-load decryption and/or data merge).
Consumers overriding this method should not directly call InterprocessCache.FileData property to avoid potential dead-locks.
protected LoadFileData ( FileStream fileStream ) : byte[]
fileStream System.IO.FileStream used to deserialize data.
Результат byte[]

Save() публичный Метод

Initiates inter-process synchronized save of user data cache.
public Save ( ) : void
Результат void

SaveFileData() защищенный Метод

Handles serialization of file to disk; virtual method allows customization (e.g., pre-save encryption and/or data merge).
Consumers overriding this method should not directly call InterprocessCache.FileData property to avoid potential dead-locks.
protected SaveFileData ( FileStream fileStream, byte fileData ) : void
fileStream System.IO.FileStream used to serialize data.
fileData byte File data to be serialized.
Результат void

SaveUserData() публичный Метод

Serializes the userData for the given loginID into the UserDataCache.

This will add an entry into the user data cache for loginID if it doesn't exist; otherwise existing entry will be updated.

Updates are automatically queued up for serialization so user does not need to call Save.

public SaveUserData ( string loginID, GSF.Security.UserData userData ) : void
loginID string Login ID of associated to retrieve.
userData GSF.Security.UserData Reference to object to serialize into .
Результат void

TryGetUserData() публичный Метод

Attempts to retrieve UserData for given loginID.
public TryGetUserData ( string loginID, GSF.Security.UserData &userData ) : bool
loginID string Login ID of associated to retrieve.
userData GSF.Security.UserData Reference to object to populate if found.
Результат bool

UserDataCache() публичный Метод

Creates a new instance of the UserDataCache.
public UserDataCache ( int providerID = LdapSecurityProvider.ProviderID ) : System
providerID int Unique provider ID used to distinguish cached user data that may be different based on provider.
Результат System

UserDataCache() публичный Метод

Creates a new instance of the UserDataCache with the specified number of maximumConcurrentLocks.
public UserDataCache ( int providerID, int maximumConcurrentLocks ) : System
providerID int Unique provider ID used to distinguish cached user data that may be different based on provider.
maximumConcurrentLocks int Maximum concurrent reader locks to allow.
Результат System

this() публичный Метод

Gets or sets UserData for given loginID.
public this ( string loginID ) : GSF.Security.UserData
loginID string Login ID of associated to load or save.
Результат GSF.Security.UserData