3 types derived from ClaimsIdentity
Microsoft.AspNetCore.Antiforgery.Test (1)
System.Security.Claims (1)
System.Security.Principal.Windows (1)
257 instantiations of ClaimsIdentity
Aspire.Dashboard (5)
Aspire.Hosting (1)
BasicTestApp (2)
BasicWebSite (1)
Certificate.Sample (1)
ClaimsTransformation (2)
CookiePolicySample (1)
Cookies (1)
CookieSample (1)
CookieSessionSample (1)
CustomAuthorizationFailureResponse (1)
CustomPolicyProvider (1)
HtmlGenerationWebSite (1)
Identity.DefaultUI.WebSite (1)
Microsoft.AspNetCore.Antiforgery.Test (26)
Microsoft.AspNetCore.Authentication (1)
Microsoft.AspNetCore.Authentication.Certificate (1)
Microsoft.AspNetCore.Authentication.Cookies (2)
Microsoft.AspNetCore.Authentication.Core.Test (12)
AuthenticationServiceTests.cs (11)
92await context.SignInAsync("signin", new ClaimsPrincipal(new ClaimsIdentity("whatever")), null);
107await context.SignInAsync("signin", new ClaimsPrincipal(new ClaimsIdentity("whatever")), null);
123await context.SignInAsync("uber", new ClaimsPrincipal(new ClaimsIdentity("whatever")), null);
124var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync("base", new ClaimsPrincipal(new ClaimsIdentity("whatever")), null));
127await context.SignInAsync("signin", new ClaimsPrincipal(new ClaimsIdentity("whatever")), null);
128ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync("signout", new ClaimsPrincipal(new ClaimsIdentity("whatever")), null));
170ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync(new ClaimsPrincipal(new ClaimsIdentity("whatever"))));
189await context.SignInAsync(new ClaimsPrincipal(new ClaimsIdentity("whatever")));
207await context.SignInAsync(new ClaimsPrincipal(new ClaimsIdentity("whatever")));
225var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync(new ClaimsPrincipal(new ClaimsIdentity("whatever"))));
259new ClaimsPrincipal(new ClaimsIdentity("whatever")),
Microsoft.AspNetCore.Authentication.Negotiate (1)
Microsoft.AspNetCore.Authentication.OAuth (1)
Microsoft.AspNetCore.Authentication.Test (78)
CookieTests.cs (30)
164var user = new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"));
174new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))),
318var user = new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"));
534new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))),
575new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies")))));
606new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies")))));
634new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies")))));
671new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies")))));
709ctx.ReplacePrincipal(new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice2", "Cookies2"))));
716new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies")))));
740ctx.ReplacePrincipal(new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice2", "Cookies2"))));
749new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies")))));
792new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies")))));
848new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies")))));
907new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies")))));
953new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies")))));
1005new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies")))));
1217new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))));
1356app.Run(context => context.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(new ClaimsIdentity("whatever"))));
1384app.Run(context => context.SignInAsync("Cookie1", new ClaimsPrincipal(new ClaimsIdentity("whatever"))));
1413new ClaimsPrincipal(new ClaimsIdentity("whatever")))));
1435app.Map("/login", signoutApp => signoutApp.Run(context => context.SignInAsync("Cookies", new ClaimsPrincipal(new ClaimsIdentity("whatever")))));
1565new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", CookieAuthenticationDefaults.AuthenticationScheme))),
1589new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", CookieAuthenticationDefaults.AuthenticationScheme))));
1611new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", CookieAuthenticationDefaults.AuthenticationScheme))));
1634new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", CookieAuthenticationDefaults.AuthenticationScheme))));
1656new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", CookieAuthenticationDefaults.AuthenticationScheme))),
1703new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))),
1771new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))));
1842var id = new ClaimsIdentity("xform");
Microsoft.AspNetCore.Authentication.Twitter (1)
Microsoft.AspNetCore.Authorization.Policy (1)
Microsoft.AspNetCore.Authorization.Test (39)
DefaultAuthorizationServiceTests.cs (30)
41var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim("Permission", "CanViewPage") }));
62var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim("Permission", "CanViewPage") }, "Basic"));
78new ClaimsIdentity(
206new ClaimsIdentity(
228new ClaimsIdentity(
249new ClaimsIdentity(
270new ClaimsIdentity(
302var user = new ClaimsPrincipal(new ClaimsIdentity());
318new ClaimsIdentity(
352new ClaimsIdentity(
374new ClaimsIdentity(
395new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, "Name") }, "AuthType")
412new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Role, "Admin") }, "AuthType")
429new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Role, "Users") }, "AuthType"));
445new ClaimsIdentity(
466new ClaimsIdentity(
493new ClaimsIdentity(
519new ClaimsIdentity(
544var identity = new ClaimsIdentity("AuthType", "Name", "Role");
566var identity = new ClaimsIdentity("AuthType", "Name", "Role");
588var user = new ClaimsPrincipal(new ClaimsIdentity());
589user.AddIdentity(new ClaimsIdentity(
613var user = new ClaimsPrincipal(new ClaimsIdentity());
730new ClaimsIdentity(
758new ClaimsIdentity(
785new ClaimsIdentity(
849new ClaimsIdentity(
892new ClaimsIdentity(
913new ClaimsIdentity(
1061var id = new ClaimsIdentity();
Microsoft.AspNetCore.Components.Authorization.Tests (2)
Microsoft.AspNetCore.Components.Server (1)
Microsoft.AspNetCore.Components.Server.Tests (2)
Microsoft.AspNetCore.CookiePolicy.Test (2)
Microsoft.AspNetCore.Http (1)
Microsoft.AspNetCore.Http.Connections.Tests (5)
Microsoft.AspNetCore.Http.Tests (1)
Microsoft.AspNetCore.Identity (3)
Microsoft.AspNetCore.Identity.InMemory.Test (2)
Microsoft.AspNetCore.Identity.Test (17)
Microsoft.AspNetCore.Mvc.Core.Test (2)
Microsoft.AspNetCore.Mvc.TagHelpers.Test (2)
Microsoft.AspNetCore.Owin.Tests (3)
Microsoft.AspNetCore.Shared.Tests (5)
Microsoft.AspNetCore.SignalR.Specification.Tests (1)
Microsoft.AspNetCore.SignalR.Tests (2)
Microsoft.AspNetCore.SignalR.Tests.Utils (1)
Microsoft.AspNetCore.Tests (1)
Microsoft.Extensions.Identity.Core (1)
PathSchemeSelection (2)
SecurityWebSite (5)
StaticFilesAuth (1)
System.Security.Claims (12)
System\Security\Claims\ClaimsIdentity.cs (8)
64/// <remarks><seealso cref="ClaimsIdentity(IIdentity, IEnumerable{Claim}, string, string, string)"/> for details on how internal values are set.</remarks>
75/// <remarks><seealso cref="ClaimsIdentity(IIdentity, IEnumerable{Claim}, string, string, string)"/> for details on how internal values are set.</remarks>
96/// <remarks><seealso cref="ClaimsIdentity(IIdentity, IEnumerable{Claim}, string, string, string)"/> for details on how internal values are set.</remarks>
107/// <remarks><seealso cref="ClaimsIdentity(IIdentity, IEnumerable{Claim}, string, string, string)"/> for details on how internal values are set.</remarks>
119/// <remarks><seealso cref="ClaimsIdentity(IIdentity, IEnumerable{Claim}, string, string, string)"/> for details on how internal values are set.</remarks>
132/// <remarks><seealso cref="ClaimsIdentity(IIdentity, IEnumerable{Claim}, string, string, string)"/> for details on how internal values are set.</remarks>
458return new ClaimsIdentity(this, _stringComparison);
820_actor = new ClaimsIdentity(reader);
373 references to ClaimsIdentity
Aspire.Dashboard (9)
BasicTestApp (1)
CustomPolicyProvider (1)
dotnet-svcutil-lib (1)
HtmlGenerationWebSite (2)
Identity.DefaultUI.WebSite (1)
Microsoft.AspNetCore.Antiforgery (10)
Microsoft.AspNetCore.Antiforgery.Test (38)
Microsoft.AspNetCore.Authentication (19)
TicketSerializer.cs (17)
65foreach (var identity in principal.Identities)
77/// <param name="identity">The <see cref="ClaimsIdentity" />.</param>
78protected virtual void WriteIdentity(BinaryWriter writer, ClaimsIdentity identity)
86WriteWithDefault(writer, identity.NameClaimType, ClaimsIdentity.DefaultNameClaimType);
87WriteWithDefault(writer, identity.RoleClaimType, ClaimsIdentity.DefaultRoleClaimType);
125WriteWithDefault(writer, claim.Type, claim.Subject?.NameClaimType ?? ClaimsIdentity.DefaultNameClaimType);
128WriteWithDefault(writer, claim.Issuer, ClaimsIdentity.DefaultIssuer);
165var identities = new ClaimsIdentity[count];
177/// Reads a <see cref="ClaimsIdentity"/> from a <see cref="BinaryReader"/>.
180/// <returns>The read <see cref="ClaimsIdentity"/>.</returns>
181protected virtual ClaimsIdentity ReadIdentity(BinaryReader reader)
186var nameClaimType = ReadWithDefault(reader, ClaimsIdentity.DefaultNameClaimType);
187var roleClaimType = ReadWithDefault(reader, ClaimsIdentity.DefaultRoleClaimType);
193var identity = new ClaimsIdentity(authenticationType, nameClaimType, roleClaimType);
223/// <param name="identity">The <see cref="ClaimsIdentity"/> to add the claim to.</param>
225protected virtual Claim ReadClaim(BinaryReader reader, ClaimsIdentity identity)
233var issuer = ReadWithDefault(reader, ClaimsIdentity.DefaultIssuer);
Microsoft.AspNetCore.Authentication.Abstractions (3)
Microsoft.AspNetCore.Authentication.Certificate (1)
Microsoft.AspNetCore.Authentication.Cookies (1)
Microsoft.AspNetCore.Authentication.Core.Test (1)
Microsoft.AspNetCore.Authentication.Facebook (1)
Microsoft.AspNetCore.Authentication.Google (1)
Microsoft.AspNetCore.Authentication.MicrosoftAccount (1)
Microsoft.AspNetCore.Authentication.Negotiate (4)
Microsoft.AspNetCore.Authentication.OAuth (14)
Microsoft.AspNetCore.Authentication.OpenIdConnect (5)
Microsoft.AspNetCore.Authentication.Test (42)
Microsoft.AspNetCore.Authentication.Twitter (5)
Microsoft.AspNetCore.Authorization (1)
Microsoft.AspNetCore.Authorization.Policy (2)
Microsoft.AspNetCore.Authorization.Test (5)
Microsoft.AspNetCore.Components.Authorization (3)
Microsoft.AspNetCore.Components.Server.Tests (1)
Microsoft.AspNetCore.Components.WebAssembly.Server (2)
Microsoft.AspNetCore.Http.Connections (4)
Microsoft.AspNetCore.Identity (3)
Microsoft.AspNetCore.Identity.InMemory.Test (2)
Microsoft.AspNetCore.Identity.Test (15)
Microsoft.AspNetCore.Mvc.Core (2)
Microsoft.AspNetCore.Mvc.Core.Test (1)
Microsoft.AspNetCore.Mvc.TagHelpers.Test (4)
Microsoft.AspNetCore.Shared.Tests (7)
Microsoft.AspNetCore.Tests (2)
Microsoft.Extensions.Identity.Core (10)
mscorlib (1)
netstandard (1)
OpenIdConnectSample (1)
PathSchemeSelection (1)
SecurityWebSite (4)
System.Security.Claims (138)
System\Security\Claims\Claim.cs (42)
36private readonly ClaimsIdentity? _subject;
57/// <param name="subject"> the value for <see cref="Claim.Subject"/>, which is the <see cref="ClaimsIdentity"/> that has these claims.</param>
59public Claim(BinaryReader reader, ClaimsIdentity? subject)
72_type = ClaimsIdentity.DefaultNameClaimType;
76_type = ClaimsIdentity.DefaultRoleClaimType;
101_issuer = ClaimsIdentity.DefaultIssuer;
115_originalIssuer = ClaimsIdentity.DefaultIssuer;
148/// <see cref="Claim.Issuer"/> is set to <see cref="ClaimsIdentity.DefaultIssuer"/>,
150/// <see cref="Claim.OriginalIssuer"/> is set to <see cref="ClaimsIdentity.DefaultIssuer"/>, and
153/// <seealso cref="ClaimsIdentity"/>
157: this(type, value, ClaimValueTypes.String, ClaimsIdentity.DefaultIssuer, ClaimsIdentity.DefaultIssuer, (ClaimsIdentity?)null)
169/// <see cref="Claim.Issuer"/> is set to <see cref="ClaimsIdentity.DefaultIssuer"/>,
170/// <see cref="Claim.OriginalIssuer"/> is set to <see cref="ClaimsIdentity.DefaultIssuer"/>,
173/// <seealso cref="ClaimsIdentity"/>
177: this(type, value, valueType, ClaimsIdentity.DefaultIssuer, ClaimsIdentity.DefaultIssuer, (ClaimsIdentity?)null)
187/// <param name="issuer">The claim issuer. If this parameter is empty or null, then <see cref="ClaimsIdentity.DefaultIssuer"/> is used.</param>
193/// <seealso cref="ClaimsIdentity"/>
197: this(type, value, valueType, issuer, issuer, (ClaimsIdentity?)null)
207/// <param name="issuer">The claim issuer. If this parameter is empty or null, then <see cref="ClaimsIdentity.DefaultIssuer"/> is used.</param>
213/// <seealso cref="ClaimsIdentity"/>
217: this(type, value, valueType, issuer, originalIssuer, (ClaimsIdentity?)null)
227/// <param name="issuer">The claim issuer. If this parameter is empty or null, then <see cref="ClaimsIdentity.DefaultIssuer"/> is used.</param>
231/// <seealso cref="ClaimsIdentity"/>
234public Claim(string type, string value, string? valueType, string? issuer, string? originalIssuer, ClaimsIdentity? subject)
246/// <param name="issuer">The claim issuer. If this parameter is empty or null, then <see cref="ClaimsIdentity.DefaultIssuer"/> is used.</param>
251internal Claim(string type, string value, string? valueType, string? issuer, string? originalIssuer, ClaimsIdentity? subject, string? propertyKey, string? propertyValue)
259_issuer = string.IsNullOrEmpty(issuer) ? ClaimsIdentity.DefaultIssuer : issuer;
277: this(other, (other == null ? (ClaimsIdentity?)null : other._subject))
285/// <param name="subject">the <see cref="ClaimsIdentity"/> to assign to <see cref="Claim.Subject"/>.</param>
288protected Claim(Claim other, ClaimsIdentity? subject)
349public ClaimsIdentity? Subject
385return Clone((ClaimsIdentity?)null);
391/// <param name="identity">the value for <see cref="Claim.Subject"/>, which is the <see cref="ClaimsIdentity"/> that has these claims.</param>
393public virtual Claim Clone(ClaimsIdentity? identity)
420if (string.Equals(_type, ClaimsIdentity.DefaultNameClaimType))
424else if (string.Equals(_type, ClaimsIdentity.DefaultRoleClaimType))
439if (!string.Equals(_issuer, ClaimsIdentity.DefaultIssuer, StringComparison.Ordinal))
449else if (!string.Equals(_originalIssuer, ClaimsIdentity.DefaultIssuer))
System\Security\Claims\ClaimsIdentity.cs (51)
33private ClaimsIdentity? _actor;
53/// Initializes an instance of <see cref="ClaimsIdentity"/>.
61/// Initializes an instance of <see cref="ClaimsIdentity"/>.
71/// Initializes an instance of <see cref="ClaimsIdentity"/>.
83/// Initializes an instance of <see cref="ClaimsIdentity"/>.
92/// Initializes an instance of <see cref="ClaimsIdentity"/>.
103/// Initializes an instance of <see cref="ClaimsIdentity"/>.
114/// Initializes an instance of <see cref="ClaimsIdentity"/>.
117/// <param name="nameType">The <see cref="Claim.Type"/> used when obtaining the value of <see cref="ClaimsIdentity.Name"/>.</param>
126/// Initializes an instance of <see cref="ClaimsIdentity"/>.
130/// <param name="nameType">The <see cref="Claim.Type"/> used when obtaining the value of <see cref="ClaimsIdentity.Name"/>.</param>
139/// Initializes an instance of <see cref="ClaimsIdentity"/>.
144/// <param name="nameType">The <see cref="Claim.Type"/> used when obtaining the value of <see cref="ClaimsIdentity.Name"/>.</param>
146/// <remarks>If 'identity' is a <see cref="ClaimsIdentity"/>, then there are potentially multiple sources for AuthenticationType, NameClaimType, RoleClaimType.
151/// <exception cref="InvalidOperationException">if 'identity' is a <see cref="ClaimsIdentity"/> and <see cref="ClaimsIdentity.Actor"/> results in a circular reference back to 'this'.</exception>
154ClaimsIdentity? claimsIdentity = identity as ClaimsIdentity;
197/// Initializes an instance of <see cref="ClaimsIdentity"/> using a <see cref="BinaryReader"/>.
200/// <param name="reader">a <see cref="BinaryReader"/> pointing to a <see cref="ClaimsIdentity"/>.</param>
210/// Initializes an instance of <see cref="ClaimsIdentity" /> with the specified <see cref="BinaryReader" />.
212/// <param name="reader">A <see cref="BinaryReader" /> pointing to a <see cref="ClaimsIdentity" />.</param>
232/// <param name="other"><see cref="ClaimsIdentity"/> to copy.</param>
234protected ClaimsIdentity(ClaimsIdentity other)
241/// Initializes a new instance of the <see cref="ClaimsIdentity" /> class from an existing
242/// <see cref="ClaimsIdentity" /> instance.
244/// <param name="other">The <see cref="ClaimsIdentity" /> to copy.</param>
252protected ClaimsIdentity(ClaimsIdentity other, StringComparison stringComparison)
261/// Initializes a new instance of the <see cref="ClaimsIdentity" /> class.
273/// <paramref name="identity"/> is a <see cref="ClaimsIdentity"/> and <see cref="Actor" />
297/// Initializes an instance of <see cref="ClaimsIdentity"/> from a serialized stream created via
312/// Gets the authentication type that can be used to determine how this <see cref="ClaimsIdentity"/> authenticated to an authority.
328/// Gets or sets a <see cref="ClaimsIdentity"/> that was granted delegation rights.
331public ClaimsIdentity? Actor
348/// Gets or sets a context that was used to create this <see cref="ClaimsIdentity"/>.
357/// Gets the claims as <see cref="IEnumerable{Claim}"/>, associated with this <see cref="ClaimsIdentity"/>.
404/// Allow the association of claims with this instance of <see cref="ClaimsIdentity"/>.
405/// The claims will not be serialized or added in Clone(). They will be included in searches, finds and returned from the call to <see cref="ClaimsIdentity.Claims"/>.
410/// Gets or sets the label for this <see cref="ClaimsIdentity"/>
419/// Gets the Name of this <see cref="ClaimsIdentity"/>.
438/// Gets the value that identifies 'Name' claims. This is used when returning the property <see cref="ClaimsIdentity.Name"/>.
454/// Creates a new instance of <see cref="ClaimsIdentity"/> with values copied from this object.
456public virtual ClaimsIdentity Clone()
736private void Initialize(ClaimsIdentity other)
760/// <param name="reader">a <see cref="BinaryReader"/> pointing to a <see cref="ClaimsIdentity"/>.</param>
789_nameClaimType = ClaimsIdentity.DefaultNameClaimType;
799_roleClaimType = ClaimsIdentity.DefaultRoleClaimType;
886if (!string.Equals(_nameClaimType, ClaimsIdentity.DefaultNameClaimType, StringComparison.Ordinal))
892if (!string.Equals(_roleClaimType, ClaimsIdentity.DefaultRoleClaimType, StringComparison.Ordinal))
977private bool IsCircular(ClaimsIdentity subject)
984ClaimsIdentity currSubject = subject;
System.Security.Principal.Windows (1)
System.ServiceModel.Primitives (1)