Question

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.

Was it helpful?

Solution

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());
 }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top