summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.OAuth.Common/OAuth/ChannelElements/OAuthIdentity.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2012-02-08 07:49:57 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2012-02-08 17:30:02 -0800
commitdcf7af7bcef6724ba73e5cf952eaf554f4da4e9f (patch)
tree3e097dff0522b75ce3630ca8e017971cfe5724a0 /src/DotNetOpenAuth.OAuth.Common/OAuth/ChannelElements/OAuthIdentity.cs
parentbef6c27a1b50519f23a5308547d65b55c8e98868 (diff)
downloadDotNetOpenAuth-dcf7af7bcef6724ba73e5cf952eaf554f4da4e9f.zip
DotNetOpenAuth-dcf7af7bcef6724ba73e5cf952eaf554f4da4e9f.tar.gz
DotNetOpenAuth-dcf7af7bcef6724ba73e5cf952eaf554f4da4e9f.tar.bz2
Added DotNetOpenAuth.OAuth.Common to contain dependencies shared between OAuth 1 and OAuth 2.
Related to and closes #71
Diffstat (limited to 'src/DotNetOpenAuth.OAuth.Common/OAuth/ChannelElements/OAuthIdentity.cs')
-rw-r--r--src/DotNetOpenAuth.OAuth.Common/OAuth/ChannelElements/OAuthIdentity.cs64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.OAuth.Common/OAuth/ChannelElements/OAuthIdentity.cs b/src/DotNetOpenAuth.OAuth.Common/OAuth/ChannelElements/OAuthIdentity.cs
new file mode 100644
index 0000000..1f9fbbc
--- /dev/null
+++ b/src/DotNetOpenAuth.OAuth.Common/OAuth/ChannelElements/OAuthIdentity.cs
@@ -0,0 +1,64 @@
+//-----------------------------------------------------------------------
+// <copyright file="OAuthIdentity.cs" company="Outercurve Foundation">
+// Copyright (c) Outercurve Foundation. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.OAuth.ChannelElements {
+ using System;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Diagnostics.Contracts;
+ using System.Runtime.InteropServices;
+ using System.Security.Principal;
+ using DotNetOpenAuth.Messaging;
+
+ /// <summary>
+ /// Represents an OAuth consumer that is impersonating a known user on the system.
+ /// </summary>
+ [SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Justification = "Not cocreatable.")]
+ [Serializable]
+ [ComVisible(true)]
+ public class OAuthIdentity : IIdentity {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="OAuthIdentity"/> class.
+ /// </summary>
+ /// <param name="username">The username.</param>
+ internal OAuthIdentity(string username) {
+ Requires.NotNullOrEmpty(username, "username");
+ this.Name = username;
+ }
+
+ #region IIdentity Members
+
+ /// <summary>
+ /// Gets the type of authentication used.
+ /// </summary>
+ /// <value>The constant "OAuth"</value>
+ /// <returns>
+ /// The type of authentication used to identify the user.
+ /// </returns>
+ public string AuthenticationType {
+ get { return "OAuth"; }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether the user has been authenticated.
+ /// </summary>
+ /// <value>The value <c>true</c></value>
+ /// <returns>true if the user was authenticated; otherwise, false.
+ /// </returns>
+ public bool IsAuthenticated {
+ get { return true; }
+ }
+
+ /// <summary>
+ /// Gets the name of the user who authorized the OAuth token the consumer is using for authorization.
+ /// </summary>
+ /// <returns>
+ /// The name of the user on whose behalf the code is running.
+ /// </returns>
+ public string Name { get; private set; }
+
+ #endregion
+ }
+}