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


C# HttpRequestInfo.GetRecipient方法代码示例

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


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

示例1: ReadFromRequestCore

		/// <summary>
		/// Gets the protocol message that may be embedded in the given HTTP request.
		/// </summary>
		/// <param name="request">The request to search for an embedded message.</param>
		/// <returns>
		/// The deserialized message, if one is found.  Null otherwise.
		/// </returns>
		protected override IDirectedProtocolMessage ReadFromRequestCore(HttpRequestInfo request) {
			if (!string.IsNullOrEmpty(request.Url.Fragment)) {
				var fields = HttpUtility.ParseQueryString(request.Url.Fragment.Substring(1)).ToDictionary();

				MessageReceivingEndpoint recipient;
				try {
					recipient = request.GetRecipient();
				} catch (ArgumentException ex) {
					Logger.Messaging.WarnFormat("Unrecognized HTTP request: " + ex.ToString());
					return null;
				}

				return (IDirectedProtocolMessage)this.Receive(fields, recipient);
			}

			return base.ReadFromRequestCore(request);
		}
开发者ID:SachiraChin,项目名称:dotnetopenid,代码行数:24,代码来源:OAuth2AuthorizationServerChannel.cs

示例2: ReadFromRequestCore

		/// <summary>
		/// Gets the protocol message that may be embedded in the given HTTP request.
		/// </summary>
		/// <param name="request">The request to search for an embedded message.</param>
		/// <returns>
		/// The deserialized message, if one is found.  Null otherwise.
		/// </returns>
		protected override IDirectedProtocolMessage ReadFromRequestCore(HttpRequestInfo request) {
			var fields = new Dictionary<string, string>();
			string accessToken;
			if ((accessToken = SearchForBearerAccessTokenInRequest(request)) != null) {
				fields["token_type"] = Protocol.AccessTokenTypes.Bearer;
				fields["access_token"] = accessToken;
			}

			if (fields.Count > 0) {
				MessageReceivingEndpoint recipient;
				try {
					recipient = request.GetRecipient();
				} catch (ArgumentException ex) {
					Logger.OAuth.WarnFormat("Unrecognized HTTP request: " + ex.ToString());
					return null;
				}

				// Deserialize the message using all the data we've collected.
				var message = (IDirectedProtocolMessage)this.Receive(fields, recipient);
				return message;
			}

			return null;
		}
开发者ID:SachiraChin,项目名称:dotnetopenid,代码行数:31,代码来源:OAuth2ResourceServerChannel.cs

示例3: ReadFromRequestCore

		/// <summary>
		/// Gets the protocol message that may be embedded in the given HTTP request.
		/// </summary>
		/// <param name="request">The request to search for an embedded message.</param>
		/// <returns>
		/// The deserialized message, if one is found.  Null otherwise.
		/// </returns>
		protected override IDirectedProtocolMessage ReadFromRequestCore(HttpRequestInfo request) {
			Logger.Channel.DebugFormat("Incoming HTTP request: {0} {1}", request.HttpMethod, request.UrlBeforeRewriting.AbsoluteUri);

			var fields = request.QueryStringBeforeRewriting.ToDictionary();

			// Also read parameters from the fragment, if it's available.
			// Typically the fragment is not available because the browser doesn't send it to a web server
			// but this request may have been fabricated by an installed desktop app, in which case
			// the fragment is available.
			string fragment = request.UrlBeforeRewriting.Fragment;
			if (!string.IsNullOrEmpty(fragment)) {
				foreach (var pair in HttpUtility.ParseQueryString(fragment.Substring(1)).ToDictionary()) {
					fields.Add(pair.Key, pair.Value);
				}
			}

			MessageReceivingEndpoint recipient;
			try {
				recipient = request.GetRecipient();
			} catch (ArgumentException ex) {
				Logger.Messaging.WarnFormat("Unrecognized HTTP request: ", ex);
				return null;
			}

			return (IDirectedProtocolMessage)this.Receive(fields, recipient);
		}
开发者ID:rafek,项目名称:dotnetopenid,代码行数:33,代码来源:OAuth2ClientChannel.cs

