Null Exception in System.Security.Claims
authorLucas <LRFalk01@gmail.com>
Sun, 1 Jun 2014 20:50:38 +0000 (16:50 -0400)
committerLucas <LRFalk01@gmail.com>
Sun, 1 Jun 2014 22:21:11 +0000 (18:21 -0400)
This fixed a runtime exception when trying to get a ClaimsPrincipal from an IIdentity.
Noticed this work working with aspnet Identity in a Web Api 2 controller.
Exception fired when running User.Identity.IsAuthenticated.

Exception detail:
http://falk.pw:7777/tocehuhemo.xml

mcs/class/corlib/System.Security.Claims/ClaimsIdentity.cs
mcs/class/corlib/System.Security.Claims/ClaimsPrincipal.cs

index 852e4f40085e2d6e3fa8e02577b540d503bb7ab0..7b62592da1555b1ad7bfe4f1cb9f69b274ef8cbe 100644 (file)
@@ -97,8 +97,10 @@ namespace System.Security.Claims {
                                foreach (var c in ci.Claims)
                                        this.claims.Add (c);
                                
-                               foreach (var c in claims)
-                                       this.claims.Add (c);
+                               if (claims != null) {
+                                       foreach (var c in claims)
+                                               this.claims.Add (c);
+                               }
                                Label = ci.Label;
                                NameClaimType = ci.NameClaimType;
                                RoleClaimType = ci.RoleClaimType;
@@ -264,4 +266,4 @@ namespace System.Security.Claims {
                }
        }
 }
-#endif
\ No newline at end of file
+#endif
index d3827b8d1a2f7718c6a17c64c4b4e7b34bf29503..76fb35f297688be7159d1dc4f8c4631386a014ac 100644 (file)
@@ -66,7 +66,9 @@ namespace System.Security.Claims {
                {
                        if (identity == null)
                                throw new ArgumentNullException ("identity");
-                       // TODO
+
+                       identities = new List<ClaimsIdentity> ();
+                       identities.Add (new ClaimsIdentity (identity))
                }
 
                public ClaimsPrincipal (IPrincipal principal)
@@ -187,4 +189,4 @@ namespace System.Security.Claims {
                
        }
 }
-#endif
\ No newline at end of file
+#endif