Reputation: 6373
I am working with WIF and I create an instance of Saml2SecurityToken
, now I would like to save this token as XML, so that I can use it in testing - I cannot see obvious way of doing it however.
I have seen this answer that suggest using SecurityTokenHandler
however this class has a protected constructor, so I cannot just new it up.
Upvotes: 2
Views: 1173
Reputation: 6373
Silly me, I should have been using Saml2SecurityTokenHandler
rather than just SecurityTokenHandler
which is an abstract class.
This solved my problem:
public static void DupmToken(Saml2SecurityToken token)
{
var handler = new Saml2SecurityTokenHandler();
var sw = new StringWriter();
handler.WriteToken(new XmlTextWriter(sw), token);
Console.WriteLine(sw.ToString());
}
Upvotes: 3