Permalink
Browse files

OAuth 1 assemblies now FxCop clean. #68

  • Loading branch information...
1 parent 0b7175b commit db132c3c9216833d05c4fb1bfea5f3d94190e02a @AArnott AArnott committed Feb 10, 2012
@@ -30,11 +30,10 @@ internal class OAuthConsumerChannel : OAuthChannel {
internal OAuthConsumerChannel(ITamperProtectionChannelBindingElement signingBindingElement, INonceStore store, IConsumerTokenManager tokenManager, ConsumerSecuritySettings securitySettings, IMessageFactory messageFactory = null)
: base(
signingBindingElement,
- store,
tokenManager,
securitySettings,
messageFactory ?? new OAuthConsumerMessageFactory(),
- InitializeBindingElements(signingBindingElement, store, tokenManager, securitySettings)) {
+ InitializeBindingElements(signingBindingElement, store)) {
Requires.NotNull(tokenManager, "tokenManager");
Requires.NotNull(securitySettings, "securitySettings");
Requires.NotNull(signingBindingElement, "signingBindingElement");
@@ -56,15 +55,11 @@ internal OAuthConsumerChannel(ITamperProtectionChannelBindingElement signingBind
/// </summary>
/// <param name="signingBindingElement">The signing binding element.</param>
/// <param name="store">The nonce store.</param>
- /// <param name="tokenManager">The token manager.</param>
- /// <param name="securitySettings">The security settings.</param>
/// <returns>
/// An array of binding elements used to initialize the channel.
/// </returns>
- private static new IChannelBindingElement[] InitializeBindingElements(ITamperProtectionChannelBindingElement signingBindingElement, INonceStore store, ITokenManager tokenManager, SecuritySettings securitySettings) {
- Contract.Requires(securitySettings != null);
-
- return OAuthChannel.InitializeBindingElements(signingBindingElement, store, tokenManager, securitySettings).ToArray();
+ private static new IChannelBindingElement[] InitializeBindingElements(ITamperProtectionChannelBindingElement signingBindingElement, INonceStore store) {
+ return OAuthChannel.InitializeBindingElements(signingBindingElement, store).ToArray();
}
}
}
@@ -6,6 +6,7 @@
namespace DotNetOpenAuth.OAuth.ChannelElements {
using System;
+ using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
@@ -15,6 +16,7 @@ namespace DotNetOpenAuth.OAuth.ChannelElements {
/// <summary>
/// A binding element that signs outgoing messages and verifies the signature on incoming messages.
/// </summary>
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sha", Justification = "Acronym")]
public class RsaSha1ConsumerSigningBindingElement : RsaSha1SigningBindingElement {
/// <summary>
/// Initializes a new instance of the <see cref="RsaSha1ConsumerSigningBindingElement"/> class.
@@ -30,7 +30,6 @@ internal class OAuthServiceProviderChannel : OAuthChannel {
internal OAuthServiceProviderChannel(ITamperProtectionChannelBindingElement signingBindingElement, INonceStore store, IServiceProviderTokenManager tokenManager, ServiceProviderSecuritySettings securitySettings, IMessageFactory messageTypeProvider = null)
: base(
signingBindingElement,
- store,
tokenManager,
securitySettings,
messageTypeProvider ?? new OAuthServiceProviderMessageFactory(tokenManager),
@@ -59,10 +58,10 @@ internal OAuthServiceProviderChannel(ITamperProtectionChannelBindingElement sign
/// <returns>
/// An array of binding elements used to initialize the channel.
/// </returns>
- private static new IChannelBindingElement[] InitializeBindingElements(ITamperProtectionChannelBindingElement signingBindingElement, INonceStore store, ITokenManager tokenManager, SecuritySettings securitySettings) {
+ private static IChannelBindingElement[] InitializeBindingElements(ITamperProtectionChannelBindingElement signingBindingElement, INonceStore store, ITokenManager tokenManager, SecuritySettings securitySettings) {
Contract.Requires(securitySettings != null);
- var bindingElements = OAuthChannel.InitializeBindingElements(signingBindingElement, store, tokenManager, securitySettings);
+ var bindingElements = OAuthChannel.InitializeBindingElements(signingBindingElement, store);
var spTokenManager = tokenManager as IServiceProviderTokenManager;
var serviceProviderSecuritySettings = securitySettings as ServiceProviderSecuritySettings;
@@ -6,6 +6,7 @@
namespace DotNetOpenAuth.OAuth.ChannelElements {
using System;
+ using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
@@ -15,6 +16,7 @@ namespace DotNetOpenAuth.OAuth.ChannelElements {
/// <summary>
/// A binding element that signs outgoing messages and verifies the signature on incoming messages.
/// </summary>
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sha", Justification = "Acronym")]
public class RsaSha1ServiceProviderSigningBindingElement : RsaSha1SigningBindingElement {
/// <summary>
/// The token manager for the service provider.
@@ -6,6 +6,7 @@
namespace DotNetOpenAuth.OAuth.ChannelElements {
using System;
+ using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Security.Cryptography;
using System.Text;
@@ -30,6 +31,7 @@ public HmacSha1SigningBindingElement()
/// <remarks>
/// This method signs the message per OAuth 1.0 section 9.2.
/// </remarks>
+ [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "False positive.")]
protected override string GetSignature(ITamperResistantOAuthMessage message) {
string key = GetConsumerAndTokenSecretString(message);
using (HashAlgorithm hasher = new HMACSHA1(Encoding.ASCII.GetBytes(key))) {
@@ -30,15 +30,14 @@ internal abstract class OAuthChannel : Channel {
/// Initializes a new instance of the <see cref="OAuthChannel"/> class.
/// </summary>
/// <param name="signingBindingElement">The binding element to use for signing.</param>
- /// <param name="store">The web application store to use for nonces.</param>
/// <param name="tokenManager">The ITokenManager instance to use.</param>
/// <param name="securitySettings">The security settings.</param>
/// <param name="messageTypeProvider">An injected message type provider instance.
/// Except for mock testing, this should always be one of
/// OAuthConsumerMessageFactory or OAuthServiceProviderMessageFactory.</param>
/// <param name="bindingElements">The binding elements.</param>
[SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Diagnostics.Contracts.__ContractsRuntime.Requires<System.ArgumentNullException>(System.Boolean,System.String,System.String)", Justification = "Code contracts"), SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "securitySettings", Justification = "Code contracts")]
- protected OAuthChannel(ITamperProtectionChannelBindingElement signingBindingElement, INonceStore store, ITokenManager tokenManager, SecuritySettings securitySettings, IMessageFactory messageTypeProvider, IChannelBindingElement[] bindingElements)
+ protected OAuthChannel(ITamperProtectionChannelBindingElement signingBindingElement, ITokenManager tokenManager, SecuritySettings securitySettings, IMessageFactory messageTypeProvider, IChannelBindingElement[] bindingElements)
: base(messageTypeProvider, bindingElements) {
Requires.NotNull(tokenManager, "tokenManager");
Requires.NotNull(securitySettings, "securitySettings");
@@ -90,14 +89,10 @@ protected OAuthChannel(ITamperProtectionChannelBindingElement signingBindingElem
/// </summary>
/// <param name="signingBindingElement">The signing binding element.</param>
/// <param name="store">The nonce store.</param>
- /// <param name="tokenManager">The token manager.</param>
- /// <param name="securitySettings">The security settings.</param>
/// <returns>
/// An array of binding elements used to initialize the channel.
/// </returns>
- protected static List<IChannelBindingElement> InitializeBindingElements(ITamperProtectionChannelBindingElement signingBindingElement, INonceStore store, ITokenManager tokenManager, SecuritySettings securitySettings) {
- Contract.Requires(securitySettings != null);
-
+ protected static List<IChannelBindingElement> InitializeBindingElements(ITamperProtectionChannelBindingElement signingBindingElement, INonceStore store) {
var bindingElements = new List<IChannelBindingElement> {
new OAuthHttpMethodBindingElement(),
signingBindingElement,
@@ -154,7 +154,7 @@ public abstract class SigningBindingElementBase : ITamperProtectionChannelBindin
Requires.NotNull(message, "message");
Requires.NotNullOrEmpty(message.HttpMethod, "message.HttpMethod");
Requires.NotNull(messageDictionary, "messageDictionary");
- ErrorUtilities.VerifyArgument(messageDictionary.Message == message, "Message references are not equal.");
+ ErrorUtilities.VerifyInternal(messageDictionary.Message == message, "Message references are not equal.");
List<string> signatureBaseStringElements = new List<string>(3);
@@ -75,3 +75,6 @@
[assembly: SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "DotNetOpenAuth.Messaging.IHttpDirectResponseContract.#DotNetOpenAuth.Messaging.IHttpDirectResponse.HttpStatusCode", Justification = "Code contract")]
[assembly: SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Scope = "member", Target = "DotNetOpenAuth.Messaging.IHttpDirectResponseContract.#DotNetOpenAuth.Messaging.IHttpDirectResponse.HttpStatusCode", Justification = "Code contract")]
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "DotNetOpenAuth.ComponentModel", Justification = "Types distributed across assemblies.")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "DotNetOpenAuth.OAuth")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "DotNetOpenAuth.OAuth.ChannelElements")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "DotNetOpenAuth.Messaging")]

0 comments on commit db132c3

Please sign in to comment.