本文整理汇总了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();
}
}
示例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();
}
}
示例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();
}
示例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();
}