private void CreateSingleSignOn(HttpContext context) { string host = context.Request.Params["Host"]; string username = context.Request.Params["Username"]; string password = context.Request.Params["Password"]; StoredPortalCredentials credentials = new StoredPortalCredentials(); if (credentials.Credentials.ContainsKey(host)) { credentials.Credentials[host].Username = username; credentials.Credentials[host].Password = GetMD5Hash(password); } else { credentials.Credentials.Add(host, new PortalCredentials( credentials, host, username, GetMD5Hash(password) )); } credentials.Save(); }
private void DeleteSingleSignOn(HttpContext context) { string host = context.Request.Params["Host"]; StoredPortalCredentials credentials = new StoredPortalCredentials(); if (credentials.Credentials.ContainsKey(host)) { credentials.Credentials.Remove(host); } credentials.Save(); }
public override void Render() { StringBuilder result = new StringBuilder(); InstanceCollection instances = new InstanceCollection(); StoredPortalCredentials credentials = new StoredPortalCredentials(); foreach (string instance in instances.Instances.Keys) { result.Append("<div class=\"Instance\">"); result.Append(string.Format( "<h1>{0}</h1>", instance )); foreach (string portal in instances.Instances[instance].Portals.Keys) { string host = instances.Instances[instance].Portals[portal].Host; if (credentials.Credentials.ContainsKey(host)) { result.Append(string.Format( "<div class=\"Portal\" onclick=\"if(event.target.nodeName == 'IMG')return;SingleSignOn('{0}', '{1}', '{2}')\"><table>", host, credentials.Credentials[host].Username, credentials.Credentials[host].Password )); } else { result.Append(string.Format( "<div class=\"Portal\" onclick=\"CreateSingleSignOn('{0}')\"><table>", host )); } result.Append(string.Format( "<tr><td colspan=\"2\"><b>{0}</b></td>", host )); if (credentials.Credentials.ContainsKey(host)) { result.Append(string.Format( "<tr><td><b>{0}</b></td><td>{1}</td><td><img src=\"/Images/Icons/Delete.png\" onclick=\"DeleteSingleSignOn('{2}')\" /></td></tr>", Global.LanguageManager.GetText("Username"), credentials.Credentials[host].Username, host )); } else { result.Append(string.Format( "<tr><td><td>{0}</td></tr>", Global.LanguageManager.GetText("PortalCredentialsNotExist") )); } result.Append("</table></div>"); } result.Append("</div>"); } this.Controls.Add(new LiteralControl(result.ToString())); }