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


C# Association.Sign方法代码示例

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


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

示例1: GetSignature

		/// <summary>
		/// Calculates the signature for a given message.
		/// </summary>
		/// <param name="signedMessage">The message to sign or verify.</param>
		/// <param name="association">The association to use to sign the message.</param>
		/// <returns>The calculated signature of the method.</returns>
		private string GetSignature(ITamperResistantOpenIdMessage signedMessage, Association association) {
			Contract.Requires<ArgumentNullException>(signedMessage != null);
			Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(signedMessage.SignedParameterOrder));
			Contract.Requires<ArgumentNullException>(association != null);

			// Prepare the parts to sign, taking care to replace an openid.mode value
			// of check_authentication with its original id_res so the signature matches.
			MessageDictionary dictionary = this.Channel.MessageDescriptions.GetAccessor(signedMessage);
			var parametersToSign = from name in signedMessage.SignedParameterOrder.Split(',')
								   let prefixedName = Protocol.V20.openid.Prefix + name
								   select new KeyValuePair<string, string>(name, dictionary[prefixedName]);

			byte[] dataToSign = KeyValueFormEncoding.GetBytes(parametersToSign);
			string signature = Convert.ToBase64String(association.Sign(dataToSign));

			if (Logger.Signatures.IsDebugEnabled) {
				Logger.Signatures.DebugFormat(
					"Signing these message parts: {0}{1}{0}Base64 representation of signed data: {2}{0}Signature: {3}",
					Environment.NewLine,
					parametersToSign.ToStringDeferred(),
					Convert.ToBase64String(dataToSign),
					signature);
			}

			return signature;
		}
开发者ID:jsmale,项目名称:dotnetopenid,代码行数:32,代码来源:SigningBindingElement.cs

示例2: GetSignature

        /// <summary>
        /// Calculates the signature for a given message.
        /// </summary>
        /// <param name="signedMessage">The message to sign or verify.</param>
        /// <param name="association">The association to use to sign the message.</param>
        /// <returns>The calculated signature of the method.</returns>
        private string GetSignature(ITamperResistantOpenIdMessage signedMessage, Association association)
        {
            ErrorUtilities.VerifyArgumentNotNull(signedMessage, "signedMessage");
            ErrorUtilities.VerifyNonZeroLength(signedMessage.SignedParameterOrder, "signedMessage.SignedParameterOrder");
            ErrorUtilities.VerifyArgumentNotNull(association, "association");

            // Prepare the parts to sign, taking care to replace an openid.mode value
            // of check_authentication with its original id_res so the signature matches.
            MessageDictionary dictionary = this.Channel.MessageDescriptions.GetAccessor(signedMessage);
            var parametersToSign = from name in signedMessage.SignedParameterOrder.Split(',')
                                   let prefixedName = Protocol.V20.openid.Prefix + name
                                   select new KeyValuePair<string, string>(name, dictionary[prefixedName]);

            byte[] dataToSign = KeyValueFormEncoding.GetBytes(parametersToSign);
            string signature = Convert.ToBase64String(association.Sign(dataToSign));

            if (Logger.Signatures.IsDebugEnabled) {
                Logger.Signatures.DebugFormat(
                    CultureInfo.InvariantCulture,
                    "Signing these message parts: {0}{1}{0}Base64 representation of signed data: {2}{0}Signature: {3}",
                    Environment.NewLine,
                    parametersToSign.ToStringDeferred(),
                    Convert.ToBase64String(dataToSign),
                    signature);
            }

            return signature;
        }
开发者ID:vrushalid,项目名称:dotnetopenid,代码行数:34,代码来源:SigningBindingElement.cs


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