我已经创建了一个 SamlAssertion 的实例,并向其中添加了授权声明和属性声明,现在我想打印出 XML,以便我可以进行 HTTP 发布,但并不是所有的断言都被输出。我错过了什么(我确定这是一些愚蠢的东西)?
这是我正在使用的代码:
// Add the Statements to the SAML Assertion
samlAssert.Statements.Add(samlAuthStatement);
samlAssert.Statements.Add(samlAttrStatement);
MemoryStream xmlStream = new MemoryStream();
XmlDictionaryWriter xmlWriter = XmlDictionaryWriter.CreateTextWriter(xmlStream, System.Text.Encoding.UTF8);
SamlSerializer samlAssertSerializer = new SamlSerializer();
WSSecurityTokenSerializer secTokenSerializer = new WSSecurityTokenSerializer();
samlAssert.WriteXml(xmlWriter, samlAssertSerializer, secTokenSerializer);
xmlStream.Position = 0;
StreamReader sr = new StreamReader(xmlStream, System.Text.Encoding.UTF8);
string AssertStr = sr.ReadToEnd();
TextBox1.Text = AssertStr;
但得到的只是这样的:
<saml:Assertion MajorVersion="1" MinorVersion="1" AssertionID="assertID"
Issuer="my Company" IssueInstant="2008-11-19T19:54:12.191Z"
xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion">
<saml:Conditions NotBefore="2008-11-19T19:54:12.191Z" NotOnOrAfter="2008-11-19T19:59:12.191Z"/>
<saml:AuthenticationStatement AuthenticationMethod="urn:oasis:names:tc:SAML:2.0:ac:classes:TimeSyncToken"
AuthenticationInstant="2008-11-19T19:54:12.191Z">
<saml:Subject>
<saml:NameIdentifier Format="cs-sstc-schema-assertion-1.1.xsd" NameQualifier="My company">xxxx</saml:NameIdentifier>
<saml:SubjectConfirmation>
<saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer</saml:ConfirmationMethod>
</saml:SubjectConfirmation>
</saml:Subject>
<saml:SubjectLocality IPAddress="x.x.x.x"/>
</saml: