本文整理汇总了C#中IDirectedProtocolMessage类的典型用法代码示例。如果您正苦于以下问题:C# IDirectedProtocolMessage类的具体用法?C# IDirectedProtocolMessage怎么用?C# IDirectedProtocolMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDirectedProtocolMessage类属于命名空间,在下文中一共展示了IDirectedProtocolMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetNewResponseMessage
/// <summary>
/// Analyzes an incoming request message payload to discover what kind of
/// message is embedded in it and returns the type, or null if no match is found.
/// </summary>
/// <param name="request">
/// The message that was sent as a request that resulted in the response.
/// Null on a Consumer site that is receiving an indirect message from the Service Provider.
/// </param>
/// <param name="fields">The name/value pairs that make up the message payload.</param>
/// <returns>
/// A newly instantiated <see cref="IProtocolMessage"/>-derived object that this message can
/// deserialize to. Null if the request isn't recognized as a valid protocol message.
/// </returns>
/// <remarks>
/// The response messages are:
/// UnauthorizedTokenResponse
/// AuthorizedTokenResponse
/// </remarks>
public virtual IDirectResponseProtocolMessage GetNewResponseMessage(IDirectedProtocolMessage request, IDictionary<string, string> fields) {
MessageBase message = null;
// All response messages have the oauth_token field.
if (!fields.ContainsKey("oauth_token")) {
return null;
}
// All direct message responses should have the oauth_token_secret field.
if (!fields.ContainsKey("oauth_token_secret")) {
Logger.OAuth.Error("An OAuth message was expected to contain an oauth_token_secret but didn't.");
return null;
}
var unauthorizedTokenRequest = request as UnauthorizedTokenRequest;
var authorizedTokenRequest = request as AuthorizedTokenRequest;
if (unauthorizedTokenRequest != null) {
Protocol protocol = fields.ContainsKey("oauth_callback_confirmed") ? Protocol.V10a : Protocol.V10;
message = new UnauthorizedTokenResponse(unauthorizedTokenRequest, protocol.Version);
} else if (authorizedTokenRequest != null) {
message = new AuthorizedTokenResponse(authorizedTokenRequest);
} else {
Logger.OAuth.ErrorFormat("Unexpected response message given the request type {0}", request.GetType().Name);
throw new ProtocolException(OAuthStrings.InvalidIncomingMessage);
}
if (message != null) {
message.SetAsIncoming();
}
return message;
}
开发者ID:brivas,项目名称:DotNetOpenAuth,代码行数:50,代码来源:OAuthConsumerMessageFactory.cs
示例2: TryValidateAccessToken
/// <summary>
/// Reads an access token to find out what data it authorizes access to.
/// </summary>
/// <param name="message">The message carrying the access token.</param>
/// <param name="accessToken">The access token.</param>
/// <param name="user">The user whose data is accessible with this access token.</param>
/// <param name="scope">The scope of access authorized by this access token.</param>
/// <returns>
/// A value indicating whether this access token is valid.
/// </returns>
/// <remarks>
/// This method also responsible to throw a <see cref="ProtocolException"/> or return
/// <c>false</c> when the access token is expired, invalid, or from an untrusted authorization server.
/// </remarks>
public virtual bool TryValidateAccessToken(IDirectedProtocolMessage message, string accessToken, out string user, out HashSet<string> scope) {
var accessTokenFormatter = AccessToken.CreateFormatter(this.AuthorizationServerPublicSigningKey, this.ResourceServerPrivateEncryptionKey);
var token = accessTokenFormatter.Deserialize(message, accessToken);
user = token.User;
scope = new HashSet<string>(token.Scope, OAuthUtilities.ScopeStringComparer);
return true;
}
开发者ID:rafek,项目名称:dotnetopenid,代码行数:21,代码来源:StandardAccessTokenAnalyzer.cs
示例3: AutoResponsiveRequest
/// <summary>
/// Initializes a new instance of the <see cref="AutoResponsiveRequest"/> class.
/// </summary>
/// <param name="request">The request message.</param>
/// <param name="response">The response that is ready for transmittal.</param>
internal AutoResponsiveRequest(IDirectedProtocolMessage request, IProtocolMessage response)
: base(request)
{
ErrorUtilities.VerifyArgumentNotNull(response, "response");
this.response = response;
}
开发者ID:vrushalid,项目名称:dotnetopenid,代码行数:12,代码来源:AutoResponsiveRequest.cs
示例4: NotImplementedException
/// <summary>
/// Reads an access token to find out what data it authorizes access to.
/// </summary>
/// <param name="message">The message carrying the access token.</param>
/// <param name="accessToken">The access token.</param>
/// <param name="user">The user whose data is accessible with this access token.</param>
/// <param name="scope">The scope of access authorized by this access token.</param>
/// <returns>
/// A value indicating whether this access token is valid.
/// </returns>
bool IAccessTokenAnalyzer.TryValidateAccessToken(IDirectedProtocolMessage message, string accessToken, out string user, out HashSet<string> scope) {
Requires.NotNull(message, "message");
Requires.NotNullOrEmpty(accessToken, "accessToken");
Contract.Ensures(Contract.Result<bool>() == (Contract.ValueAtReturn<string>(out user) != null));
throw new NotImplementedException();
}
开发者ID:SachiraChin,项目名称:dotnetopenid,代码行数:17,代码来源:IAccessTokenAnalyzer.cs
示例5: AutoResponsiveRequest
/// <summary>
/// Initializes a new instance of the <see cref="AutoResponsiveRequest"/> class.
/// </summary>
/// <param name="request">The request message.</param>
/// <param name="response">The response that is ready for transmittal.</param>
/// <param name="securitySettings">The security settings.</param>
internal AutoResponsiveRequest(IDirectedProtocolMessage request, IProtocolMessage response, ProviderSecuritySettings securitySettings)
: base(request, securitySettings)
{
ErrorUtilities.VerifyArgumentNotNull(response, "response");
this.response = response;
}
开发者ID:jcp-xx,项目名称:dotnetopenid,代码行数:13,代码来源:AutoResponsiveRequest.cs
示例6: MessageBase
/// <summary>
/// Initializes a new instance of the <see cref="MessageBase"/> class for direct response messages.
/// </summary>
/// <param name="protectionRequired">The level of protection the message requires.</param>
/// <param name="originatingRequest">The request that asked for this direct response.</param>
protected MessageBase(MessageProtections protectionRequired, IDirectedProtocolMessage originatingRequest)
{
ErrorUtilities.VerifyArgumentNotNull(originatingRequest, "originatingRequest");
this.protectionRequired = protectionRequired;
this.transport = MessageTransport.Direct;
this.originatingRequest = originatingRequest;
}
开发者ID:vrushalid,项目名称:dotnetopenid,代码行数:13,代码来源:MessageBase.cs
示例7: MessageBase
/// <summary>
/// Initializes a new instance of the <see cref="MessageBase"/> class.
/// </summary>
/// <param name="request">The originating request.</param>
/// <param name="recipient">The recipient of the directed message. Null if not applicable.</param>
protected MessageBase(IDirectedProtocolMessage request, Uri recipient = null) {
Requires.NotNull(request, "request");
this.originatingRequest = request;
this.messageTransport = request.Transport;
this.version = request.Version;
this.Recipient = recipient;
this.HttpMethods = HttpDeliveryMethods.GetRequest;
}
开发者ID:hnlshzx,项目名称:DotNetOpenAuth,代码行数:13,代码来源:MessageBase.cs
示例8: MessageBase
/// <summary>
/// Initializes a new instance of the <see cref="MessageBase"/> class.
/// </summary>
/// <param name="request">The originating request.</param>
/// <param name="recipient">The recipient of the directed message. Null if not applicable.</param>
protected MessageBase(IDirectedProtocolMessage request, Uri recipient = null) {
Contract.Requires<ArgumentNullException>(request != null);
this.originatingRequest = request;
this.messageTransport = request.Transport;
this.version = request.Version;
this.Recipient = recipient;
this.HttpMethods = HttpDeliveryMethods.GetRequest;
}
开发者ID:enslam,项目名称:dotnetopenid,代码行数:13,代码来源:MessageBase.cs
示例9: MessageBase
/// <summary>
/// Initializes a new instance of the <see cref="MessageBase"/> class for direct response messages.
/// </summary>
/// <param name="protectionRequired">The level of protection the message requires.</param>
/// <param name="originatingRequest">The request that asked for this direct response.</param>
/// <param name="version">The OAuth version.</param>
protected MessageBase(MessageProtections protectionRequired, IDirectedProtocolMessage originatingRequest, Version version) {
Requires.NotNull(originatingRequest, "originatingRequest");
Requires.NotNull(version, "version");
this.protectionRequired = protectionRequired;
this.transport = MessageTransport.Direct;
this.originatingRequest = originatingRequest;
this.Version = version;
}
开发者ID:rafek,项目名称:dotnetopenid,代码行数:15,代码来源:MessageBase.cs
示例10: MessageBase
/// <summary>
/// Initializes a new instance of the <see cref="MessageBase"/> class for direct response messages.
/// </summary>
/// <param name="protectionRequired">The level of protection the message requires.</param>
/// <param name="originatingRequest">The request that asked for this direct response.</param>
/// <param name="version">The OAuth version.</param>
protected MessageBase(MessageProtections protectionRequired, IDirectedProtocolMessage originatingRequest, Version version) {
Contract.Requires<ArgumentNullException>(originatingRequest != null);
Contract.Requires<ArgumentNullException>(version != null);
this.protectionRequired = protectionRequired;
this.transport = MessageTransport.Direct;
this.originatingRequest = originatingRequest;
this.Version = version;
}
开发者ID:jongalloway,项目名称:dotnetopenid,代码行数:15,代码来源:MessageBase.cs
示例11: CreateHttpRequest
/// <summary>
/// Prepares an HTTP request that carries a given message.
/// </summary>
/// <param name="request">The message to send.</param>
/// <returns>
/// The <see cref="HttpWebRequest"/> prepared to send the request.
/// </returns>
/// <remarks>
/// This method must be overridden by a derived class, unless the <see cref="Channel.RequestCore"/> method
/// is overridden and does not require this method.
/// </remarks>
protected override HttpWebRequest CreateHttpRequest(IDirectedProtocolMessage request) {
HttpWebRequest httpRequest;
if ((request.HttpMethods & HttpDeliveryMethods.GetRequest) != 0) {
httpRequest = InitializeRequestAsGet(request);
} else if ((request.HttpMethods & HttpDeliveryMethods.PostRequest) != 0) {
httpRequest = InitializeRequestAsPost(request);
} else {
throw new NotSupportedException();
}
return httpRequest;
}
开发者ID:rafek,项目名称:dotnetopenid,代码行数:23,代码来源:OAuth2ClientChannel.cs
示例12: DeserializeAccessToken
/// <summary>
/// Reads an access token to find out what data it authorizes access to.
/// </summary>
/// <param name="message">The message carrying the access token.</param>
/// <param name="accessToken">The access token's serialized representation.</param>
/// <returns>The deserialized, validated token.</returns>
/// <exception cref="ProtocolException">Thrown if the access token is expired, invalid, or from an untrusted authorization server.</exception>
public virtual AccessToken DeserializeAccessToken(IDirectedProtocolMessage message, string accessToken) {
ErrorUtilities.VerifyProtocol(!string.IsNullOrEmpty(accessToken), ResourceServerStrings.MissingAccessToken);
var accessTokenFormatter = AccessToken.CreateFormatter(this.AuthorizationServerPublicSigningKey, this.ResourceServerPrivateEncryptionKey);
var token = new AccessToken();
try {
accessTokenFormatter.Deserialize(token, accessToken, message, Protocol.access_token);
} catch (IOException ex) {
throw new ProtocolException(ResourceServerStrings.InvalidAccessToken, ex);
}
return token;
}
开发者ID:brivas,项目名称:DotNetOpenAuth,代码行数:19,代码来源:StandardAccessTokenAnalyzer.cs
示例13: GetNewResponseMessage
/// <summary>
/// Analyzes an incoming request message payload to discover what kind of
/// message is embedded in it and returns the type, or null if no match is found.
/// </summary>
/// <param name="request">The message that was sent as a request that resulted in the response.</param>
/// <param name="fields">The name/value pairs that make up the message payload.</param>
/// <returns>
/// A newly instantiated <see cref="IProtocolMessage"/>-derived object that this message can
/// deserialize to. Null if the request isn't recognized as a valid protocol message.
/// </returns>
public IDirectResponseProtocolMessage GetNewResponseMessage(IDirectedProtocolMessage request, IDictionary<string, string> fields) {
DirectResponseBase message = null;
// Discern the OpenID version of the message.
Protocol protocol = Protocol.V11;
string ns;
if (fields.TryGetValue(Protocol.V20.openidnp.ns, out ns)) {
ErrorUtilities.VerifyProtocol(string.Equals(ns, Protocol.OpenId2Namespace, StringComparison.Ordinal), MessagingStrings.UnexpectedMessagePartValue, Protocol.V20.openidnp.ns, ns);
protocol = Protocol.V20;
}
// Handle error messages generally.
if (fields.ContainsKey(protocol.openidnp.error)) {
message = new DirectErrorResponse(protocol.Version, request);
}
var associateRequest = request as AssociateRequest;
if (associateRequest != null) {
if (protocol.Version.Major >= 2 && fields.ContainsKey(protocol.openidnp.error_code)) {
// This is a special recognized error case that we create a special message for.
message = new AssociateUnsuccessfulResponse(protocol.Version, associateRequest);
} else if (message == null) {
if (OpenIdUtilities.IsDiffieHellmanPresent) {
var associateDiffieHellmanRequest = request as AssociateDiffieHellmanRequest;
if (associateDiffieHellmanRequest != null) {
message = new AssociateDiffieHellmanRelyingPartyResponse(protocol.Version, associateDiffieHellmanRequest);
}
}
var associateUnencryptedRequest = request as AssociateUnencryptedRequest;
if (associateUnencryptedRequest != null) {
message = new AssociateUnencryptedResponseRelyingParty(protocol.Version, associateUnencryptedRequest);
}
}
}
var checkAuthenticationRequest = request as CheckAuthenticationRequest;
if (checkAuthenticationRequest != null && message == null) {
message = new CheckAuthenticationResponse(protocol.Version, checkAuthenticationRequest);
}
if (message != null) {
message.SetAsIncoming();
}
return message;
}
开发者ID:hnlshzx,项目名称:DotNetOpenAuth,代码行数:57,代码来源:OpenIdRelyingPartyMessageFactory.cs
示例14: NotImplementedException
/// <summary>
/// Analyzes an incoming request message payload to discover what kind of
/// message is embedded in it and returns the type, or null if no match is found.
/// </summary>
/// <param name="request">The message that was sent as a request that resulted in the response.</param>
/// <param name="fields">The name/value pairs that make up the message payload.</param>
/// <returns>
/// A newly instantiated <see cref="IProtocolMessage"/>-derived object that this message can
/// deserialize to. Null if the request isn't recognized as a valid protocol message.
/// </returns>
IDirectResponseProtocolMessage IMessageFactory.GetNewResponseMessage(IDirectedProtocolMessage request, IDictionary<string, string> fields) {
Requires.NotNull(request, "request");
Requires.NotNull(fields, "fields");
throw new NotImplementedException();
}
开发者ID:437072341,项目名称:dotnetopenid,代码行数:15,代码来源:IMessageFactory.cs
示例15: CreateHttpRequest
protected override HttpWebRequest CreateHttpRequest(IDirectedProtocolMessage request) {
throw new NotImplementedException("CreateHttpRequest");
}
开发者ID:437072341,项目名称:dotnetopenid,代码行数:3,代码来源:TestChannel.cs
示例16: ProcessUserAuthorization
/// <summary>
/// Scans the incoming request for an authorization response message.
/// </summary>
/// <param name="authorizationState">The authorization.</param>
/// <param name="response">The incoming authorization response message.</param>
/// <returns>
/// The granted authorization, or <c>null</c> if the incoming HTTP request did not contain an authorization server response or authorization was rejected.
/// </returns>
internal IAuthorizationState ProcessUserAuthorization(IAuthorizationState authorizationState, IDirectedProtocolMessage response) {
Requires.NotNull(authorizationState, "authorizationState");
Requires.NotNull(response, "response");
EndUserAuthorizationSuccessAccessTokenResponse accessTokenSuccess;
EndUserAuthorizationSuccessAuthCodeResponse authCodeSuccess;
if ((accessTokenSuccess = response as EndUserAuthorizationSuccessAccessTokenResponse) != null) {
UpdateAuthorizationWithResponse(authorizationState, accessTokenSuccess);
} else if ((authCodeSuccess = response as EndUserAuthorizationSuccessAuthCodeResponse) != null) {
this.UpdateAuthorizationWithResponse(authorizationState, authCodeSuccess);
} else if (response is EndUserAuthorizationFailedResponse) {
authorizationState.Delete();
return null;
}
return authorizationState;
}
开发者ID:437072341,项目名称:dotnetopenid,代码行数:25,代码来源:UserAgentClient.cs
示例17: CreateHttpRequest
/// <summary>
/// Prepares an HTTP request that carries a given message.
/// </summary>
/// <param name="request">The message to send.</param>
/// <returns>
/// The <see cref="HttpRequest"/> prepared to send the request.
/// </returns>
protected override HttpWebRequest CreateHttpRequest(IDirectedProtocolMessage request) {
HttpWebRequest httpRequest;
HttpDeliveryMethods transmissionMethod = request.HttpMethods;
if ((transmissionMethod & HttpDeliveryMethods.AuthorizationHeaderRequest) != 0) {
httpRequest = this.InitializeRequestAsAuthHeader(request);
} else if ((transmissionMethod & HttpDeliveryMethods.PostRequest) != 0) {
var requestMessageWithBinaryData = request as IMessageWithBinaryData;
ErrorUtilities.VerifyProtocol(requestMessageWithBinaryData == null || !requestMessageWithBinaryData.SendAsMultipart, OAuthStrings.MultipartPostMustBeUsedWithAuthHeader);
httpRequest = this.InitializeRequestAsPost(request);
} else if ((transmissionMethod & HttpDeliveryMethods.GetRequest) != 0) {
httpRequest = InitializeRequestAsGet(request);
} else if ((transmissionMethod & HttpDeliveryMethods.HeadRequest) != 0) {
httpRequest = InitializeRequestAsHead(request);
} else if ((transmissionMethod & HttpDeliveryMethods.PutRequest) != 0) {
httpRequest = this.InitializeRequestAsPut(request);
} else if ((transmissionMethod & HttpDeliveryMethods.DeleteRequest) != 0) {
httpRequest = InitializeRequestAsDelete(request);
} else {
throw new NotSupportedException();
}
return httpRequest;
}
开发者ID:fvaca,项目名称:dotnetopenid,代码行数:30,代码来源:OAuthChannel.cs
示例18: GetErrorResponse
/// <summary>
/// Prepares the return value for the GetRequest method in the event of an exception.
/// </summary>
/// <param name="ex">The exception that forms the basis of the error response. Must not be null.</param>
/// <param name="httpRequestInfo">The incoming HTTP request. Must not be null.</param>
/// <param name="incomingMessage">The incoming message. May be null in the case that it was malformed.</param>
/// <returns>
/// Either the <see cref="IRequest"/> to return to the host site or null to indicate no response could be reasonably created and that the caller should rethrow the exception.
/// </returns>
private IRequest GetErrorResponse(ProtocolException ex, HttpRequestInfo httpRequestInfo, IDirectedProtocolMessage incomingMessage) {
Contract.Requires<ArgumentNullException>(ex != null);
Contract.Requires<ArgumentNullException>(httpRequestInfo != null);
Logger.OpenId.Error("An exception was generated while processing an incoming OpenID request.", ex);
IErrorMessage errorMessage;
// We must create the appropriate error message type (direct vs. indirect)
// based on what we see in the request.
string returnTo = httpRequestInfo.QueryString[Protocol.Default.openid.return_to];
if (returnTo != null) {
// An indirect request message from the RP
// We need to return an indirect response error message so the RP can consume it.
// Consistent with OpenID 2.0 section 5.2.3.
var indirectRequest = incomingMessage as SignedResponseRequest;
if (indirectRequest != null) {
errorMessage = new IndirectErrorResponse(indirectRequest);
} else {
errorMessage = new IndirectErrorResponse(Protocol.Default.Version, new Uri(returnTo));
}
} else if (httpRequestInfo.HttpMethod == "POST") {
// A direct request message from the RP
// We need to return a direct response error message so the RP can consume it.
// Consistent with OpenID 2.0 section 5.1.2.2.
errorMessage = new DirectErrorResponse(Protocol.Default.Version, incomingMessage);
} else {
// This may be an indirect request from an RP that was so badly
// formed that we cannot even return an error to the RP.
// The best we can do is display an error to the user.
// Returning null cues the caller to "throw;"
return null;
}
errorMessage.ErrorMessage = ex.ToStringDescriptive();
// Allow host to log this error and issue a ticket #.
// We tear off the field to a local var for thread safety.
IErrorReporting hostErrorHandler = this.ErrorReporting;
if (hostErrorHandler != null) {
errorMessage.Contact = hostErrorHandler.Contact;
errorMessage.Reference = hostErrorHandler.LogError(ex);
}
if (incomingMessage != null) {
return new AutoResponsiveRequest(incomingMessage, errorMessage, this.SecuritySettings);
} else {
return new AutoResponsiveRequest(errorMessage, this.SecuritySettings);
}
}
开发者ID:jsmale,项目名称:dotnetopenid,代码行数:58,代码来源:OpenIdProvider.cs
示例19: DirectResponseBase
/// <summary>
/// Initializes a new instance of the <see cref="DirectResponseBase"/> class.
/// </summary>
/// <param name="responseVersion">The OpenID version of the response message.</param>
/// <param name="originatingRequest">The originating request. May be null in case the request is unrecognizable and this is an error response.</param>
protected DirectResponseBase(Version responseVersion, IDirectedProtocolMessage originatingRequest) {
Requires.NotNull(responseVersion, "responseVersion");
this.Version = responseVersion;
this.originatingRequest = originatingRequest;
}
开发者ID:437072341,项目名称:dotnetopenid,代码行数:11,代码来源:DirectResponseBase.cs
示例20: PrepareIndirectResponse
internal new void PrepareIndirectResponse(IDirectedProtocolMessage message) {
base.PrepareIndirectResponse(message);
}
开发者ID:rafek,项目名称:dotnetopenid,代码行数:3,代码来源:TestBadChannel.cs
注:本文中的IDirectedProtocolMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论