質問
誰かが条件ノードで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));
希望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>
私ができます SamlConditions のクラスのコンストラクタがあることを見ます3番目のパラメータのため、条件、およびそこSamlAudienceRestrictionクラスだが、私は2を接続する方法を見つけ出すように見えることができません。私はコードのビットを参照した場合、それは私には痛いほど明白になるだろうと思うが、残念ながら、私のグーグル-fooが今日の私を失敗してます。
解決
私は答えを見るために必要な正確に何だっ投稿する前に、このいずれかを把握しようとしているいくつかの時間を過ごした...どうやら投稿誓います。以下は、私がSAMLのための聴衆の制限を作成するためにやったコードがあります:
//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
Uri[] approvedAudiences = {new Uri("http://www.example2.com")};
List<SamlCondition> conditions = new List<SamlCondition>();
conditions.Add(new SamlAudienceRestrictionCondition(approvedAudiences));
samlAssert.Conditions = new SamlConditions(
DateTime.Now,
DateTime.Now.AddMinutes(5),
conditions
);
誰が間違った何かを見ている、またはより良い/より効率的な方法を知っている場合は、は、私に知らせてくださいます。
所属していません StackOverflow