summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2011-09-23 05:28:28 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2011-09-23 05:28:28 -0700
commit1360edabba8b78621b016a5fd95f2967c2659a4d (patch)
treeb48d6df55d0f633faf4adbf3ec3eed0583f8d318 /src
parentf16525005555b86151b7a1c741aa29550635108a (diff)
parent1e36184240227b505d35e1ea9c04bf0ddb9e2800 (diff)
downloadDotNetOpenAuth-1360edabba8b78621b016a5fd95f2967c2659a4d.zip
DotNetOpenAuth-1360edabba8b78621b016a5fd95f2967c2659a4d.tar.gz
DotNetOpenAuth-1360edabba8b78621b016a5fd95f2967c2659a4d.tar.bz2
Merge pull request #50 from oyvindkinsey/master
Improvements to the OAuthPrincipal
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth/OAuth/ChannelElements/OAuthPrincipal.cs24
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>