Class AppPrincipalFactory
Creates an AppPrincipal on the client side. A token is requested from the ITokenProvider designated by the ProviderId key of the settings, its claims
(and the ones given by the registered IClaimsFiller) are added to an identity and cached; the authorization and profile are then built from the claims.
Without network, the principal is built from the cached claims. The principal is set in the IApplicationContext.
[Export(typeof(IAppPrincipalFactory))]
public class AppPrincipalFactory : IAppPrincipalFactory
- Inheritance
-
AppPrincipalFactory
- Implements
- Inherited Members
Constructors
AppPrincipalFactory(IServiceProvider, INetworkInformation, ISecureCache, ICacheKeyGenerator, IApplicationContext, ILogger<AppPrincipalFactory>)
Creates an AppPrincipal on the client side. A token is requested from the ITokenProvider designated by the ProviderId key of the settings, its claims
(and the ones given by the registered IClaimsFiller) are added to an identity and cached; the authorization and profile are then built from the claims.
Without network, the principal is built from the cached claims. The principal is set in the IApplicationContext.
public AppPrincipalFactory(IServiceProvider container, INetworkInformation networkInformation, ISecureCache claimsCache, ICacheKeyGenerator cacheKeyGenerator, IApplicationContext applicationContext, ILogger<AppPrincipalFactory> logger)
Parameters
containerIServiceProviderThe service provider used to resolve the token providers and the claim fillers.
networkInformationINetworkInformationThe network status.
claimsCacheISecureCacheThe secure cache in which the claims are kept.
cacheKeyGeneratorICacheKeyGeneratorThe generator of the cache key of the claims.
applicationContextIApplicationContextThe application context that receives the principal.
loggerILogger<AppPrincipalFactory>The logger.
Fields
PlatformParameters
The name (platformParameters) of the platform specific parameters.
public const string PlatformParameters = "platformParameters"
Field Value
Methods
CreatePrincipalAsync(IKeyValueSettings, object?)
Creates the principal with the given settings.
public Task<Result<AppPrincipal>> CreatePrincipalAsync(IKeyValueSettings settings, object? parameter = null)
Parameters
settingsIKeyValueSettingsThe settings, which must contain the
ProviderIdkey.parameterobjectOptional parameter forwarded to the token provider.
Returns
- Task<Result<AppPrincipal>>
The principal, or a failed result when the principal cannot be built.
Exceptions
- ArgumentNullException
settingsis null.
CreatePrincipalAsync(object?)
Creates the principal with the settings named OAuth2.
public Task<Result<AppPrincipal>> CreatePrincipalAsync(object? parameter = null)
Parameters
parameterobjectOptional parameter forwarded to the token provider.
Returns
- Task<Result<AppPrincipal>>
The principal, or a failed result.
CreatePrincipalAsync(string, object?)
Creates the principal with the named settings.
public Task<Result<AppPrincipal>> CreatePrincipalAsync(string settingsResolveName, object? parameter = null)
Parameters
settingsResolveNamestringThe name of the SimpleKeyValueSettings options holding the settings.
parameterobjectOptional parameter forwarded to the token provider.
Returns
- Task<Result<AppPrincipal>>
The principal, or a failed result when the settings do not exist or the principal cannot be built.
SignOutUserAsync(IKeyValueSettings, CancellationToken)
Removes the cached claims and signs the user out of every token provider that holds a user session (ISignOutTokenProvider),
giving them settings. An exception thrown by a token provider is logged and not rethrown.
public ValueTask SignOutUserAsync(IKeyValueSettings settings, CancellationToken cancellationToken)
Parameters
settingsIKeyValueSettingsThe settings given to the token providers.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- ValueTask
A task that completes when the user is signed out.
Exceptions
- ArgumentNullException
settingsis null.
SignOutUserAsync(CancellationToken)
Signs the user out with the settings named OAuth2, or with empty settings when they do not exist.
public ValueTask SignOutUserAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- ValueTask
A task that completes when the user is signed out.