从 SAML 令牌读取 SAML 属性
我正在从 XML 文件加载 SAML 令牌。
string certificatePath = @"D:\Projects\SAMLDemo\Server.pfx";
X509Certificate2 cert = new X509Certificate2(certificatePath, "shani");
string samlFilePath = @"D:\Projects\SAMLDemo\saml.xml";
XmlReader reader = XmlReader.Create(samlFilePath);
List<SecurityToken> tokens = new List<SecurityToken>();
tokens.Add(new X509SecurityToken(cert));
SecurityTokenResolver outOfBandTokenResolver = SecurityTokenResolver.CreateDefaultSecurityTokenResolver(new ReadOnlyCollection<SecurityToken>(tokens), true);
SecurityToken securityToken = WSSecurityTokenSerializer.DefaultInstance.ReadToken(reader, outOfBandTokenResolver);
SamlSecurityToken deserializedSaml = securityToken as SamlSecurityToken;
如何从 deserializedSaml 读取 SAML 属性?
我需要属性的字符串值。
I am loading SAML Token from XML file.
string certificatePath = @"D:\Projects\SAMLDemo\Server.pfx";
X509Certificate2 cert = new X509Certificate2(certificatePath, "shani");
string samlFilePath = @"D:\Projects\SAMLDemo\saml.xml";
XmlReader reader = XmlReader.Create(samlFilePath);
List<SecurityToken> tokens = new List<SecurityToken>();
tokens.Add(new X509SecurityToken(cert));
SecurityTokenResolver outOfBandTokenResolver = SecurityTokenResolver.CreateDefaultSecurityTokenResolver(new ReadOnlyCollection<SecurityToken>(tokens), true);
SecurityToken securityToken = WSSecurityTokenSerializer.DefaultInstance.ReadToken(reader, outOfBandTokenResolver);
SamlSecurityToken deserializedSaml = securityToken as SamlSecurityToken;
How can I read the SAML attributes from deserializedSaml ?
I need string values for the attributes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这行不通吗?
Doesn't this work?