本文整理汇总了C#中OperationRequest.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# OperationRequest.ToString方法的具体用法?C# OperationRequest.ToString怎么用?C# OperationRequest.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OperationRequest
的用法示例。
在下文中一共展示了OperationRequest.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleAuthenticate
public OperationResponse HandleAuthenticate(OperationRequest operationRequest, SendParameters sendParameters)
{
// validate operation request
var authenticateRequest = new AuthenticateRequest(this.Protocol, operationRequest);
if (authenticateRequest.IsValid == false)
{
return OperationHandlerBase.HandleInvalidOperation(authenticateRequest, log);
}
if (log.IsDebugEnabled)
{
log.DebugFormat(
"HandleAuthenticateRequest:appId={0};version={1};region={2};type={3};userId={4}",
authenticateRequest.ApplicationId,
authenticateRequest.ApplicationVersion,
authenticateRequest.Region,
authenticateRequest.ClientAuthenticationType,
authenticateRequest.UserId);
}
if (authenticateRequest.ClientAuthenticationType == 255 || !string.IsNullOrEmpty(authenticateRequest.Token))
{
var response = this.HandleAuthenticateTokenRequest(authenticateRequest);
if (log.IsDebugEnabled)
{
log.DebugFormat("HandleAuthenticateRequest - Token Authentication done. Result: {0}; msg={1}", response.ReturnCode, response.DebugMessage);
}
if (response.ReturnCode == 0)
{
this.SetCurrentOperationHandler(OperationHandlerDefault.Instance);
this.OnAuthSuccess(authenticateRequest);
}
return response;
}
// if authentication data is used it must be either a byte array or a string value
if (authenticateRequest.ClientAuthenticationData != null)
{
var dataType = authenticateRequest.ClientAuthenticationData.GetType();
if (dataType != typeof(byte[]) && dataType != typeof(string))
{
if (log.IsDebugEnabled)
{
log.DebugFormat("HandleAuthenticateRequest - invalid type for auth data (datatype = {0}), request: {1}", dataType, operationRequest.ToString());
}
return new OperationResponse
{
OperationCode = operationRequest.OperationCode,
ReturnCode = (short)ErrorCode.OperationInvalid,
DebugMessage = ErrorMessages.InvalidTypeForAuthData
};
}
}
var app = (MasterApplication)ApplicationBase.Instance;
// check if custom client authentication is required
if (app.CustomAuthHandler.IsClientAuthenticationEnabled)
{
if (app.TokenCreator == null)
{
log.WarnFormat("No custom authentication supported: AuthTokenKey not specified in config.");
var response = new OperationResponse(authenticateRequest.OperationRequest.OperationCode)
{
ReturnCode = (short)ErrorCode.InvalidAuthentication,
DebugMessage = ErrorMessages.AuthTokenTypeNotSupported
};
return response;
}
this.SetCurrentOperationHandler(OperationHandlerAuthenticating.Instance);
var authSettings = new AuthSettings
{
IsAnonymousAccessAllowed = app.CustomAuthHandler.IsAnonymousAccessAllowed,
};
app.CustomAuthHandler.AuthenticateClient(this, authenticateRequest, authSettings, new SendParameters(), authSettings);
return null;
}
// TBD: centralizing setting of userid
this.UserId = authenticateRequest.UserId;
// apply application to the peer
this.SetCurrentOperationHandler(OperationHandlerDefault.Instance);
this.OnAuthSuccess(authenticateRequest);
// publish operation response
return new OperationResponse(operationRequest.OperationCode);
}