DisplayClaimCollection GetDisplayClaimsFromClaimTypes(IEnumerable <string> claimTypes) { DisplayClaimCollection result = new DisplayClaimCollection(); foreach (string claimType in claimTypes) { result.Add(new DisplayClaim(claimType)); } return(result); }
/// <summary> /// Gets the DisplayToken. /// </summary> /// <param name="requestedDisplayTokenLanguage">The requested DisplayToken language. This is an optional parameter and may be null.</param> /// <param name="subject">The IClaimsIdentity representing the collection of claims that will be placed in the issued security token.</param> /// <returns>The DisplayToken to be included in the response.</returns> /// <remarks> /// This operation might expose information about the user. The code below is intended for illustrative purposes only. /// </remarks> protected override DisplayToken GetDisplayToken(string requestedDisplayTokenLanguage, IClaimsIdentity subject) { string localizedDisplayTag; // Try looking up the localized DisplayClaim table for the requestedDisplayTokenLanguage if (!localizedDisplayClaimTable.TryGetValue(requestedDisplayTokenLanguage, out localizedDisplayTag)) { localizedDisplayTag = "Given Name"; // default to English } DisplayClaimCollection collection = new DisplayClaimCollection(); DisplayClaim claim = new DisplayClaim(ClaimTypes.GivenName); claim.DisplayTag = localizedDisplayTag; // The input subject can be used to further qualify the DisplayClaim being generated, such as including an optional DisplayValue. collection.Add(claim); DisplayToken token = new DisplayToken(requestedDisplayTokenLanguage, collection); return(token); }