//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.OAuth.ChannelElements { using System; using System.Collections.Generic; using System.Linq; using System.Text; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.Messaging.Bindings; /// /// A binding element that signs outgoing messages and verifies the signature on incoming messages. /// public class PlaintextSigningBindingElement : SigningBindingElementBase { /// /// Initializes a new instance of the class. /// public PlaintextSigningBindingElement() : base("PLAINTEXT") { } /// /// Calculates a signature for a given message. /// /// The message to sign. /// The signature for the message. /// /// This method signs the message according to OAuth 1.0 section 9.4.1. /// protected override string GetSignature(ITamperResistantOAuthMessage message) { return GetConsumerAndTokenSecretString(message); } /// /// Checks whether this binding element applies to this message. /// /// The message that needs to be signed. /// True if this binding element can be used to sign the message. False otherwise. protected override bool IsMessageApplicable(ITamperResistantOAuthMessage message) { if (string.Equals(message.Recipient.Scheme, "https", StringComparison.OrdinalIgnoreCase)) { return true; } else { Logger.Bindings.DebugFormat("The {0} element will not sign this message because the URI scheme is not https.", this.GetType().Name); return false; } } /// /// Clones this instance. /// /// A new instance of the binding element. protected override ITamperProtectionChannelBindingElement Clone() { return new PlaintextSigningBindingElement(); } } }