示例4: ReadFromRequestCore

        /// <summary>
        /// Searches an incoming HTTP request for data that could be used to assemble
        /// a protocol request message.
        /// </summary>
        /// <param name="request">The HTTP request to search.</param>
        /// <returns>A dictionary of data in the request.  Should never be null, but may be empty.</returns>
        protected override IDirectedProtocolMessage ReadFromRequestCore(HttpRequestInfo request)
        {
            ErrorUtilities.VerifyArgumentNotNull(request, "request");

            // First search the Authorization header.  Use it exclusively if it's present.
            string authorization = request.Headers[HttpRequestHeader.Authorization];
            if (authorization != null) {
                string[] authorizationSections = authorization.Split(';'); // TODO: is this the right delimiter?
                string oauthPrefix = Protocol.Default.AuthorizationHeaderScheme + " ";

                // The Authorization header may have multiple uses, and OAuth may be just one of them.
                // Go through each one looking for an OAuth one.
                foreach (string auth in authorizationSections) {
                    string trimmedAuth = auth.Trim();
                    if (trimmedAuth.StartsWith(oauthPrefix, StringComparison.Ordinal)) {
                        // We found an Authorization: OAuth header.
                        // Parse it according to the rules in section 5.4.1 of the V1.0 spec.
                        var fields = new Dictionary<string, string>();
                        foreach (string stringPair in trimmedAuth.Substring(oauthPrefix.Length).Split(',')) {
                            string[] keyValueStringPair = stringPair.Trim().Split('=');
                            string key = Uri.UnescapeDataString(keyValueStringPair[0]);
                            string value = Uri.UnescapeDataString(keyValueStringPair[1].Trim('"'));
                            fields.Add(key, value);
                        }

                        return (IDirectedProtocolMessage)this.Receive(fields, request.GetRecipient());
                    }
                }
            }

            // We didn't find an OAuth authorization header.  Revert to other payload methods.
            IDirectedProtocolMessage message = base.ReadFromRequestCore(request);

            // Add receiving HTTP transport information required for signature generation.
            var signedMessage = message as ITamperResistantOAuthMessage;
            if (signedMessage != null) {
                signedMessage.Recipient = request.Url;
                signedMessage.HttpMethod = request.HttpMethod;
            }

            return message;
        }
开发者ID:vrushalid,项目名称:dotnetopenid,代码行数:48,代码来源:OAuthChannel.cs

示例5: ReadFromRequestCore

		/// <summary>
		/// Searches an incoming HTTP request for data that could be used to assemble
		/// a protocol request message.
		/// </summary>
		/// <param name="request">The HTTP request to search.</param>
		/// <returns>The deserialized message, if one is found.  Null otherwise.</returns>
		protected override IDirectedProtocolMessage ReadFromRequestCore(HttpRequestInfo request) {
			var fields = new Dictionary<string, string>();

			// First search the Authorization header.
			string authorization = request.Headers[HttpRequestHeader.Authorization];
			if (authorization != null) {
				string[] authorizationSections = authorization.Split(';'); // TODO: is this the right delimiter?
				string oauthPrefix = Protocol.AuthorizationHeaderScheme + " ";

				// The Authorization header may have multiple uses, and OAuth may be just one of them.
				// Go through each one looking for an OAuth one.
				foreach (string auth in authorizationSections) {
					string trimmedAuth = auth.Trim();
					if (trimmedAuth.StartsWith(oauthPrefix, StringComparison.Ordinal)) {
						// We found an Authorization: OAuth header.  
						// Parse it according to the rules in section 5.4.1 of the V1.0 spec.
						foreach (string stringPair in trimmedAuth.Substring(oauthPrefix.Length).Split(',')) {
							string[] keyValueStringPair = stringPair.Trim().Split('=');
							string key = Uri.UnescapeDataString(keyValueStringPair[0]);
							string value = Uri.UnescapeDataString(keyValueStringPair[1].Trim('"'));
							fields.Add(key, value);
						}
					}
				}

				fields.Remove("realm"); // ignore the realm parameter, since we don't use it, and it must be omitted from signature base string.
			}

			// Scrape the entity
			if (!string.IsNullOrEmpty(request.Headers[HttpRequestHeader.ContentType])) {
				ContentType contentType = new ContentType(request.Headers[HttpRequestHeader.ContentType]);
				if (string.Equals(contentType.MediaType, HttpFormUrlEncoded, StringComparison.Ordinal)) {
					foreach (string key in request.Form) {
						if (key != null) {
							fields.Add(key, request.Form[key]);
						} else {
							Logger.OAuth.WarnFormat("Ignoring query string parameter '{0}' since it isn't a standard name=value parameter.", request.Form[key]);
						}
					}
				}
			}

			// Scrape the query string
			foreach (string key in request.QueryStringBeforeRewriting) {
				if (key != null) {
					fields.Add(key, request.QueryStringBeforeRewriting[key]);
				} else {
					Logger.OAuth.WarnFormat("Ignoring query string parameter '{0}' since it isn't a standard name=value parameter.", request.QueryStringBeforeRewriting[key]);
				}
			}

			MessageReceivingEndpoint recipient;
			try {
				recipient = request.GetRecipient();
			} catch (ArgumentException ex) {
				Logger.OAuth.WarnFormat("Unrecognized HTTP request: " + ex.ToString());
				return null;
			}

			// Deserialize the message using all the data we've collected.
			var message = (IDirectedProtocolMessage)this.Receive(fields, recipient);

			// Add receiving HTTP transport information required for signature generation.
			var signedMessage = message as ITamperResistantOAuthMessage;
			if (signedMessage != null) {
				signedMessage.Recipient = request.UrlBeforeRewriting;
				signedMessage.HttpMethod = request.HttpMethod;
			}

			return message;
		}
