Esempio n. 1
0
        public static void SetValue(this SAMLInputModel model, string key, HttpContext context, bool isPost, List <KeyValuePair <string, string> > body, Action <SAMLInputModel, string> setAction)
        {
            if (body != null && isPost)
            {
                foreach (var a in body)
                {
                    if (a.Key != key)
                    {
                        continue;
                    }

                    if (!string.IsNullOrEmpty(a.Value))
                    {
                        setAction(model, a.Value);
                        break;
                    }
                }

                return;
            }

            StringValues value;

            if (context.TryGetValue(key, out value, isPost))
            {
                foreach (var a in value)
                {
                    if (!string.IsNullOrEmpty(a))
                    {
                        setAction(model, a);
                        break;
                    }
                }
            }
        }
Esempio n. 2
0
        public static SAMLInputModel BindModel(this SAMLInputModel model, HttpContext context)
        {
            var isPost = context.Request.Method == "POST";

            List <KeyValuePair <string, string> > body = null;

            if (!context.Request.HasFormContentType)
            {
                body = GetBodyValues(context);
            }

            model.SetValue("SAMLRequest", context, isPost, body, (x, v) => x.SAMLRequest   = v);
            model.SetValue("SAMLResponse", context, isPost, body, (x, v) => x.SAMLResponse = v);
            model.SetValue("SAMLart", context, isPost, body, (x, v) => x.SAMLart           = v);
            model.SetValue("RelayState", context, isPost, body, (x, v) => x.RelayState     = v);
            model.SetValue("SigAlg", context, isPost, body, (x, v) => x.SigAlg             = v);
            model.SetValue("Signature", context, isPost, body, (x, v) => x.Signature       = v);

            return(model);
        }
Esempio n. 3
0
 public static bool HasResponse(this SAMLInputModel input)
 {
     return(!String.IsNullOrEmpty(input?.SAMLResponse));
 }