public CommandResult Run(HttpRequestData request) { return new CommandResult() { HttpStatusCode = HttpStatusCode.NotFound }; }
public CommandResult Run(HttpRequestData request) { return new CommandResult() { Content = ServiceProvider.Metadata.ToXmlString( KentorAuthServicesSection.Current.MetadataCacheDuration), ContentType = "application/samlmetadata+xml" }; }
public CommandResult Run(HttpRequestData request) { if(request == null) { throw new ArgumentNullException("request"); } return CreateResult(new EntityId(request.QueryString["idp"]), request.QueryString["ReturnUrl"], request.Url); }
protected internal override bool CanUnbind(HttpRequestData request) { if (request == null) { throw new ArgumentNullException("request"); } return request.HttpMethod == "POST" && request.Form.Keys.Contains("SAMLResponse"); }
public override string Unbind(HttpRequestData request) { if (request == null) { throw new ArgumentNullException("request"); } var xml = Encoding.UTF8.GetString( Convert.FromBase64String(request.Form["SAMLResponse"])); return xml; }
public override string Unbind(HttpRequestData request) { if (request == null || request.QueryString["SAMLRequest"] == null) { return null; } var payload = Convert.FromBase64String(request.QueryString["SAMLRequest"]); using (var compressed = new MemoryStream(payload)) { using (var decompressedStream = new DeflateStream(compressed, CompressionMode.Decompress, true)) { using (var deCompressed = new MemoryStream()) { decompressedStream.CopyTo(deCompressed); var xmlData = System.Text.Encoding.UTF8.GetString(deCompressed.GetBuffer()); return xmlData; } } } }
public CommandResult Run(HttpRequestData request) { var binding = Saml2Binding.Get(request); if (binding != null) { try { var samlResponse = Saml2Response.Read(binding.Unbind(request)); samlResponse.Validate(GetSigningKey(samlResponse.Issuer)); var principal = new ClaimsPrincipal(samlResponse.GetClaims()); FederatedAuthentication.FederationConfiguration.IdentityConfiguration .ClaimsAuthenticationManager.Authenticate(null, principal); return new CommandResult() { HttpStatusCode = HttpStatusCode.SeeOther, Location = samlResponse.RequestState != null && samlResponse.RequestState.ReturnUri != null ? samlResponse.RequestState.ReturnUri : KentorAuthServicesSection.Current.ReturnUri, Principal = principal }; } catch (FormatException ex) { throw new BadFormatSamlResponseException( "The SAML Response did not contain valid BASE64 encoded data.", ex); } catch (XmlException ex) { throw new BadFormatSamlResponseException( "The SAML response contains incorrect XML", ex); } } throw new NoSamlResponseFoundException(); }
/// <summary> /// Get a cached binding instance that can handle the current request. /// </summary> /// <param name="request">Current HttpRequest</param> /// <returns>A derived class instance that supports the requested binding, /// or null if no binding supports the current request.</returns> public static Saml2Binding Get(HttpRequestData request) { return(bindings.FirstOrDefault(b => b.Value.CanUnbind(request)).Value); }
/// <summary> /// Checks if the binding can extract a message out of the current /// http request. /// </summary> /// <param name="request">HttpRequest to check for message.</param> /// <returns>True if the binding supports the current request.</returns> protected internal virtual bool CanUnbind(HttpRequestData request) { return(false); }
/// <summary> /// Extracts a message out of the current HttpRequest. /// </summary> /// <param name="request">Current HttpRequest.</param> /// <returns>Extracted message.</returns> public virtual string Unbind(HttpRequestData request) { throw new NotImplementedException(); }
/// <summary> /// Get a cached binding instance that can handle the current request. /// </summary> /// <param name="request">Current HttpRequest</param> /// <returns>A derived class instance that supports the requested binding, /// or null if no binding supports the current request.</returns> public static Saml2Binding Get(HttpRequestData request) { return bindings.FirstOrDefault(b => b.Value.CanUnbind(request)).Value; }
/// <summary> /// Checks if the binding can extract a message out of the current /// http request. /// </summary> /// <param name="request">HttpRequest to check for message.</param> /// <returns>True if the binding supports the current request.</returns> protected internal virtual bool CanUnbind(HttpRequestData request) { return false; }