diff options
-rw-r--r-- | src/DotNetOpenAuth/OAuth/ChannelElements/OAuthPrincipal.cs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/DotNetOpenAuth/OAuth/ChannelElements/OAuthPrincipal.cs b/src/DotNetOpenAuth/OAuth/ChannelElements/OAuthPrincipal.cs index 82ecb0a..442cf30 100644 --- a/src/DotNetOpenAuth/OAuth/ChannelElements/OAuthPrincipal.cs +++ b/src/DotNetOpenAuth/OAuth/ChannelElements/OAuthPrincipal.cs @@ -2,8 +2,8 @@ // <copyright file="OAuthPrincipal.cs" company="Andrew Arnott"> // Copyright (c) Andrew Arnott. All rights reserved. // </copyright> -//----------------------------------------------------------------------- - +//-----------------------------------------------------------------------
+
namespace DotNetOpenAuth.OAuth.ChannelElements { using System; using System.Collections.Generic; @@ -11,7 +11,8 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { using System.Diagnostics.Contracts; using System.Linq; using System.Runtime.InteropServices; - using System.Security.Principal; + using System.Security.Principal;
+ using System.Collections.ObjectModel;
/// <summary> /// Represents an OAuth consumer that is impersonating a known user on the system. @@ -61,6 +62,23 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { /// <value>A non-empty string.</value> public string AccessToken { get; private set; } + /// <summary>
+ /// Gets the roles that this principal has as a ReadOnlyCollection.
+ /// </summary> + public ReadOnlyCollection<string> Roles
+ {
+ get { return new ReadOnlyCollection<string> (roles.ToList()); }
+ } + + /// <summary>
+ /// Creates a new instance of GenericPrincipal based on this OAuthPrincipal.
+ /// </summary>
+ /// <returns>A new instance of GenericPrincipal with a GenericIdentity, having the same username and roles as this OAuthPrincipal and OAuthIdentity</returns> + public GenericPrincipal CreateGenericPrincipal()
+ {
+ return new GenericPrincipal( new GenericIdentity(this.Identity.Name), roles.ToArray());
+ } + #region IPrincipal Members /// <summary> |