added HasClaim, FindFirst, FindAll System.Security.Claims.ClaimsPrincipal method...
authorJonathan Channon <jonathan.channon@gmail.com>
Wed, 13 Aug 2014 16:57:55 +0000 (17:57 +0100)
committerJonathan Channon <jonathan.channon@gmail.com>
Wed, 13 Aug 2014 16:57:55 +0000 (17:57 +0100)
mcs/class/corlib/System.Security.Claims/ClaimsPrincipal.cs [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index cf1fe29..8063ada
@@ -186,6 +186,29 @@ namespace System.Security.Claims {
                        }
                        return false;
                }
+
+               public virtual bool HasClaim(string type, string value)
+               {
+                       foreach(var claim in Claims){
+                               if (claim.Type == type && claim.Value == value)
+                                       return true;
+                       }
+                       return false;
+               }
+
+               public virtual Claim FindFirst(string type)
+               {
+                       if (type == null)
+                               throw new ArgumentNullException ("type");
+                       return FindFirst(x => x.Type == type);
+               }
+
+               public virtual IEnumerable<Claim> FindAll(string type)
+               {
+                       if (type == null)
+                               throw new ArgumentNullException ("type");
+                       return FindAll(x => x.Type == type);
+               }
                
        }
 }