Skip to content

Instantly share code, notes, and snippets.

View michaelkc's full-sized avatar

Michael Christensen michaelkc

View GitHub Profile
var wsTrustClient = new WsTrustClient("devtest-idp.vfltest.dk");
var audience = "https://devtest-ws-dli.vfltest.dk/UserServices/";
var token = (GenericXmlSecurityToken)wsTrustClient.GetSecurityToken(audience, "<service account>", "<service account password>");
var tokenXml = token.TokenXml.OuterXml;
var encodedToken = new DeflatedSamlTokenHeaderEncoder().Encode(tokenXml);
Console.WriteLine(tokenXml);
Console.WriteLine(encodedToken);
using (var client = new HttpClient())
{
using System;
using System.IdentityModel.Protocols.WSTrust;
using System.IdentityModel.Tokens;
using System.Reflection;
using System.Security.Claims;
using System.Security.Cryptography.X509Certificates;
using System.ServiceModel;
using System.ServiceModel.Security;
using System.Text.RegularExpressions;
using System.Threading;
using System;
using System.IdentityModel;
using System.Reflection;
using System.Text;
using System.Web;
namespace Samples
{
/// <summary>
/// A "DeflatedSaml" token header encoder. DeflatedSaml is a semi-standard, in that the encoding/compression steps are described in the SAML standards.