How should you build the class constructor?

Posted by: Pdfprep Category: 70-486 Tags: , ,

DRAG DROP

You are developing an ASP.NET MVC application that authenticates a user by using claims-based authentication.

The application must:

You need to implement authentication.

How should you build the class constructor? (To answer, drag the appropriate code segment to the correct location or locations in the answer area. Each code segment may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.)

Answer:

Explanation:

Similar example:

For Box 1, see line 15.

For Box 2, see line 22.

For Box 3, see line 22.

For Box 4, see line 26.

using System;

02 using System.Collections.Generic;

03 using System.Linq;

04 using System.Web;

05 using Microsoft.IdentityModel.Claims;

06

07 namespace MVC3MixedAuthenticationSample.Models

08 {

09 public class IdentityClaim

10 {

11 private string _identityProvider;

12 private string _identityValue;

13 public const string ACSProviderClaim ="http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider";

14

15 public IdentityClaim(IClaimsIdentity identity)

16 {

17

18 if (identity != null)

19 {

20 foreach (var claim in identity.Claims)

21 {

22 if (claim.ClaimType == ClaimTypes.NameIdentifier)

23 {

24 _identityValue = claim.Value;

25 }

26 if (claim.ClaimType == ACSProviderClaim)

27 {

28 _identityProvider = claim.Value;

29 }

30

31 }

32 }

33

34 }

Leave a Reply

Your email address will not be published.