从SAML令牌中读取SAML属性
我正在从XML文件加载SAML令牌。
string certificatePath = @"D:ProjectsSAMLDemoServer.pfx"; X509Certificate2 cert = new X509Certificate2(certificatePath, "shani"); string samlFilePath = @"D:ProjectsSAMLDemosaml.xml"; XmlReader reader = XmlReader.Create(samlFilePath); List tokens = new List(); tokens.Add(new X509SecurityToken(cert)); SecurityTokenResolver outOfBandTokenResolver = SecurityTokenResolver.CreateDefaultSecurityTokenResolver(new ReadOnlyCollection(tokens), true); SecurityToken securityToken = WSSecurityTokenSerializer.DefaultInstance.ReadToken(reader, outOfBandTokenResolver); SamlSecurityToken deserializedSaml = securityToken as SamlSecurityToken;
如何从deserializedSaml中读取SAML属性?
我需要属性的字符串值。
这不行吗?
上述就是C#学习教程:从SAML令牌中读取SAML属性分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
foreach (SamlStatement statement in deserializedSaml.Assertion.Statements) { SamlAttributeStatement attributeStatement = statement as SamlAttributeStatement; if (null != attributeStatement) { foreach (SamlAttribute attribute in attributeStatement.Attributes) { DoWhateverYouLikeWith(attribute); } } }
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/1016112.html