Skip to content
This repository was archived by the owner on Mar 20, 2019. It is now read-only.

Commit 5cd3b78

Browse files
committed
StyleCop cleanup, and reversal of some code changes that were no longer necessary.
1 parent 2ddd19d commit 5cd3b78

24 files changed

Lines changed: 272 additions & 126 deletions

src/DotNetOpenAuth.Core/Messaging/IHttpDirectRequestContract.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,38 @@ WebHeaderCollection IHttpDirectRequest.Headers {
3434

3535
#region IMessage Members
3636

37+
/// <summary>
38+
/// Gets the version of the protocol or extension this message is prepared to implement.
39+
/// </summary>
40+
/// <remarks>
41+
/// Implementations of this interface should ensure that this property never returns null.
42+
/// </remarks>
3743
Version IMessage.Version {
3844
get { throw new NotImplementedException(); }
3945
}
4046

47+
/// <summary>
48+
/// Gets the extra, non-standard Protocol parameters included in the message.
49+
/// </summary>
50+
/// <remarks>
51+
/// Implementations of this interface should ensure that this property never returns null.
52+
/// </remarks>
4153
IDictionary<string, string> IMessage.ExtraData {
4254
get { throw new NotImplementedException(); }
4355
}
4456

57+
/// <summary>
58+
/// Checks the message state for conformity to the protocol specification
59+
/// and throws an exception if the message is invalid.
60+
/// </summary>
61+
/// <remarks>
62+
/// <para>Some messages have required fields, or combinations of fields that must relate to each other
63+
/// in specialized ways. After deserializing a message, this method checks the state of the
64+
/// message to see if it conforms to the protocol.</para>
65+
/// <para>Note that this property should <i>not</i> check signatures or perform any state checks
66+
/// outside this scope of this particular message.</para>
67+
/// </remarks>
68+
/// <exception cref="ProtocolException">Thrown if the message is invalid.</exception>
4569
void IMessage.EnsureValidMessage() {
4670
throw new NotImplementedException();
4771
}

src/DotNetOpenAuth.Core/Requires.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ internal static T NotNull<T>(T value, string parameterName) where T : class {
4343
/// </summary>
4444
/// <param name="value">The value.</param>
4545
/// <param name="parameterName">Name of the parameter.</param>
46+
/// <returns>The validated value.</returns>
4647
#if !CLR4
4748
[ContractArgumentValidator]
4849
#endif

src/DotNetOpenAuth.OAuth2.AuthorizationServer/DotNetOpenAuth.OAuth2.AuthorizationServer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<Compile Include="OAuth2\ChannelElements\IOAuth2ChannelWithAuthorizationServer.cs" />
3636
<Compile Include="OAuth2\ChannelElements\OAuth2AuthorizationServerChannel.cs" />
3737
<Compile Include="OAuth2\ChannelElements\RefreshToken.cs" />
38-
<Compile Include="OAuth2\ChannelElements\ClientCredentialReader.cs" />
38+
<Compile Include="OAuth2\ChannelElements\ClientAuthenticationModuleBase.cs" />
3939
<Compile Include="OAuth2\ClientDescription.cs" />
4040
<Compile Include="OAuth2\Messages\AccessTokenAuthorizationCodeRequestAS.cs" />
4141
<Compile Include="OAuth2\Messages\AccessTokenRefreshRequestAS.cs" />

src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/AuthorizationServer.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,14 @@ public class AuthorizationServer {
2828
private static readonly TypeConfigurationCollection<IClientAuthenticationModule> defaultClientAuthenticationModules =
2929
new TypeConfigurationCollection<IClientAuthenticationModule>(new Type[] { typeof(ClientCredentialHttpBasicReader), typeof(ClientCredentialMessagePartReader) });
3030

31+
/// <summary>
32+
/// The list of modules that verify client authentication data.
33+
/// </summary>
3134
private readonly List<IClientAuthenticationModule> clientAuthenticationModules = new List<IClientAuthenticationModule>();
3235

36+
/// <summary>
37+
/// The lone aggregate client authentication module that uses the <see cref="clientAuthenticationModules"/> and applies aggregating policy.
38+
/// </summary>
3339
private readonly ClientAuthenticationModuleBase aggregatingClientAuthenticationModule;
3440

3541
/// <summary>
@@ -50,7 +56,6 @@ public AuthorizationServer(IAuthorizationServerHost authorizationServer) {
5056
////this.clientAuthenticationModules.AddRange(modules.CreateInstances(true));
5157
this.clientAuthenticationModules.Add(new ClientCredentialMessagePartReader(authorizationServer));
5258
this.clientAuthenticationModules.Add(new ClientCredentialHttpBasicReader(authorizationServer));
53-
5459
}
5560

5661
/// <summary>
@@ -67,6 +72,9 @@ public IAuthorizationServerHost AuthorizationServerServices {
6772
get { return ((IOAuth2ChannelWithAuthorizationServer)this.Channel).AuthorizationServer; }
6873
}
6974

75+
/// <summary>
76+
/// Gets the extension modules that can read client authentication data from incoming messages.
77+
/// </summary>
7078
public IList<IClientAuthenticationModule> ClientAuthenticationModules {
7179
get { return this.clientAuthenticationModules; }
7280
}

src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/AggregatingClientCredentialReader.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ internal AggregatingClientCredentialReader(IEnumerable<IClientAuthenticationModu
3232
this.authenticators = authenticators;
3333
}
3434

35+
/// <summary>
36+
/// Attempts to extract client identification/authentication information from a message.
37+
/// </summary>
38+
/// <param name="requestMessage">The incoming message.</param>
39+
/// <param name="clientIdentifier">Receives the client identifier, if one was found.</param>
40+
/// <returns>The level of the extracted client information.</returns>
3541
public override ClientAuthenticationResult TryAuthenticateClient(AuthenticatedClientRequestBase requestMessage, out string clientIdentifier) {
3642
Requires.NotNull(requestMessage, "requestMessage");
3743

src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/ClientCredentialReader.cs renamed to src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/ClientAuthenticationModuleBase.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//-----------------------------------------------------------------------
2-
// <copyright file="ClientCredentialReader.cs" company="Andrew Arnott">
2+
// <copyright file="ClientAuthenticationModuleBase.cs" company="Andrew Arnott">
33
// Copyright (c) Andrew Arnott. All rights reserved.
44
// </copyright>
55
//-----------------------------------------------------------------------
@@ -14,16 +14,41 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements {
1414
using DotNetOpenAuth.Messaging;
1515
using DotNetOpenAuth.OAuth2.Messages;
1616

17+
/// <summary>
18+
/// A convenient base class for imlementations of the <see cref="IClientAuthenticationModule"/> interface.
19+
/// </summary>
1720
public abstract class ClientAuthenticationModuleBase : IClientAuthenticationModule {
21+
/// <summary>
22+
/// Initializes a new instance of the <see cref="ClientAuthenticationModuleBase"/> class.
23+
/// </summary>
1824
protected ClientAuthenticationModuleBase() {
1925
}
2026

27+
/// <summary>
28+
/// Attempts to extract client identification/authentication information from a message.
29+
/// </summary>
30+
/// <param name="requestMessage">The incoming message.</param>
31+
/// <param name="clientIdentifier">Receives the client identifier, if one was found.</param>
32+
/// <returns>The level of the extracted client information.</returns>
2133
public abstract ClientAuthenticationResult TryAuthenticateClient(AuthenticatedClientRequestBase requestMessage, out string clientIdentifier);
2234

35+
/// <summary>
36+
/// Attempts to extract client identification/authentication information from a message.
37+
/// </summary>
38+
/// <param name="requestMessage">The incoming message. Always an instance of <see cref="AuthenticatedClientRequestBase"/></param>
39+
/// <param name="clientIdentifier">Receives the client identifier, if one was found.</param>
40+
/// <returns>The level of the extracted client information.</returns>
2341
public ClientAuthenticationResult TryAuthenticateClient(IDirectedProtocolMessage requestMessage, out string clientIdentifier) {
2442
return this.TryAuthenticateClient((AuthenticatedClientRequestBase)requestMessage, out clientIdentifier);
2543
}
2644

45+
/// <summary>
46+
/// Validates a client identifier and shared secret against the authoriation server's database.
47+
/// </summary>
48+
/// <param name="authorizationServerHost">The authorization server host; cannot be <c>null</c>.</param>
49+
/// <param name="clientIdentifier">The alleged client identifier.</param>
50+
/// <param name="clientSecret">The alleged client secret to be verified.</param>
51+
/// <returns>An indication as to the outcome of the validation.</returns>
2752
protected static ClientAuthenticationResult TryAuthenticateClient(IAuthorizationServerHost authorizationServerHost, string clientIdentifier, string clientSecret) {
2853
Requires.NotNull(authorizationServerHost, "authorizationServerHost");
2954

src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/ClientCredentialHttpBasicReader.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,30 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements {
1313
using DotNetOpenAuth.Messaging;
1414
using DotNetOpenAuth.OAuth2.Messages;
1515

16+
/// <summary>
17+
/// Reads client authentication information from the HTTP Authorization header via Basic authentication.
18+
/// </summary>
1619
public class ClientCredentialHttpBasicReader : ClientAuthenticationModuleBase {
20+
/// <summary>
21+
/// The authorization server host.
22+
/// </summary>
1723
private readonly IAuthorizationServerHost authorizationServerHost;
1824

25+
/// <summary>
26+
/// Initializes a new instance of the <see cref="ClientCredentialHttpBasicReader"/> class.
27+
/// </summary>
28+
/// <param name="authorizationServerHost">The authorization server host.</param>
1929
public ClientCredentialHttpBasicReader(IAuthorizationServerHost authorizationServerHost) {
2030
Requires.NotNull(authorizationServerHost, "authorizationServerHost");
2131
this.authorizationServerHost = authorizationServerHost;
2232
}
2333

34+
/// <summary>
35+
/// Attempts to extract client identification/authentication information from a message.
36+
/// </summary>
37+
/// <param name="requestMessage">The incoming message.</param>
38+
/// <param name="clientIdentifier">Receives the client identifier, if one was found.</param>
39+
/// <returns>The level of the extracted client information.</returns>
2440
public override ClientAuthenticationResult TryAuthenticateClient(AuthenticatedClientRequestBase requestMessage, out string clientIdentifier) {
2541
Requires.NotNull(requestMessage, "requestMessage");
2642

src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/ClientCredentialMessagePartReader.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,30 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements {
1212
using System.Web;
1313
using DotNetOpenAuth.OAuth2.Messages;
1414

15+
/// <summary>
16+
/// Reads client authentication information from the message payload itself (POST entity as a URI-encoded parameter).
17+
/// </summary>
1518
public class ClientCredentialMessagePartReader : ClientAuthenticationModuleBase {
19+
/// <summary>
20+
/// The authorization server host.
21+
/// </summary>
1622
private readonly IAuthorizationServerHost authorizationServerHost;
1723

24+
/// <summary>
25+
/// Initializes a new instance of the <see cref="ClientCredentialMessagePartReader"/> class.
26+
/// </summary>
27+
/// <param name="authorizationServerHost">The authorization server host.</param>
1828
public ClientCredentialMessagePartReader(IAuthorizationServerHost authorizationServerHost) {
1929
Requires.NotNull(authorizationServerHost, "authorizationServerHost");
2030
this.authorizationServerHost = authorizationServerHost;
2131
}
2232

33+
/// <summary>
34+
/// Attempts to extract client identification/authentication information from a message.
35+
/// </summary>
36+
/// <param name="requestMessage">The incoming message.</param>
37+
/// <param name="clientIdentifier">Receives the client identifier, if one was found.</param>
38+
/// <returns>The level of the extracted client information.</returns>
2339
public override ClientAuthenticationResult TryAuthenticateClient(AuthenticatedClientRequestBase requestMessage, out string clientIdentifier) {
2440
Requires.NotNull(requestMessage, "requestMessage");
2541
clientIdentifier = requestMessage.ClientIdentifier;

src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/MessageValidationBindingElement.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements {
2323
/// not been revoked and that an access token has not expired.
2424
/// </remarks>
2525
internal class MessageValidationBindingElement : AuthServerBindingElementBase {
26+
/// <summary>
27+
/// The aggregating client authentication module.
28+
/// </summary>
2629
private readonly IClientAuthenticationModule clientAuthenticationModule;
2730

31+
/// <summary>
32+
/// Initializes a new instance of the <see cref="MessageValidationBindingElement"/> class.
33+
/// </summary>
34+
/// <param name="clientAuthenticationModule">The aggregating client authentication module.</param>
2835
internal MessageValidationBindingElement(IClientAuthenticationModule clientAuthenticationModule) {
2936
Requires.NotNull(clientAuthenticationModule, "clientAuthenticationModule");
3037
this.clientAuthenticationModule = clientAuthenticationModule;

src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/OAuth2AuthorizationServerChannel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ internal class OAuth2AuthorizationServerChannel : OAuth2ChannelBase, IOAuth2Chan
3535
/// Initializes a new instance of the <see cref="OAuth2AuthorizationServerChannel"/> class.
3636
/// </summary>
3737
/// <param name="authorizationServer">The authorization server.</param>
38+
/// <param name="clientAuthenticationModule">The aggregating client authentication module.</param>
3839
protected internal OAuth2AuthorizationServerChannel(IAuthorizationServerHost authorizationServer, IClientAuthenticationModule clientAuthenticationModule)
3940
: base(MessageTypes, InitializeBindingElements(authorizationServer, clientAuthenticationModule)) {
4041
Requires.NotNull(authorizationServer, "authorizationServer");
@@ -106,13 +107,14 @@ protected override IDirectedProtocolMessage ReadFromRequestCore(HttpRequestBase
106107
/// Initializes the binding elements for the OAuth channel.
107108
/// </summary>
108109
/// <param name="authorizationServer">The authorization server.</param>
110+
/// <param name="clientAuthenticationModule">The aggregating client authentication module.</param>
109111
/// <returns>
110112
/// An array of binding elements used to initialize the channel.
111113
/// </returns>
112114
private static IChannelBindingElement[] InitializeBindingElements(IAuthorizationServerHost authorizationServer, IClientAuthenticationModule clientAuthenticationModule) {
113115
Requires.NotNull(authorizationServer, "authorizationServer");
114116
Requires.NotNull(clientAuthenticationModule, "clientAuthenticationModule");
115-
117+
116118
var bindingElements = new List<IChannelBindingElement>();
117119

118120
// The order they are provided is used for outgoing messgaes, and reversed for incoming messages.

0 commit comments

Comments
 (0)