public ShellWebConnection( IWebConnection webConnection, WebMethod method, string url, byte[] content, string contentType, CookiesFromBrowser cookiesFromBrowser, CallingFrom callingFrom) : base(webConnection.WebServer, callingFrom, webConnection.Generation + 1) { _Content = new WebConnectionContent.InMemory(content); _ContentType = contentType; _Session = webConnection.Session; _Method = method; _CookiesFromBrowser = cookiesFromBrowser; _CookiesToSet = webConnection.CookiesToSet; _HttpVersion = webConnection.HttpVersion; _RequestedHost = webConnection.RequestedHost; _Headers = new Dictionary<string, string>(webConnection.Headers); _MimeReader = webConnection.MimeReader; BaseWebConnection = webConnection; DetermineRequestedFileAndGetParameters(url); TryDecodePostParameters(); }
public ShellWebConnection( string url, IWebConnection webConnection, RequestParameters postParameters, CookiesFromBrowser cookiesFromBrowser, CallingFrom callingFrom) : this(url, webConnection, postParameters, cookiesFromBrowser, callingFrom, WebMethod.GET) { }
protected WebConnectionBase(IWebServer webServer, CallingFrom callingFrom, uint generation) : this(webServer, callingFrom) { // Prevent stack overflow. TODO, make the maximum generation configurable if (generation > 250) throw new WebResultsOverrideException( WebResults.From(Status._500_Internal_Server_Error, "Stack overflow, too many levels of shells")); _Generation = generation; }
public BlockingShellWebConnection( IWebConnection webConnection, WebMethod method, string url, byte[] content, string contentType, CookiesFromBrowser cookiesFromBrowser, CallingFrom callingFrom) : base(webConnection, method, url, content, contentType, cookiesFromBrowser, callingFrom) { }
public BlockingShellWebConnection( IWebServer webServer, ISession session, string url, byte[] content, string contentType, CookiesFromBrowser cookiesFromBrowser, CallingFrom callingFrom, WebMethod method) : base(webServer, session, url, content, contentType, cookiesFromBrowser, callingFrom, method) { }
public BlockingShellWebConnection( IWebConnection webConnection, ISession session, string requestedFile, RequestParameters getParameters, byte[] content, string contentType, CookiesFromBrowser cookiesFromBrowser, CallingFrom callingFrom) : base(webConnection, session, requestedFile, getParameters, content, contentType, cookiesFromBrowser, callingFrom) { }
public IWebResults CallMethod(IWebConnection webConnection, CallingFrom callingFrom) { object toReturn; FilePermissionEnum? minimumPermission; switch (callingFrom) { case CallingFrom.Local: minimumPermission = WebCallableMethod.WebCallableAttribute.MinimumPermissionForTrusted; break; case CallingFrom.Web: minimumPermission = WebCallableMethod.WebCallableAttribute.MinimumPermissionForWeb; break; default: // This clause shouldn't be hit, but in case it is, require the strictest permission possible minimumPermission = FilePermissionEnum.Administer; break; } ID<IUserOrGroup, Guid> userId = webConnection.Session.User.Id; // If this user isn't the owner, then verify that the user has the appropriate permission if (null != minimumPermission) if (FileContainer.OwnerId != userId) { bool hasPermission = false; // Get appropriate permission FilePermissionEnum? userPermission = FileContainer.LoadPermission(userId); if (null != userPermission) if (userPermission.Value >= minimumPermission.Value) hasPermission = true; // If the user doesn't explicitly have the needed permission, try loading any potentially-needed declaritive permissions if (!hasPermission) hasPermission = FileContainer.HasNamedPermissions(userId, WebCallableMethod.NamedPermissions); if (!hasPermission) return WebResults.From(Status._401_Unauthorized, "Permission Denied for method " + WebCallableMethod.MethodInfo.Name); } if (null != WebCallableMethod.WebMethod) if (WebCallableMethod.WebMethod.Value != webConnection.Method) return WebResults.From(Status._405_Method_Not_Allowed, "Allowed method: " + WebCallableMethod.WebMethod.Value.ToString()); toReturn = WebCallableMethod.CallMethod(webConnection, WebHandlerPlugin); return (IWebResults)toReturn; }
public ShellWebConnection( IWebConnection webConnection, ISession session, string requestedFile, RequestParameters getParameters, byte[] content, string contentType, CookiesFromBrowser cookiesFromBrowser, CallingFrom callingFrom) : base(webConnection.WebServer, callingFrom, webConnection.Generation + 1) { _Content = new WebConnectionContent.InMemory(content); _ContentType = contentType; _Session = session; _Method = WebMethod.GET; _CookiesFromBrowser = cookiesFromBrowser; _CookiesToSet = webConnection.CookiesToSet; _HttpVersion = webConnection.HttpVersion; _RequestedHost = webConnection.RequestedHost; _Headers = new Dictionary<string, string>(webConnection.Headers); _MimeReader = webConnection.MimeReader; BaseWebConnection = webConnection; _RequestedFile = requestedFile; _GetParameters = getParameters; _PostParameters = null; }
/// <summary> /// Constructor for when a web request is generated publicly instead of externally /// </summary> /// <param name="webServer"></param> /// <param name="session"></param> /// <param name="url"></param> /// <param name="content"></param> /// <param name="contentType"></param> /// <param name="cookiesFromBrowser"></param> /// <param name="callingFrom"></param> /// <param name="method"></param> public ShellWebConnection( IWebServer webServer, ISession session, string url, byte[] content, string contentType, CookiesFromBrowser cookiesFromBrowser, CallingFrom callingFrom, WebMethod method) : base(webServer, callingFrom, 0) { _Content = new WebConnectionContent.InMemory(content); _ContentType = contentType; _Session = session; _Method = method; _CookiesFromBrowser = cookiesFromBrowser; _CookiesToSet = new List<CookieToSet>(); _HttpVersion = 1; _RequestedHost = null; _Headers = new Dictionary<string, string>(); DetermineRequestedFileAndGetParameters(url); TryDecodePostParameters(); if (null == BaseWebConnection) BaseWebConnection = this; }
public ShellWebConnection( string url, IWebConnection webConnection, RequestParameters postParameters, CookiesFromBrowser cookiesFromBrowser, CallingFrom callingFrom, WebMethod method) : base(webConnection.WebServer, callingFrom, webConnection.Generation + 1) { _PostParameters = postParameters; _Content = webConnection.Content; _ContentType = webConnection.ContentType; _Session = webConnection.Session; _Method = method; _CookiesFromBrowser = cookiesFromBrowser; _CookiesToSet = webConnection.CookiesToSet; _HttpVersion = webConnection.HttpVersion; _RequestedHost = webConnection.RequestedHost; _Headers = new Dictionary<string, string>(webConnection.Headers); _MimeReader = webConnection.MimeReader; BaseWebConnection = webConnection; DetermineRequestedFileAndGetParameters(url); }
public WebConnectionCommon(IWebServer webServer, CallingFrom callingFrom) : base(webServer, callingFrom) { }
protected WebConnectionBase(IWebServer webServer, CallingFrom callingFrom) { _WebServer = webServer; _CallingFrom = callingFrom; }
public IWebResults ShellTo(WebMethod method, string url, byte[] content, string contentType, CallingFrom callingFrom, bool bypassJavascript) { ShellWebConnection shellWebConnection = new BlockingShellWebConnection( this, method, url, content, contentType, _CookiesFromBrowser, callingFrom); shellWebConnection._BypassJavascript = bypassJavascript; return shellWebConnection.GenerateResultsForClient(); }
public IWebResults ShellTo(string url, CallingFrom callingFrom, bool bypassJavascript) { ShellWebConnection shellWebConnection = new BlockingShellWebConnection( url, this, PostParameters, _CookiesFromBrowser, callingFrom); shellWebConnection._BypassJavascript = bypassJavascript; return shellWebConnection.GenerateResultsForClient(); }
/*public void TemporaryChangeSession(ISession tempSession, Action del) { ISession realSession = _Session; _Session = tempSession; try { del(); } finally { _Session = realSession; } }*/ public void ChangeCallingFrom(CallingFrom newCallingFrom, Action toCall) { CallingFrom oldCallingFrom = _CallingFrom; _CallingFrom = newCallingFrom; try { toCall(); } finally { _CallingFrom = oldCallingFrom; } }
/// <summary> /// Calls a function within the context of a CallingFrom /// </summary> /// <param name="function"></param> /// <param name="callingFrom"></param> /// <returns></returns> private static object SetTempCallingFrom(SubProcess.Callback callback, CallingFrom callingFrom) { CallingFrom priorCallingFrom = FunctionCaller.CallingFrom; FunctionCaller.CallingFrom = callingFrom; try { return callback.Call(new object[0]); } finally { FunctionCaller.CallingFrom = priorCallingFrom; } }