From Wikibooks, open books for an open world
Jump to navigation Jump to search



/// <summary>
/// Decodes a SAML string into plain text
/// SAML: XML open-standard for exchanging authorisation/authentication data btw. identity & service providers
/// More info cf.
/// SAML address the SSO problem (cf.
/// </summary>
/// <param name="encodedSAML">Encoded SAML string</param>
/// <returns>Plaintext SAML</returns>
private static string DecodeSAML(string encodedSAML)
     if (encodedSAML.Contains("%"))
          encodedSAML = HttpUtility.UrlDecode(encodedSAML);

     byte[] decodedSAML = Convert.FromBase64String (encodedSAML);
     return Encoding.UTF8.GetString(decodedSAML);