예제 #1
0
파일: AppDomain.cs 프로젝트: yuxi214/mono
        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);
        }
예제 #2
0
        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));
        }
예제 #3
0
 internal ApplicationScope(ApplicationInstance application, IServiceScope scope, IPrincipal?principal = null)
     : base(application, scope, principal: principal)
 {
     Service1 = scope.ServiceProvider.GetRequiredService <T1>();
 }
예제 #4
0
 public AuditInterceptor(IPrincipal?principal)
 {
     _principal = principal;
 }
예제 #5
0
 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;
 }
예제 #8
0
        public async Task <ApplicationScope> CreateScopeAsync(IPrincipal?principal = null)
        {
            var scope = await CreateScopeInternalAsync();

            return(new ApplicationScope(this, scope, principal: principal));
        }
예제 #9
0
 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;
 }
예제 #13
0
 public EntityDeleteCommand(IPrincipal?principal, [NotNull] TKey id) : base(principal, id)
 {
 }
예제 #14
0
        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));
        }
예제 #15
0
 public void NotifyAccountUnlocked(IPrincipal?currentUser, string userId) => Notify(currentUser,
                                                                                    (currentUserId, ip) => new UserUnlockedNotification(ip, userId, currentUserId)
                                                                                    );
예제 #16
0
 /// <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
 {
예제 #17
0
 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));
 }
예제 #19
0
 public void NotifyPasswordReset(IPrincipal?currentUser, string userId) => Notify(currentUser,
                                                                                  (currentUserId, ip) => new UserPasswordResetNotification(ip, userId, currentUserId)
                                                                                  );
예제 #20
0
 protected PrincipalQueryBase(IPrincipal?principal)
 {
     Principal = principal;
 }
예제 #21
0
 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);
예제 #23
0
 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;
 }