小编mjm*_*nto的帖子

SAML断言中的AudienceRestriction

有人可以指点我在一个示例的方向创建一个包含条件节点中的AudienceRestriction的SamlAssertion吗?

下面是我的代码示例,我想把它放在:

//Create the SAML Assertion
SamlAssertion samlAssert = new SamlAssertion();
samlAssert.AssertionId = Convert.ToBase64String(encoding.GetBytes(System.Guid.NewGuid().ToString()));
samlAssert.Issuer = "http://www.example.com/";

// Set up the conditions of the assertion - Not Before and Not After
samlAssert.Conditions = new SamlConditions(DateTime.Now, DateTime.Now.AddMinutes(5));
Run Code Online (Sandbox Code Playgroud)

所需的XML看起来像这样:

<Assertion xmlns="urn:oasis:names:tc:SAML:1.0:assertion" AssertionID="_e835eca079133299b2f8a2a63ad72fe8" IssueInstant="2007-02-07T20:22:58.165Z" Issuer="http://www.example.com/" MajorVersion="1" MinorVersion="1">
 <Conditions NotBefore="2007-02-07T20:22:58.162Z" NotOnOrAfter="2007-02-07T20:24:58.162Z">
  <AudienceRestrictionCondition>
   <Audience>http://www.example2.com</Audience> 
  </AudienceRestrictionCondition>
 </Conditions>
Run Code Online (Sandbox Code Playgroud)

我看到有一个SamlConditions类的构造函数允许第三个参数,条件,并且有一个SamlAudienceRestriction类,但我似乎无法弄清楚如何连接这两个.我想如果我要看一些代码,那对我来说就会变得非常痛苦,但不幸的是,我的google-foo今天让我失望了.

c# saml

3
推荐指数
1
解决办法
2780
查看次数

标签 统计

c# ×1

saml ×1