summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.OAuth2/OAuth2
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2012-02-09 20:14:38 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2012-02-09 20:14:38 -0800
commit7bf63044b1a48dc6f1df95c63431e8130940595d (patch)
treef1827702b757452ef55971272962db73ada4985c /src/DotNetOpenAuth.OAuth2/OAuth2
parent1473078585937057deca74a8264f332327ab9869 (diff)
downloadDotNetOpenAuth-7bf63044b1a48dc6f1df95c63431e8130940595d.zip
DotNetOpenAuth-7bf63044b1a48dc6f1df95c63431e8130940595d.tar.gz
DotNetOpenAuth-7bf63044b1a48dc6f1df95c63431e8130940595d.tar.bz2
Fixed many FxCop messages in OAuth2 assemblies. #68
Diffstat (limited to 'src/DotNetOpenAuth.OAuth2/OAuth2')
-rw-r--r--src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/AccessRequestBindingElement.cs5
-rw-r--r--src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/AuthorizationCode.cs4
-rw-r--r--src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/OAuth2ClientChannel.cs2
-rw-r--r--src/DotNetOpenAuth.OAuth2/OAuth2/OAuthStrings.Designer.cs18
-rw-r--r--src/DotNetOpenAuth.OAuth2/OAuth2/OAuthStrings.resx6
-rw-r--r--src/DotNetOpenAuth.OAuth2/OAuth2/OAuthUtilities.cs2
6 files changed, 35 insertions, 2 deletions
diff --git a/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/AccessRequestBindingElement.cs b/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/AccessRequestBindingElement.cs
index b490a72..b1ead11 100644
--- a/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/AccessRequestBindingElement.cs
+++ b/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/AccessRequestBindingElement.cs
@@ -7,6 +7,7 @@
namespace DotNetOpenAuth.OAuth2.ChannelElements {
using System;
using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Security.Cryptography;
@@ -106,6 +107,10 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements {
/// Implementations that provide message protection must honor the
/// <see cref="MessagePartAttribute.RequiredProtection"/> properties where applicable.
/// </remarks>
+ [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "unauthorizedclient", Justification = "Protocol requirement")]
+ [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "incorrectclientcredentials", Justification = "Protocol requirement")]
+ [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "authorizationexpired", Justification = "Protocol requirement")]
+ [SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "DotNetOpenAuth.Messaging.ErrorUtilities.VerifyProtocol(System.Boolean,System.String,System.Object[])", Justification = "Protocol requirement")]
public override MessageProtections? ProcessIncomingMessage(IProtocolMessage message) {
var tokenRequest = message as IAuthorizationCarryingRequest;
if (tokenRequest != null) {
diff --git a/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/AuthorizationCode.cs b/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/AuthorizationCode.cs
index 9152201..ad9730a 100644
--- a/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/AuthorizationCode.cs
+++ b/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/AuthorizationCode.cs
@@ -7,6 +7,7 @@
namespace DotNetOpenAuth.OAuth2.ChannelElements {
using System;
using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Security.Cryptography;
using System.Text;
@@ -80,6 +81,8 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements {
/// and the callback URL given in the access token request match.
/// </remarks>
/// <exception cref="ProtocolException">Thrown when the callback URLs do not match.</exception>
+ [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "redirecturimismatch", Justification = "Protocol requirement")]
+ [SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "DotNetOpenAuth.Messaging.ErrorUtilities.VerifyProtocol(System.Boolean,System.String,System.Object[])", Justification = "Protocol requirement")]
internal void VerifyCallback(Uri callback) {
ErrorUtilities.VerifyProtocol(MessagingUtilities.AreEquivalent(this.CallbackHash, CalculateCallbackHash(callback)), Protocol.redirect_uri_mismatch);
}
@@ -91,6 +94,7 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements {
/// <returns>
/// A base64 encoding of the hash of the URL.
/// </returns>
+ [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "False positive.")]
private static byte[] CalculateCallbackHash(Uri callback) {
using (var hasher = new SHA256Managed()) {
return hasher.ComputeHash(Encoding.UTF8.GetBytes(callback.AbsoluteUri));
diff --git a/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/OAuth2ClientChannel.cs b/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/OAuth2ClientChannel.cs
index c74fced..3a8a7c0 100644
--- a/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/OAuth2ClientChannel.cs
+++ b/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/OAuth2ClientChannel.cs
@@ -65,7 +65,7 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements {
} else if (response.ContentType.MediaType == HttpFormUrlEncoded || response.ContentType.MediaType == PlainTextEncoded) {
return HttpUtility.ParseQueryString(body).ToDictionary();
} else {
- throw ErrorUtilities.ThrowProtocol("Unexpected response Content-Type {0}", response.ContentType.MediaType);
+ throw ErrorUtilities.ThrowProtocol(OAuthStrings.UnexpectedResponseContentType, response.ContentType.MediaType);
}
}
diff --git a/src/DotNetOpenAuth.OAuth2/OAuth2/OAuthStrings.Designer.cs b/src/DotNetOpenAuth.OAuth2/OAuth2/OAuthStrings.Designer.cs
index 04e9073..b3482fd 100644
--- a/src/DotNetOpenAuth.OAuth2/OAuth2/OAuthStrings.Designer.cs
+++ b/src/DotNetOpenAuth.OAuth2/OAuth2/OAuthStrings.Designer.cs
@@ -79,6 +79,15 @@ namespace DotNetOpenAuth.OAuth2 {
}
/// <summary>
+ /// Looks up a localized string similar to The access token contains characters that must not appear in the HTTP Authorization header..
+ /// </summary>
+ internal static string AccessTokenInvalidForHttpAuthorizationHeader {
+ get {
+ return ResourceManager.GetString("AccessTokenInvalidForHttpAuthorizationHeader", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Failed to obtain access token. Authorization Server reports reason: {0}.
/// </summary>
internal static string CannotObtainAccessTokenWithReason {
@@ -149,5 +158,14 @@ namespace DotNetOpenAuth.OAuth2 {
return ResourceManager.GetString("ScopesMayNotContainSpaces", resourceCulture);
}
}
+
+ /// <summary>
+ /// Looks up a localized string similar to Unexpected response Content-Type {0}.
+ /// </summary>
+ internal static string UnexpectedResponseContentType {
+ get {
+ return ResourceManager.GetString("UnexpectedResponseContentType", resourceCulture);
+ }
+ }
}
}
diff --git a/src/DotNetOpenAuth.OAuth2/OAuth2/OAuthStrings.resx b/src/DotNetOpenAuth.OAuth2/OAuth2/OAuthStrings.resx
index 0852b76..faa9fe5 100644
--- a/src/DotNetOpenAuth.OAuth2/OAuth2/OAuthStrings.resx
+++ b/src/DotNetOpenAuth.OAuth2/OAuth2/OAuthStrings.resx
@@ -123,6 +123,9 @@
<data name="AccessScopeExceedsGrantScope" xml:space="preserve">
<value>The requested access scope ("{0}") exceeds the grant scope ("{1}").</value>
</data>
+ <data name="AccessTokenInvalidForHttpAuthorizationHeader" xml:space="preserve">
+ <value>The access token contains characters that must not appear in the HTTP Authorization header.</value>
+ </data>
<data name="CannotObtainAccessTokenWithReason" xml:space="preserve">
<value>Failed to obtain access token. Authorization Server reports reason: {0}</value>
</data>
@@ -147,4 +150,7 @@
<data name="ScopesMayNotContainSpaces" xml:space="preserve">
<value>Individual scopes may not contain spaces.</value>
</data>
+ <data name="UnexpectedResponseContentType" xml:space="preserve">
+ <value>Unexpected response Content-Type {0}</value>
+ </data>
</root> \ No newline at end of file
diff --git a/src/DotNetOpenAuth.OAuth2/OAuth2/OAuthUtilities.cs b/src/DotNetOpenAuth.OAuth2/OAuth2/OAuthUtilities.cs
index e857422..f3bceda 100644
--- a/src/DotNetOpenAuth.OAuth2/OAuth2/OAuthUtilities.cs
+++ b/src/DotNetOpenAuth.OAuth2/OAuth2/OAuthUtilities.cs
@@ -93,7 +93,7 @@ namespace DotNetOpenAuth.OAuth2 {
internal static void AuthorizeWithBearerToken(this HttpWebRequest request, string accessToken) {
Requires.NotNull(request, "request");
Requires.NotNullOrEmpty(accessToken, "accessToken");
- ErrorUtilities.VerifyProtocol(accessToken.All(ch => accessTokenAuthorizationHeaderAllowedCharacters.IndexOf(ch) >= 0), "The access token contains characters that must not appear in the HTTP Authorization header.");
+ ErrorUtilities.VerifyProtocol(accessToken.All(ch => accessTokenAuthorizationHeaderAllowedCharacters.IndexOf(ch) >= 0), OAuthStrings.AccessTokenInvalidForHttpAuthorizationHeader);
request.Headers[HttpRequestHeader.Authorization] = string.Format(
CultureInfo.InvariantCulture,