summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.AspNet/AuthenticationResult.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.AspNet/AuthenticationResult.cs')
-rw-r--r--src/DotNetOpenAuth.AspNet/AuthenticationResult.cs128
1 files changed, 70 insertions, 58 deletions
diff --git a/src/DotNetOpenAuth.AspNet/AuthenticationResult.cs b/src/DotNetOpenAuth.AspNet/AuthenticationResult.cs
index 24ef18d..84d9abe 100644
--- a/src/DotNetOpenAuth.AspNet/AuthenticationResult.cs
+++ b/src/DotNetOpenAuth.AspNet/AuthenticationResult.cs
@@ -11,40 +11,84 @@ namespace DotNetOpenAuth.AspNet {
using DotNetOpenAuth.Messaging;
/// <summary>
- /// Represents the result of OAuth & OpenId authentication
+ /// Represents the result of OAuth or OpenID authentication.
/// </summary>
public class AuthenticationResult {
+ #region Constants and Fields
+
/// <summary>
/// Returns an instance which indicates failed authentication.
/// </summary>
- [SuppressMessage(
- "Microsoft.Security",
- "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
+ [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
Justification = "This type is immutable.")]
public static readonly AuthenticationResult Failed = new AuthenticationResult(isSuccessful: false);
+ #endregion
+
+ #region Constructors and Destructors
+
/// <summary>
- /// Gets a value indicating whether the authentication step is successful.
+ /// Initializes a new instance of the <see cref="AuthenticationResult"/> class.
/// </summary>
- /// <value>
- /// <c>true</c> if authentication is successful; otherwise, <c>false</c>.
- /// </value>
- public bool IsSuccessful { get; private set; }
+ /// <param name="isSuccessful">
+ /// if set to <c>true</c> [is successful].
+ /// </param>
+ public AuthenticationResult(bool isSuccessful)
+ : this(isSuccessful, provider: null, providerUserId: null, userName: null, extraData: null) {}
/// <summary>
- /// Gets the provider's name.
+ /// Initializes a new instance of the <see cref="AuthenticationResult"/> class.
/// </summary>
- public string Provider { get; private set; }
+ /// <param name="exception">
+ /// The exception.
+ /// </param>
+ public AuthenticationResult(Exception exception)
+ : this(isSuccessful: false) {
+ if (exception == null) {
+ throw new ArgumentNullException("exception");
+ }
+
+ this.Error = exception;
+ }
/// <summary>
- /// Gets the unique user id that is returned from the provider.
+ /// Initializes a new instance of the <see cref="AuthenticationResult"/> class.
/// </summary>
- public string ProviderUserId { get; private set; }
+ /// <param name="isSuccessful">
+ /// if set to <c>true</c> [is successful].
+ /// </param>
+ /// <param name="provider">
+ /// The provider.
+ /// </param>
+ /// <param name="providerUserId">
+ /// The provider user id.
+ /// </param>
+ /// <param name="userName">
+ /// Name of the user.
+ /// </param>
+ /// <param name="extraData">
+ /// The extra data.
+ /// </param>
+ public AuthenticationResult(
+ bool isSuccessful, string provider, string providerUserId, string userName, IDictionary<string, string> extraData) {
+ this.IsSuccessful = isSuccessful;
+ this.Provider = provider;
+ this.ProviderUserId = providerUserId;
+ this.UserName = userName;
+ if (extraData != null) {
+ // wrap extraData in a read-only dictionary
+ this.ExtraData = new ReadOnlyDictionary<string, string>(extraData);
+ }
+ }
+
+ #endregion
+
+ #region Public Properties
/// <summary>
- /// Gets the user name that is returned from the provider.
+ /// Gets the error that may have occured during the authentication process
/// </summary>
- public string UserName { get; private set; }
+ public Exception Error { get; private set; }
/// <summary>
/// Gets the optional extra data that may be returned from the provider
@@ -52,57 +96,25 @@ namespace DotNetOpenAuth.AspNet {
public IDictionary<string, string> ExtraData { get; private set; }
/// <summary>
- /// Gets the error that may have occured during the authentication process
+ /// Gets a value indicating whether the authentication step is successful.
/// </summary>
- public Exception Error { get; private set; }
+ /// <value> <c>true</c> if authentication is successful; otherwise, <c>false</c> . </value>
+ public bool IsSuccessful { get; private set; }
/// <summary>
- /// Initializes a new instance of the <see cref="AuthenticationResult"/> class.
+ /// Gets the provider's name.
/// </summary>
- /// <param name="isSuccessful">if set to <c>true</c> [is successful].</param>
- public AuthenticationResult(bool isSuccessful) :
- this(isSuccessful,
- provider: null,
- providerUserId: null,
- userName: null,
- extraData: null) {
- }
+ public string Provider { get; private set; }
/// <summary>
- /// Initializes a new instance of the <see cref="AuthenticationResult"/> class.
+ /// Gets the unique user id that is returned from the provider.
/// </summary>
- /// <param name="exception">The exception.</param>
- public AuthenticationResult(Exception exception)
- : this(isSuccessful: false) {
- if (exception == null) {
- throw new ArgumentNullException("exception");
- }
-
- Error = exception;
- }
+ public string ProviderUserId { get; private set; }
/// <summary>
- /// Initializes a new instance of the <see cref="AuthenticationResult"/> class.
+ /// Gets the user name that is returned from the provider.
/// </summary>
- /// <param name="isSuccessful">if set to <c>true</c> [is successful].</param>
- /// <param name="provider">The provider.</param>
- /// <param name="providerUserId">The provider user id.</param>
- /// <param name="userName">Name of the user.</param>
- /// <param name="extraData">The extra data.</param>
- public AuthenticationResult(
- bool isSuccessful,
- string provider,
- string providerUserId,
- string userName,
- IDictionary<string, string> extraData) {
- IsSuccessful = isSuccessful;
- Provider = provider;
- ProviderUserId = providerUserId;
- UserName = userName;
- if (extraData != null) {
- // wrap extraData in a read-only dictionary
- ExtraData = new ReadOnlyDictionary<string, string>(extraData);
- }
- }
+ public string UserName { get; private set; }
+ #endregion
}
-} \ No newline at end of file
+}