当前位置: 首页>>代码示例>>C#>>正文


C# RequestContext.CreateResponse方法代码示例

本文整理汇总了C#中RequestContext.CreateResponse方法的典型用法代码示例。如果您正苦于以下问题:C# RequestContext.CreateResponse方法的具体用法?C# RequestContext.CreateResponse怎么用?C# RequestContext.CreateResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RequestContext的用法示例。


在下文中一共展示了RequestContext.CreateResponse方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Authenticate

        public override void Authenticate(RequestContext<AuthenticateRequest, AuthenticateResponse> requestContext)
        {
            PeerCred credentials = new PeerCred(((UnixSocketConnection)ServerContext.Connection).UnixSocket);

            if(credentials == null)
            {
                AuthenticateResponse response = requestContext.CreateResponse();
                response.Succeeded = false;
                response.CustomErrorMessage = "Could not retrieve credentials from requesting client!";
                response.Execute();
            }
            else
            {
                ServerContext.ServerAuthenticationContext.AuthenticatedPermissionMember =
                    new ExternalUser(credentials.UserID.ToString(), credentials.GroupID.ToString());

                AuthenticateResponse response = requestContext.CreateResponse();
                response.Succeeded = true;
                response.Execute();
            }
        }
开发者ID:deveck,项目名称:doTSS,代码行数:21,代码来源:UnixSocketAuthentication.cs

示例2: Authenticate

        public override void Authenticate(RequestContext<AuthenticateRequest, AuthenticateResponse> requestContext)
        {
            string remoteUser = ((NamedPipeServerStream)((NamedPipeConnection)requestContext.Context.Connection).PipeStream).GetImpersonationUserName();

            if (remoteUser == null)
            {
                AuthenticateResponse response = requestContext.CreateResponse();
                response.Succeeded = false;
                response.CustomErrorMessage = "Could not retrieve credentials from requesting client!";
                response.Execute();
            }
            else
            {
                ServerContext.ServerAuthenticationContext.AuthenticatedPermissionMember =
                    new ExternalUser(remoteUser, null);

                AuthenticateResponse response = requestContext.CreateResponse();
                response.Succeeded = true;
                response.Execute();
            }
        }
开发者ID:deveck,项目名称:doTSS,代码行数:21,代码来源:NamedPipeAuthentication.cs

示例3: Authenticate

        public override void Authenticate(RequestContext<AuthenticateRequest, AuthenticateResponse> requestContext)
        {
            foreach(User user in ServerContext.AccessControlList.Users)
            {
                if(user.Id == _user && user.IdType == IdTypeEnum.User)
                {
                    ServerContext.ServerAuthenticationContext.AuthenticatedPermissionMember = user;

                    AuthenticateResponse response = requestContext.CreateResponse();
                    response.Succeeded = true;
                    response.Execute();
                    return;
                }
            }

            AuthenticateResponse errorResponse = requestContext.CreateResponse();
            errorResponse.Succeeded = false;
            errorResponse.CustomErrorMessage = "Could not retrieve credentials from requesting client!";
            errorResponse.Execute();
        }
开发者ID:deveck,项目名称:doTSS,代码行数:20,代码来源:DummyAuthentication.cs

示例4: Authenticate

        public override void Authenticate(RequestContext<AuthenticateRequest, AuthenticateResponse> requestContext)
        {
            SslConnection connection = _context.Connection as SslConnection;

            X509Certificate cert = connection.ClientCertificate;
            string certHashString = cert.GetCertHashString();

            foreach(User user in ServerContext.AccessControlList.Users)
            {
                SslAuthenticationParameters auth = (SslAuthenticationParameters)user.GetAuthentication("ssl_auth");

                if(auth != null && auth.CertificateHash.Equals(certHashString))
                {
                    ServerContext.ServerAuthenticationContext.AuthenticatedPermissionMember = user;

                    AuthenticateResponse response = requestContext.CreateResponse();
                    response.Succeeded = true;
                    response.Execute();
                    return;
                }
            }

            _log.WarnFormat("Could not find user associated with certificate '{0}'", certHashString);

            AuthenticateResponse errorResponse = requestContext.CreateResponse();
            errorResponse.Succeeded = false;
            errorResponse.CustomErrorMessage = "No client associated with specified certificate!";
            errorResponse.Execute();
        }
开发者ID:deveck,项目名称:doTSS,代码行数:29,代码来源:SslAuthentication.cs


注:本文中的RequestContext.CreateResponse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。