示例#1
0
 public CommandResult Run(HttpRequestData request)
 {
     return new CommandResult()
     {
         HttpStatusCode = HttpStatusCode.NotFound
     };
 }
示例#2
0
 public CommandResult Run(HttpRequestData request)
 {
     return new CommandResult()
     {
         Content = ServiceProvider.Metadata.ToXmlString(
             KentorAuthServicesSection.Current.MetadataCacheDuration),
         ContentType = "application/samlmetadata+xml"
     };
 }
示例#3
0
        public CommandResult Run(HttpRequestData request)
        {
            if(request == null)
            {
                throw new ArgumentNullException("request");
            }

            return CreateResult(new EntityId(request.QueryString["idp"]), 
                request.QueryString["ReturnUrl"], request.Url);
        }
示例#4
0
        protected internal override bool CanUnbind(HttpRequestData request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            return request.HttpMethod == "POST"
                && request.Form.Keys.Contains("SAMLResponse");
        }
示例#5
0
        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;
             }
         }
     }
 }
示例#7
0
        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();
        }
示例#8
0
 /// <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);
 }
示例#9
0
 /// <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);
 }
示例#10
0
 /// <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();
 }
示例#11
0
 /// <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;
 }
示例#12
0
 /// <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;
 }
示例#13
0
 /// <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();
 }