How to parse a SAML token

21 במרץ 2014

A customer asked me how to manually parse a saml token. Well I found this blog post with a detailed answer. To get the SAML token request from a request and decode it I do the following:// spec says "SAMLResponse=" string rawSamlData = Request; // the sample data sent us may be already encoded, // which results in double encoding if (rawSamlData.Contains('%')) { rawSamlData = HttpUtility.UrlDecode(rawSamlData); } // read the base64 encoded bytes byte samlData = Convert.FromBase64String(rawSamlData); // read back into a UTF string string samlAssertion = Encoding.UTF8.GetString(samlData);   Enjoy.
no comments

SignalR Message Format

12 במרץ 2014

I looked around for documentation about the message format of Asp.Net SignalR but I could not find any so I had to explore myself and produce the following summary about Asp.Net message format. Messages are serialized as JSON objects and contain metadata about the handlers and the connection as well as payload (i.e. the data to transfer) The following information is included in the messages: - Hubs (H): Handlers (i.e methods) on the server as well as on the clients are grouped in "Hubs".- Method (M): The name of the Handler that will process the message.- Groups: Clients can...
no comments

WAAD, OAuth and Javascript

4 במרץ 2014

As you probably know Microsoft released AAL (Windows Azure AD Authentication Library for .NET) which is a great API for interacting with WAAD and implement the OAuth code flow. This API is extremely easy to use yet it works only for single threaded (STA) clients. It means that you can use it in a console application or windows store app but not in a browser. The scenario in which a client wants to call a web api in a SPA (Single Page Application) looks very interesting so I searched for an JavaScript SDK for WAAD but I could not...
no comments

How To Parse a JWT token

2 במרץ 2014

I had to create a test that retrieves a JWT token from WAAD so I created a little class that parses and displays the token content. Here is the code:class TokenHelper { public static Encoding TextEncoding = Encoding.UTF8; private static char Base64PadCharacter = '='; private static char Base64Character62 = '+'; private static char Base64Character63 = '/'; private static char Base64UrlCharacter62 = '-'; private static char Base64UrlCharacter63 = '_'; public static void DisplayAccessToken(string accessToken) { ...
no comments