public static void GuideSSO(HttpResponseBase httpResponse, string partnerSp, string subject, Dictionary <string, string> samlAttributes) { Trace.TraceInformation("Initiation of SSO to the partner service provider " + partnerSp + " has completed successfully."); SAMLConfiguration.Load(); var issuer = SAMLConfiguration.Current.IdentityProviderConfiguration.Name; var partner = SAMLConfiguration.Current.GetPartnerServiceProvider(partnerSp); Trace.TraceInformation(DateTime.Now.ToShortTimeString() + ": Initiating SSO to the partner service provider " + partnerSp); var saml = CreateSAML20ResponseAsBase64(issuer, 5, partnerSp, subject, partner.AssertionConsumerServiceUrl, samlAttributes, partnerSp); var responseContent = String.Format("<html xmlns=\"http://www.w3.org/1999/xhtml\">" + "<body onload=\"document.forms.samlform.submit()\">" + "<noscript><p><strong>Note:</strong> Since your browser does not support Javascript, you must press the Continue button once to proceed.</p></noscript>" + "<form id=\"samlform\" action=\"{0}\" method=\"post\">" + "<div>" + "<input type=\"hidden\" name=\"SAMLResponse\" value=\"{1}\" />" + "<input type=\"hidden\" name=\"clientId\" value=\"900D3C06-C63C-4F49-B3D2-54A91C771A43\" />" // + "<input type=\"hidden\" name=\"RelayState\" value=\"\" />" + "</div><noscript><div><input type=\"submit\" value=\"Continue\" /></div></noscript>" + "</form>" + "</body>" + "</html>", partner.AssertionConsumerServiceUrl, saml); Trace.TraceInformation(DateTime.Now.ToShortTimeString() + ": Sending SAML form: " + responseContent); httpResponse.Write(responseContent); }
public static void GuideSSO(HttpResponseBase httpResponse, string partnerSp, string subject, Dictionary <string, string> samlAttributes) { SAMLConfiguration.Load(); var issuer = SAMLConfiguration.Current.IdentityProviderConfiguration.Name; var partner = SAMLConfiguration.Current.GetPartnerServiceProvider(partnerSp); var saml = CreateSAML20Response(issuer, 5, partnerSp, subject, partner.AssertionConsumerServiceUrl, samlAttributes, partnerSp); var responseContent = String.Format("<html xmlns=\"http://www.w3.org/1999/xhtml\">" + "<body onload=\"document.forms.samlform.submit()\">" + "<noscript><p><strong>Note:</strong> Since your browser does not support Javascript, you must press the Continue button once to proceed.</p></noscript>" + "<form id=\"samlform\" action=\"{0}\" method=\"post\">" + "<div>" + "<input type=\"hidden\" name=\"SAMLResponse\" value=\"{1}\" />" + "<input type=\"hidden\" name=\"RelayState\" value=\"\" />" + "</div><noscript><div><input type=\"submit\" value=\"Continue\" /></div></noscript>" + "</form>" + "</body>" + "</html>", partner.AssertionConsumerServiceUrl, saml); httpResponse.Write(responseContent); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); SAMLConfiguration.Load(); }
protected void Application_Start() { MvcHandler.DisableMvcResponseHeader = true; AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.Upn; FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); CryptoConfig.AddAlgorithm(typeof(RSAPKCS1SHA256SignatureDescription), "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"); var samlConfigLocation = Settings.Get <string>("Saml.Configuration.FileLocation"); if (!string.IsNullOrEmpty(samlConfigLocation)) { SAMLConfiguration.Load(samlConfigLocation); } }