summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.OAuth/OAuth/ChannelElements')
-rw-r--r--src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/OAuthHttpMethodBindingElement.cs21
-rw-r--r--src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/SigningBindingElementBase.cs14
2 files changed, 12 insertions, 23 deletions
diff --git a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/OAuthHttpMethodBindingElement.cs b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/OAuthHttpMethodBindingElement.cs
index 60df47f..29ef8d5 100644
--- a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/OAuthHttpMethodBindingElement.cs
+++ b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/OAuthHttpMethodBindingElement.cs
@@ -17,17 +17,6 @@ namespace DotNetOpenAuth.OAuth.ChannelElements {
/// Sets the HTTP Method property on a signed message before the signing module gets to it.
/// </summary>
internal class OAuthHttpMethodBindingElement : IChannelBindingElement {
- /// <summary>
- /// A reusable pre-completed task that may be returned multiple times to reduce GC pressure.
- /// </summary>
- private static readonly Task<MessageProtections?> NullTask = Task.FromResult<MessageProtections?>(null);
-
- /// <summary>
- /// A reusable pre-completed task that may be returned multiple times to reduce GC pressure.
- /// </summary>
- private static readonly Task<MessageProtections?> NoneTask =
- Task.FromResult<MessageProtections?>(MessageProtections.None);
-
#region IChannelBindingElement Members
/// <summary>
@@ -58,13 +47,13 @@ namespace DotNetOpenAuth.OAuth.ChannelElements {
HttpDeliveryMethods transmissionMethod = oauthMessage.HttpMethods;
try {
oauthMessage.HttpMethod = MessagingUtilities.GetHttpVerb(transmissionMethod);
- return NoneTask;
+ return MessageProtectionTasks.None;
} catch (ArgumentException ex) {
Logger.OAuth.Error("Unrecognized HttpDeliveryMethods value.", ex);
- return NullTask;
+ return MessageProtectionTasks.Null;
}
} else {
- return NullTask;
+ return MessageProtectionTasks.Null;
}
}
@@ -82,8 +71,8 @@ namespace DotNetOpenAuth.OAuth.ChannelElements {
/// Thrown when the binding element rules indicate that this message is invalid and should
/// NOT be processed.
/// </exception>
- public async Task<MessageProtections?> ProcessIncomingMessageAsync(IProtocolMessage message, CancellationToken cancellationToken) {
- return null;
+ public Task<MessageProtections?> ProcessIncomingMessageAsync(IProtocolMessage message, CancellationToken cancellationToken) {
+ return MessageProtectionTasks.Null;
}
#endregion
diff --git a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/SigningBindingElementBase.cs b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/SigningBindingElementBase.cs
index 2db5027..357ca45 100644
--- a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/SigningBindingElementBase.cs
+++ b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/SigningBindingElementBase.cs
@@ -86,7 +86,7 @@ namespace DotNetOpenAuth.OAuth.ChannelElements {
/// The protections (if any) that this binding element applied to the message.
/// Null if this binding element did not even apply to this binding element.
/// </returns>
- public async Task<MessageProtections?> ProcessOutgoingMessageAsync(IProtocolMessage message, CancellationToken cancellationToken) {
+ public Task<MessageProtections?> ProcessOutgoingMessageAsync(IProtocolMessage message, CancellationToken cancellationToken) {
var signedMessage = message as ITamperResistantOAuthMessage;
if (signedMessage != null && this.IsMessageApplicable(signedMessage)) {
if (this.SignatureCallback != null) {
@@ -98,10 +98,10 @@ namespace DotNetOpenAuth.OAuth.ChannelElements {
signedMessage.SignatureMethod = this.signatureMethod;
Logger.Bindings.DebugFormat("Signing {0} message using {1}.", message.GetType().Name, this.signatureMethod);
signedMessage.Signature = this.GetSignature(signedMessage);
- return MessageProtections.TamperProtection;
+ return MessageProtectionTasks.TamperProtection;
}
- return null;
+ return MessageProtectionTasks.Null;
}
/// <summary>
@@ -114,14 +114,14 @@ namespace DotNetOpenAuth.OAuth.ChannelElements {
/// Null if this binding element did not even apply to this binding element.
/// </returns>
/// <exception cref="InvalidSignatureException">Thrown if the signature is invalid.</exception>
- public async Task<MessageProtections?> ProcessIncomingMessageAsync(IProtocolMessage message, CancellationToken cancellationToken) {
+ public Task<MessageProtections?> ProcessIncomingMessageAsync(IProtocolMessage message, CancellationToken cancellationToken) {
var signedMessage = message as ITamperResistantOAuthMessage;
if (signedMessage != null && this.IsMessageApplicable(signedMessage)) {
Logger.Bindings.DebugFormat("Verifying incoming {0} message signature of: {1}", message.GetType().Name, signedMessage.Signature);
if (!string.Equals(signedMessage.SignatureMethod, this.signatureMethod, StringComparison.Ordinal)) {
Logger.Bindings.WarnFormat("Expected signature method '{0}' but received message with a signature method of '{1}'.", this.signatureMethod, signedMessage.SignatureMethod);
- return MessageProtections.None;
+ return MessageProtectionTasks.None;
}
if (this.SignatureCallback != null) {
@@ -135,10 +135,10 @@ namespace DotNetOpenAuth.OAuth.ChannelElements {
throw new InvalidSignatureException(message);
}
- return MessageProtections.TamperProtection;
+ return MessageProtectionTasks.TamperProtection;
}
- return null;
+ return MessageProtectionTasks.Null;
}
#endregion