我有一個有效的SAML 2令牌從我的應用國際開發署獲取XML命名空間的錯誤,而讀令牌的SAML2
當我嘗試使用WIF代碼如下讀它,我得到以下錯誤:
Cannot read the token from the 'Response' element with the 'urn:oasis:names:tc:SAML:2.0:protocol' namespace for BinarySecretSecurityToken, with a '' ValueType. If this element is expected to be valid, ensure that security is configured to consume tokens with the name, namespace and value type specified.
這裏是我與顯示評論它失敗
string certPath = @"G:\Projects\myAPp\SAMLHandlingTests\bin\Debug\SSO.cer";
X509Certificate2 cert = new X509Certificate2(certPath);
//X509Certificate2 cert = new X509Certificate2(certPath, "LetMeIn!");
// Open the SAML
string samlPath = @"G:\Projects\myAPp\SAMLHandlingTests\bin\Debug\SAML.xml";
string samlRaw = File.OpenText(samlPath).ReadToEnd();
XmlReader rdr = XmlReader.Create(samlPath);
List<System.IdentityModel.Tokens.SecurityToken> tokens = new List<System.IdentityModel.Tokens.SecurityToken>();
var token = new X509SecurityToken(cert);
tokens.Add(token);
SecurityTokenResolver resolver =
SecurityTokenResolver.CreateDefaultSecurityTokenResolver(
new System.Collections.ObjectModel.ReadOnlyCollection<SecurityToken>(tokens), true);
//Fails on next line!
SecurityToken securityToken = System.ServiceModel.Security.WSSecurityTokenSerializer.DefaultInstance.ReadToken(rdr, resolver);
SamlSecurityToken deserializedSaml = securityToken as SamlSecurityToken;
的問題是一個XML命名空間異常,但我不知道如何「確保秒使用的代碼urity被配置爲消耗具有指定名稱,名稱空間和值類型的標記'
請問有人能指出我正確的方向嗎?
我有同樣的例外,但我的是SAML 1.0:'任何想法? –