/// <summary> /// Initialize the Session /// </summary> /// <returns></returns> public Session(Configuration.Sso ssoConfiguration, HttpSessionStateBase httpSessionObj = null) { this.ssoConfiguration = ssoConfiguration; HttpSession = httpSessionObj; if (HttpSession != null && HttpSession[ssoConfiguration.Marketplace] != null) { var enc = System.Text.Encoding.UTF8; JObject sessionObject = new JObject(); try { string decryptedMnoSession = enc.GetString(Convert.FromBase64String(HttpSession[ssoConfiguration.Marketplace].ToString())); sessionObject = JObject.Parse(decryptedMnoSession); } catch (Exception) { } // Assign attributes Uid = sessionObject.Value <String>("uid"); GroupUid = sessionObject.Value <String>("group_uid"); SessionToken = sessionObject.Value <String>("session"); // Session Recheck try { Recheck = sessionObject.Value <DateTime>("session_recheck"); } catch (Exception) { } if (Recheck == null) { Recheck = DateTime.UtcNow.AddMinutes(-1); } } }
/// <summary> /// Initializer retrieving maestrano session from user /// </summary> /// <param name="httpSessionObj"></param> /// <param name="user"></param> public Session(Configuration.Sso ssoConfiguration, HttpSessionStateBase httpSessionObj, User user) { this.ssoConfiguration = ssoConfiguration; HttpSession = httpSessionObj; if (user != null) { Uid = user.Uid; GroupUid = user.GroupUid; SessionToken = user.SsoSession; Recheck = user.SsoSessionRecheck; } }
public static Response LoadFromBase64XML(Configuration.Sso sso, String response) { //Sanitize the response // Remove newline characters string base64Response = Regex.Replace(response, @"\t|\n|\r", ""); // Pad the string with '=' to make sure the length is right int mod4 = base64Response.Length % 4; if (mod4 > 0) { base64Response += new String('=', 4 - mod4); } // Decode the response and load the XML document string xml = Encoding.ASCII.GetString(Convert.FromBase64String(base64Response)); return(LoadFromXML(sso, xml)); }
public static Response LoadFromXML(Configuration.Sso sso, String xml) { return(new Response(sso.SamlSettings().IdpCertificate, xml)); }
/// <summary> /// Initialize the Session /// </summary> /// <returns></returns> public Session(Configuration.Sso ssoConfiguration, HttpSessionState httpSessionObj, User user) : this(ssoConfiguration, new HttpSessionStateWrapper(httpSessionObj), user) { }
/// <summary> /// Initialize the Session /// </summary> /// <returns></returns> public Session(Configuration.Sso ssoConfiguration, HttpSessionState httpSessionObj = null) : this(ssoConfiguration, new HttpSessionStateWrapper(httpSessionObj)) { }