internal IPrincipal?GetThreadPrincipal() { IPrincipal?principal = _defaultPrincipal; if (principal == null) { switch (_principalPolicy) { case PrincipalPolicy.UnauthenticatedPrincipal: if (s_getUnauthenticatedPrincipal == null) { Type type = Type.GetType("System.Security.Principal.GenericPrincipal, System.Security.Claims", throwOnError: true) !; MethodInfo?mi = type.GetMethod("GetDefaultInstance", BindingFlags.NonPublic | BindingFlags.Static); Debug.Assert(mi != null); // Don't throw PNSE if null like for WindowsPrincipal as UnauthenticatedPrincipal should // be available on all platforms. Volatile.Write(ref s_getUnauthenticatedPrincipal, (Func <IPrincipal>)mi.CreateDelegate(typeof(Func <IPrincipal>))); } principal = s_getUnauthenticatedPrincipal !(); // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/26761 break; case PrincipalPolicy.WindowsPrincipal: if (s_getWindowsPrincipal == null) { Type type = Type.GetType("System.Security.Principal.WindowsPrincipal, System.Security.Principal.Windows", throwOnError: true) !; MethodInfo?mi = type.GetMethod("GetDefaultInstance", BindingFlags.NonPublic | BindingFlags.Static); if (mi == null) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_Principal); } Volatile.Write(ref s_getWindowsPrincipal, (Func <IPrincipal>)mi.CreateDelegate(typeof(Func <IPrincipal>))); } principal = s_getWindowsPrincipal !(); // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/26761 break; } } return(principal); }
public static async Task <ApplicationScope <T1, T2> > CreateScopeAsync <T1, T2>(this ApplicationInstance application, IPrincipal?principal = null) where T1 : notnull where T2 : notnull { var scope = await application.CreateScopeInternalAsync(); return(new ApplicationScope <T1, T2>(application, scope, principal: principal)); }
internal ApplicationScope(ApplicationInstance application, IServiceScope scope, IPrincipal?principal = null) : base(application, scope, principal: principal) { Service1 = scope.ServiceProvider.GetRequiredService <T1>(); }
public AuditInterceptor(IPrincipal?principal) { _principal = principal; }
public void Write(LogMessageSeverity severity, string system, IMessageSourceProvider messageSource, IPrincipal?user, JavaScriptException?jsException, LogWriteMode mode, string detailsBlock, string?category, string?caption, string?description, object[]?parameters) { Log.Write(severity, system, messageSource, user, jsException, mode, detailsBlock, category, caption, description, parameters); }
private async Task RunClientAsync(IDuplexPipe pipe, LightweightRpcEndPoint endPoint, IPrincipal?user) { var client = new ClientPipeline(pipe, this, endPoint, user, this.MaxRequestSize, this.MaxResponseSize, this.KeepSizeLimitedConnectionAlive); try { try { this.AddClient(client); await client.RunAsync().ContextFree(); } finally { await client.DisposeAsync().ContextFree(); } } finally { // Late removal of client (after dispose and wait) to avoid that shut down returns // before all clients have ended. Make sure that a client is not accidentally used // after dispose. this.RemoveClient(client); } }
protected PrincipalCommandBase(IPrincipal?principal) { Principal = principal; ActivatedBy = principal?.Identity?.Name; Activated = DateTimeOffset.UtcNow; }
public async Task <ApplicationScope> CreateScopeAsync(IPrincipal?principal = null) { var scope = await CreateScopeInternalAsync(); return(new ApplicationScope(this, scope, principal: principal)); }
protected CacheableQueryBase(IPrincipal?principal) : base(principal) { }
public EntityCreateCommand(IPrincipal?principal, [NotNull] TCreateModel model) : base(principal, model) { }
public EntityPagedQuery(IPrincipal?principal, EntityQuery?query) : base(principal) { Query = query ?? new EntityQuery(); }
internal ClientConnection(IDuplexPipe transport, EndPoint remoteEndPoint, IPrincipal?user) { this.Transport = transport; this.RemoteEndPoint = remoteEndPoint; this.User = user; }
public EntityDeleteCommand(IPrincipal?principal, [NotNull] TKey id) : base(principal, id) { }
public static async Task <ApplicationScope <T1, T2, T3, T4, T5, T6, T7, T8, T9> > CreateScopeAsync <T1, T2, T3, T4, T5, T6, T7, T8, T9>(this ApplicationInstance application, IPrincipal?principal = null) where T1 : notnull where T2 : notnull where T3 : notnull where T4 : notnull where T5 : notnull where T6 : notnull where T7 : notnull where T8 : notnull where T9 : notnull { var scope = await application.CreateScopeInternalAsync(); return(new ApplicationScope <T1, T2, T3, T4, T5, T6, T7, T8, T9>(application, scope, principal: principal)); }
public void NotifyAccountUnlocked(IPrincipal?currentUser, string userId) => Notify(currentUser, (currentUserId, ip) => new UserUnlockedNotification(ip, userId, currentUserId) );
/// <summary> /// 返回主体是否被验证 /// </summary> /// <param name="principal">待检查验证状态的主体, /// 如果为<see langword="null"/>,则直接返回<see langword="false"/></param> /// <returns></returns> public static bool IsAuthenticated([NotNullWhen(true)] this IPrincipal?principal) => principal is {
public void NotifyLoginFailed(IPrincipal?currentUser, string userId) => Notify(currentUser, (currentUserId, ip) => new UserLoginFailedNotification(ip, userId, currentUserId) );
public EntityPatchCommand(IPrincipal?principal, [NotNull] TKey id, [NotNull] IJsonPatchDocument patch) : base(principal, id) { Patch = patch ?? throw new ArgumentNullException(nameof(patch)); }
public void NotifyPasswordReset(IPrincipal?currentUser, string userId) => Notify(currentUser, (currentUserId, ip) => new UserPasswordResetNotification(ip, userId, currentUserId) );
protected PrincipalQueryBase(IPrincipal?principal) { Principal = principal; }
public void NotifyResetAccessFailedCount(IPrincipal?currentUser, string userId) => Notify(currentUser, (currentUserId, ip) => new UserResetAccessFailedCountNotification(ip, userId, currentUserId) );
public Task RunPipelineClientAsync(IDuplexPipe clientPipe, LightweightRpcEndPoint endPoint, IPrincipal?user) => this.server.RunClientAsync(clientPipe, endPoint, user);
internal ClientPipeline(IDuplexPipe pipe, LightweightRpcServer server, LightweightRpcEndPoint endPoint, IPrincipal?user, int?maxRequestSize, int?maxResponseSize, bool skipLargeFrames) : base(pipe, maxResponseSize, maxRequestSize, skipLargeFrames) { this.server = server; this.endPoint = endPoint; this.user = user; this.serializer = server.Serializer; }