.NET Claim in three namespaces

梦想的初衷 提交于 2020-01-12 06:40:24

问题


Now this is odd. After completing some research on claims based solutions in .NET, found that different authors refer to different classes in .NET namespace when actually speaking on the same matter. Claim class (not to mention other Identity, Principal, Manager, Helper classes around) is defined in 3 different namespaces.

It is clear that WIF is separate add-on for .NET 3.5 and 4.0 and that it is rewritten and made part of core in 4.5. However it could really help to have clear directions on what class to use for new projects (so that port to 4.5 after could be easier). Does anybody else have more info on the subject?

1st link: http://msdn.microsoft.com/en-us/library/ms572956(v=vs.110) (System.IdentityModel.Claims namespace)

2nd: http://msdn.microsoft.com/en-us/library/microsoft.identitymodel.claims.claim.aspx (Microsoft.IdentityModel.Claims)

3rd: (System.Security.Claims.Claim)


回答1:


For anyone still looking for a definitive answer to this, MSDN has the following information on it's System.IdentityModel.Claims Namespace page...

The System.IdentityModel.Claims namespace contains classes that implement the Windows Communication Foundation (WCF) claims-based identity authorization model. This model includes the Claim class and the ClaimSet class.

Beginning with .NET Framework 4.5 and the integration of Windows Identity Foundation (WIF) into the .NET Framework, the WCF claims-based identity model has been superseded by WIF. WIF provides a claims-based identity object model that can be used to provide authentication and authorization across several Microsoft product stacks, including the CLR, WCF, and ASP.NET. The WIF classes that represent claims, claim types, and identities and principals that are based on claims are contained in the System.Security.Claims namespace. Beginning with .NET 4.5, these classes should be used instead of those in the System.IdentityModel.Claims namespace.




回答2:


Microsoft's answer appears to be: "WIF classes are now spread across various assemblies, the main ones being System.Security.Claims, System.IdentityModel, and System.IdentityModel.Services. System.Security.Claims contains the new ClaimsPrincipal and ClaimsIdentity classes (see below). All principals in .NET now derive from ClaimsPrincipal. The classes from Microsoft.IdentityModel in WIF 1.0 have been spread mainly across System.IdentityModel (pipeline, WCF integration) and System.IdentityModel.Services (support for WS-Federation, session management). Those changes are reflected on the configuration sections as well."




回答3:


System.IdentityModel.Claims is part of WCF/.Net 3.0

Microsoft.IdentityModel.Claims extends System.IdentityModel.Claims and is the Windows Identity Foundation class.

System.Security.Claims is the .Net 4.5 version.

So if you're writing using WIF, you should use Microsoft.IdentityModel.Claims.



来源:https://stackoverflow.com/questions/11713339/net-claim-in-three-namespaces

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!