A generic Principal interface (IPrincipal) to enable strong typing of custom Identities (IIdentity)

I’ve been playing in the security rhelm lately and came up with the

public interface IPrincipal<T> where  T : IIdentity {

      T Identity { get; }
      bool IsInRole(string role);

This enables me to retrieve any custom properties from my custom identity without boxing and unboxing:

public interface ICustomIdentity : IIdentity {
    string CustomProperty { get; }

The next step would be to get this to work with impersonation. I can’t store this on the Thread (Thread.CurrentPrincipal) but I can create my own registry where I can retrieve it from.

I am thinking that this might be resolved if I were simply using CardSpace in my application.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s