SAML

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

Contents

C#[edit]

  

/// <summary>
/// Decodes a SAML string into plain text
/// SAML: XML open-standard for exchanging authorisation/authentication data btw. identity & service providers
/// More info cf. http://en.wikipedia.org/wiki/Security_Assertion_Markup_Language
/// SAML address the SSO problem (cf. http://en.wikipedia.org/wiki/Single_sign-on)
/// </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); 
}