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; } } } }
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); }
public static bool HasResponse(this SAMLInputModel input) { return(!String.IsNullOrEmpty(input?.SAMLResponse)); }