开发者ID:jsmale,项目名称:dotnetopenid,代码行数:77,代码来源:OAuthChannel.cs

示例6: ReadFromRequestCore

		/// <summary>
		/// Searches an incoming HTTP request for data that could be used to assemble
		/// a protocol request message.
		/// </summary>
		/// <param name="request">The HTTP request to search.</param>
		/// <returns>The deserialized message, if one is found.  Null otherwise.</returns>
		protected override IDirectedProtocolMessage ReadFromRequestCore(HttpRequestInfo request) {
			// First search the Authorization header.
			string authorization = request.Headers[HttpRequestHeader.Authorization];
			var fields = MessagingUtilities.ParseAuthorizationHeader(Protocol.AuthorizationHeaderScheme, authorization).ToDictionary();
			fields.Remove("realm"); // ignore the realm parameter, since we don't use it, and it must be omitted from signature base string.

			// Scrape the entity
			if (!string.IsNullOrEmpty(request.Headers[HttpRequestHeader.ContentType])) {
				var contentType = new ContentType(request.Headers[HttpRequestHeader.ContentType]);
				if (string.Equals(contentType.MediaType, HttpFormUrlEncoded, StringComparison.Ordinal)) {
					foreach (string key in request.Form) {
						if (key != null) {
							fields.Add(key, request.Form[key]);
						} else {
							Logger.OAuth.WarnFormat("Ignoring query string parameter '{0}' since it isn't a standard name=value parameter.", request.Form[key]);
						}
					}
				}
			}

			// Scrape the query string
			foreach (string key in request.QueryStringBeforeRewriting) {
				if (key != null) {
					fields.Add(key, request.QueryStringBeforeRewriting[key]);
				} else {
					Logger.OAuth.WarnFormat("Ignoring query string parameter '{0}' since it isn't a standard name=value parameter.", request.QueryStringBeforeRewriting[key]);
				}
			}

			MessageReceivingEndpoint recipient;
			try {
				recipient = request.GetRecipient();
			} catch (ArgumentException ex) {
				Logger.OAuth.WarnFormat("Unrecognized HTTP request: " + ex.ToString());
				return null;
			}

			// Deserialize the message using all the data we've collected.
			var message = (IDirectedProtocolMessage)this.Receive(fields, recipient);

			// Add receiving HTTP transport information required for signature generation.
			var signedMessage = message as ITamperResistantOAuthMessage;
			if (signedMessage != null) {
				signedMessage.Recipient = request.UrlBeforeRewriting;
				signedMessage.HttpMethod = request.HttpMethod;
			}

			return message;
		}
开发者ID:enslam,项目名称:dotnetopenid,代码行数:55,代码来源:OAuthChannel.cs


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