protected internal virtual IAsyncResult BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, object state) { IHttpHandler httpHandler = GetHttpHandler(httpContext); IHttpAsyncHandler httpAsyncHandler = httpHandler as IHttpAsyncHandler; if (httpAsyncHandler != null) { // asynchronous handler // Ensure delegates continue to use the C# Compiler static delegate caching optimization. BeginInvokeDelegate<IHttpAsyncHandler> beginDelegate = delegate(AsyncCallback asyncCallback, object asyncState, IHttpAsyncHandler innerHandler) { return innerHandler.BeginProcessRequest(HttpContext.Current, asyncCallback, asyncState); }; EndInvokeVoidDelegate<IHttpAsyncHandler> endDelegate = delegate(IAsyncResult asyncResult, IHttpAsyncHandler innerHandler) { innerHandler.EndProcessRequest(asyncResult); }; return AsyncResultWrapper.Begin(callback, state, beginDelegate, endDelegate, httpAsyncHandler, _processRequestTag); } else { // synchronous handler Action action = delegate { httpHandler.ProcessRequest(HttpContext.Current); }; return AsyncResultWrapper.BeginSynchronous(callback, state, action, _processRequestTag); } }
protected internal virtual IAsyncResult BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, object state) { IHttpHandler httpHandler = GetHttpHandler(httpContext); IHttpAsyncHandler httpAsyncHandler = httpHandler as IHttpAsyncHandler; if (httpAsyncHandler != null) { // asynchronous handler BeginInvokeDelegate beginDelegate = delegate(AsyncCallback asyncCallback, object asyncState) { return httpAsyncHandler.BeginProcessRequest(HttpContext.Current, asyncCallback, asyncState); }; EndInvokeDelegate endDelegate = delegate(IAsyncResult asyncResult) { httpAsyncHandler.EndProcessRequest(asyncResult); }; return AsyncResultWrapper.Begin(callback, state, beginDelegate, endDelegate, _processRequestTag); } else { // synchronous handler Action action = delegate { httpHandler.ProcessRequest(HttpContext.Current); }; return AsyncResultWrapper.BeginSynchronous(callback, state, action, _processRequestTag); } }
internal static void SetTableInMapping(HttpContextBase httpContext, object control, MetaTable table, IDictionary<string, object> defaultValues) { MappingInfo mappingInfo = GetMappingInfo(control, httpContext); mappingInfo.Table = table; if (defaultValues != null) { mappingInfo.DefaultValueMapping = new DefaultValueMapping(defaultValues); } }
internal static void AddVersionHeader(HttpContextBase httpContext) { if (!DisableWebPagesResponseHeader) { httpContext.Response.AppendHeader(WebPagesVersionHeaderName, WebPagesVersion); } }
internal static MetaTable GetTableWithFullFallback(IDataSource dataSource, HttpContextBase context) { MetaTable table = GetTableFromMapping(context, dataSource); if (table != null) { return table; } IDynamicDataSource dynamicDataSource = dataSource as IDynamicDataSource; if (dynamicDataSource != null) { table = GetTableFromDynamicDataSource(dynamicDataSource); if (table != null) { return table; } } table = DynamicDataRouteHandler.GetRequestMetaTable(context); if (table != null) { return table; } Control c = dataSource as Control; string id = (c != null ? c.ID : String.Empty); throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, DynamicDataResources.MetaTableHelper_CantFindTable, id)); }
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) #endif { if (parameterName == null) { throw Error.ArgumentNull("parameterName"); } if (values == null) { throw Error.ArgumentNull("values"); } object value; if (values.TryGetValue(parameterName, out value) && value != null) { if (value is bool) { return true; } bool result; string valueString = Convert.ToString(value, CultureInfo.InvariantCulture); return Boolean.TryParse(valueString, out result); } return false; }
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) #endif { if (parameterName == null) { throw Error.ArgumentNull("parameterName"); } if (values == null) { throw Error.ArgumentNull("values"); } object value; if (values.TryGetValue(parameterName, out value) && value != null) { string valueString = Convert.ToString(value, CultureInfo.InvariantCulture); int length = valueString.Length; if (Length.HasValue) { return length == Length.Value; } else { return length >= MinLength.Value && length <= MaxLength.Value; } } return false; }
/// <summary> /// 在响应头中设置MVC版本信息 /// </summary> /// <param name="httpContext"></param> protected internal virtual void AddVersionHeader(HttpContextBase httpContext) { if (!DisableMvcResponseHeader) { httpContext.Response.AppendHeader(MvcVersionHeaderName, MvcVersion); } }
internal static void DisposeResources(HttpContextBase context) { var resources = GetResources(context); if (resources != null) { resources.ForEach(resource => resource.Dispose()); resources.Clear(); } }
protected virtual bool Validate(HttpContextBase context) { if(context.User == null || context.User.Identity == null) return false; return context.User.Identity.IsAuthenticated; }
private static string GenerateClientUrlInternal(HttpContextBase httpContext, string contentPath) { if (String.IsNullOrEmpty(contentPath)) { return contentPath; } // can't call VirtualPathUtility.IsAppRelative since it throws on some inputs bool isAppRelative = contentPath[0] == '~'; if (isAppRelative) { string absoluteContentPath = VirtualPathUtility.ToAbsolute(contentPath, httpContext.Request.ApplicationPath); string modifiedAbsoluteContentPath = httpContext.Response.ApplyAppPathModifier(absoluteContentPath); return GenerateClientUrlInternal(httpContext, modifiedAbsoluteContentPath); } // we only want to manipulate the path if URL rewriting is active for this request, else we risk breaking the generated URL bool wasRequestRewritten = _urlRewriterHelper.WasRequestRewritten(httpContext); if (!wasRequestRewritten) { return contentPath; } // Since the rawUrl represents what the user sees in his browser, it is what we want to use as the base // of our absolute paths. For example, consider mysite.example.com/foo, which is internally // rewritten to content.example.com/mysite/foo. When we want to generate a link to ~/bar, we want to // base it from / instead of /foo, otherwise the user ends up seeing mysite.example.com/foo/bar, // which is incorrect. string relativeUrlToDestination = MakeRelative(httpContext.Request.Path, contentPath); string absoluteUrlToDestination = MakeAbsolute(httpContext.Request.RawUrl, relativeUrlToDestination); return absoluteUrlToDestination; }
protected internal virtual IAsyncResult BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, object state) { return SecurityUtil.ProcessInApplicationTrust(() => { IController controller; IControllerFactory factory; ProcessRequestInit(httpContext, out controller, out factory); IAsyncController asyncController = controller as IAsyncController; if (asyncController != null) { // asynchronous controller BeginInvokeDelegate beginDelegate = delegate(AsyncCallback asyncCallback, object asyncState) { try { return asyncController.BeginExecute(RequestContext, asyncCallback, asyncState); } catch { factory.ReleaseController(asyncController); throw; } }; EndInvokeDelegate endDelegate = delegate(IAsyncResult asyncResult) { try { asyncController.EndExecute(asyncResult); } finally { factory.ReleaseController(asyncController); } }; SynchronizationContext syncContext = SynchronizationContextUtil.GetSynchronizationContext(); AsyncCallback newCallback = AsyncUtil.WrapCallbackForSynchronizedExecution(callback, syncContext); return AsyncResultWrapper.Begin(newCallback, state, beginDelegate, endDelegate, _processRequestTag); } else { // synchronous controller Action action = delegate { try { controller.Execute(RequestContext); } finally { factory.ReleaseController(controller); } }; return AsyncResultWrapper.BeginSynchronous(callback, state, action, _processRequestTag); } }); }
// This method must be thread-safe since it is called by the thread-safe OnCacheAuthorization() method. protected virtual bool AuthorizeCore(HttpContextBase httpContext) { if (httpContext == null) { throw new ArgumentNullException("httpContext"); } IPrincipal user = httpContext.User; if (!user.Identity.IsAuthenticated) { return false; } if (_usersSplit.Length > 0 && !_usersSplit.Contains(user.Identity.Name, StringComparer.OrdinalIgnoreCase)) { return false; } if (_rolesSplit.Length > 0 && !_rolesSplit.Any(user.IsInRole)) { return false; } return true; }
private static CultureInfo DetermineAutoCulture(HttpContextBase context) { HttpRequestBase request = context.Request; Debug.Assert(request != null); //This call is made from a WebPageExecutingBase. Request can never be null when inside a page. CultureInfo culture = null; if (request.UserLanguages != null) { string userLanguageEntry = request.UserLanguages.FirstOrDefault(); if (!String.IsNullOrWhiteSpace(userLanguageEntry)) { // Check if user language has q parameter. E.g. something like this: "as-IN;q=0.3" int index = userLanguageEntry.IndexOf(';'); if (index != -1) { userLanguageEntry = userLanguageEntry.Substring(0, index); } try { culture = new CultureInfo(userLanguageEntry); } catch (CultureNotFoundException) { // There is no easy way to ask if a given culture is invalid so we have to handle exception. } } } return culture; }
private string GetAntiForgeryTokenAndSetCookie(HttpContextBase httpContext, string salt, string domain, string path) { string cookieName = AntiForgeryData.GetAntiForgeryTokenName(httpContext.Request.ApplicationPath); AntiForgeryData cookieToken = null; HttpCookie cookie = httpContext.Request.Cookies[cookieName]; if (cookie != null) { try { cookieToken = Serializer.Deserialize(cookie.Value); } catch (HttpAntiForgeryException) { } } if (cookieToken == null) { cookieToken = AntiForgeryData.NewToken(); string cookieValue = Serializer.Serialize(cookieToken); HttpCookie newCookie = new HttpCookie(cookieName, cookieValue) { HttpOnly = true, Domain = domain }; if (!String.IsNullOrEmpty(path)) { newCookie.Path = path; } httpContext.Response.Cookies.Set(newCookie); } AntiForgeryData formToken = new AntiForgeryData(cookieToken) { Salt = salt, Username = AntiForgeryData.GetUsername(httpContext.User) }; return Serializer.Serialize(formToken); }
/// <summary> /// 使用当前Http请求的上下文信息初始化 FormsAuthenticationHelper 类的新实例 /// </summary> /// <param name="context"></param> /// <exception cref="ArgumentNullException"></exception> public FormsAuthenticationHelper(HttpContextBase context) { if (context == null) throw new ArgumentNullException("context"); this._Context = context; UserIdentity = context.User == null ? null : context.User.Identity as FormsIdentity; }
internal DisplayInfo GetDisplayInfoForVirtualPath(string virtualPath, HttpContextBase httpContext, Func<string, bool> virtualPathExists, IDisplayMode currentDisplayMode, bool requireConsistentDisplayMode) { IEnumerable<IDisplayMode> possibleDisplayModes = GetAvailableDisplayModesForContext(httpContext, currentDisplayMode, requireConsistentDisplayMode); return possibleDisplayModes.Select(mode => mode.GetDisplayInfo(httpContext, virtualPath, virtualPathExists)) .FirstOrDefault(info => info != null); }
internal static void SetDisplayMode(HttpContextBase context, IDisplayMode displayMode) { if (context != null) { context.Items[_displayModeKey] = displayMode; } }
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) #endif { if (parameterName == null) { throw Error.ArgumentNull("parameterName"); } if (values == null) { throw Error.ArgumentNull("values"); } object value; if (values.TryGetValue(parameterName, out value) && value != null) { if (value is double) { return true; } double result; string valueString = Convert.ToString(value, CultureInfo.InvariantCulture); return Double.TryParse(valueString, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out result); } return false; }
public override RouteData GetRouteData(HttpContextBase httpContext) { try { if (HttpRoute is HostedHttpRoute) { return base.GetRouteData(httpContext); } else { // if user passed us a custom IHttpRoute, then we should invoke their function instead of the base HttpRequestMessage request = httpContext.GetOrCreateHttpRequestMessage(); IHttpRouteData data = HttpRoute.GetRouteData(httpContext.Request.ApplicationPath, request); return data == null ? null : data.ToRouteData(); } } catch (Exception exception) { // Processing an exception involves async work, and this method is synchronous. // Instead of waiting on the async work here, it's better to return a handler that will deal with the // exception asynchronously during its request processing method. ExceptionDispatchInfo exceptionInfo = ExceptionDispatchInfo.Capture(exception); return new RouteData(this, new HttpRouteExceptionRouteHandler(exceptionInfo)); } }
public override RouteData GetRouteData(HttpContextBase httpContext) { try { if (HttpRoute is HostedHttpRoute) { return base.GetRouteData(httpContext); } else { // if user passed us a custom IHttpRoute, then we should invoke their function instead of the base HttpRequestMessage request = httpContext.GetOrCreateHttpRequestMessage(); IHttpRouteData data = HttpRoute.GetRouteData(httpContext.Request.ApplicationPath, request); return data == null ? null : data.ToRouteData(); } } catch (HttpResponseException e) { // Task.Wait is fine here as ConvertResponse calls into MediaTypeFormatter.WriteToStreamAsync which happens // synchronously in the default case (our default formatters are synchronous). HttpControllerHandler.ConvertResponse(httpContext, e.Response, httpContext.GetOrCreateHttpRequestMessage()).Wait(); httpContext.Response.End(); return null; } }
protected override void VerifyAndProcessRequest(IHttpHandler httpHandler, HttpContextBase httpContext) { if (httpHandler == null) { throw new ArgumentNullException("httpHandler"); } httpHandler.ProcessRequest(HttpContext.Current); }
public static void Validate(HttpContextBase httpContext, string salt) { if (httpContext == null) { throw new ArgumentNullException("httpContext"); } _worker.Validate(httpContext, salt); }
public static HtmlString GetHtml(HttpContextBase httpContext, string salt, string domain, string path) { if (httpContext == null) { throw new ArgumentNullException("httpContext"); } return _worker.GetHtml(httpContext, salt, domain, path); }
internal void DoPostResolveRequestCache(HttpContextBase context) { // Parse incoming URL (we trim off the first two chars since they're always "~/") string requestPath = context.Request.AppRelativeCurrentExecutionFilePath.Substring(2) + context.Request.PathInfo; // Check if this request matches a file in the app WebPageMatch webpageRouteMatch = MatchRequest(requestPath, WebPageHttpHandler.GetRegisteredExtensions(), VirtualPathFactoryManager); if (webpageRouteMatch != null) { // If it matches then save some data for the WebPage's UrlData context.Items[typeof(WebPageMatch)] = webpageRouteMatch; string virtualPath = "~/" + webpageRouteMatch.MatchedPath; // Verify that this path is enabled before remapping if (!WebPagesDeployment.IsExplicitlyDisabled(virtualPath)) { IHttpHandler handler = WebPageHttpHandler.CreateFromVirtualPath(virtualPath); if (handler != null) { // Remap to our handler context.RemapHandler(handler); } } } else { // Bug:904704 If its not a match, but to a supported extension, we want to return a 404 instead of a 403 string extension = PathUtil.GetExtension(requestPath); foreach (string supportedExt in WebPageHttpHandler.GetRegisteredExtensions()) { if (String.Equals("." + supportedExt, extension, StringComparison.OrdinalIgnoreCase)) { throw new HttpException(404, null); } } } }
protected override void VerifyAndProcessRequest(IHttpHandler handler, HttpContextBase context) { Precondition.Require(handler, () => Error.ArgumentNull("handler")); Precondition.Require(context, () => Error.ArgumentNull("context")); handler.ProcessRequest(context.Unwrap()); }
private void CheckSSLConfig(HttpContextBase httpContext) { if (this._config.RequireSSL && !httpContext.Request.IsSecureConnection) { throw new InvalidOperationException(WebPageResources.AntiForgeryWorker_RequireSSL); } }
private static IHttpHandler GetHttpHandler(HttpContextBase context) { StubHttpHandler handler = new StubHttpHandler(); handler.ProcessRequestInternal(context); return handler.Handler; }
internal static void SetUpSessionState(HttpContextBase context, IHttpHandler handler, ConcurrentDictionary<Type, SessionStateBehavior?> cache) { WebPageHttpHandler webPageHandler = handler as WebPageHttpHandler; Debug.Assert(handler != null); SessionStateBehavior? sessionState = GetSessionStateBehavior(webPageHandler.RequestedPage, cache); if (sessionState != null) { // If the page explicitly specifies a session state value, return since it has the most priority. context.SetSessionStateBehavior(sessionState.Value); return; } WebPageRenderingBase page = webPageHandler.StartPage; StartPage startPage = null; do { // Drill down _AppStart and _PageStart. startPage = page as StartPage; if (startPage != null) { sessionState = GetSessionStateBehavior(page, cache); page = startPage.ChildPage; } } while (startPage != null); if (sessionState != null) { context.SetSessionStateBehavior(sessionState.Value); } }
internal static void SetCulture(Thread thread, HttpContextBase context, string cultureName) { Debug.Assert(!String.IsNullOrEmpty(cultureName)); CultureInfo cultureInfo = GetCulture(context, cultureName); if (cultureInfo != null) { thread.CurrentCulture = cultureInfo; } }
public static async Task <ExternalLoginInfo> GetExternalLoginInfoAsync(HttpContextBase context, string xsrfKey, string userId) { return(await GetAuthenticationManager(context).GetExternalLoginInfoAsync(xsrfKey, userId)); }
protected override bool AuthorizeCore(HttpContextBase httpContext) { return(httpContext.Session["UserId"] != null); }
protected override SharePointContext LoadSharePointContext(HttpContextBase httpContext) { return(httpContext.Session[SPContextKey] as SharePointAcsContext); }
protected override bool ValidateSharePointContext(SharePointContext spContext, HttpContextBase httpContext) { SharePointAcsContext spAcsContext = spContext as SharePointAcsContext; if (spAcsContext != null) { Uri spHostUrl = SharePointContext.GetSPHostUrl(httpContext.Request); string contextToken = TokenHelper.GetContextTokenFromRequest(httpContext.Request); HttpCookie spCacheKeyCookie = httpContext.Request.Cookies[SPCacheKeyKey]; string spCacheKey = spCacheKeyCookie != null ? spCacheKeyCookie.Value : null; return(spHostUrl == spAcsContext.SPHostUrl && !string.IsNullOrEmpty(spAcsContext.CacheKey) && spCacheKey == spAcsContext.CacheKey && !string.IsNullOrEmpty(spAcsContext.ContextToken) && (string.IsNullOrEmpty(contextToken) || contextToken == spAcsContext.ContextToken)); } return(false); }
/// <summary> /// Saves the specified SharePointContext instance associated with the specified HTTP context. /// <c>null</c> is accepted for clearing the SharePointContext instance associated with the HTTP context. /// </summary> /// <param name="spContext">The SharePointContext instance to be saved, or <c>null</c>.</param> /// <param name="httpContext">The HTTP context.</param> protected abstract void SaveSharePointContext(SharePointContext spContext, HttpContextBase httpContext);
/// <summary> /// Loads the SharePointContext instance associated with the specified HTTP context. /// </summary> /// <param name="httpContext">The HTTP context.</param> /// <returns>The SharePointContext instance. Returns <c>null</c> if not found.</returns> protected abstract SharePointContext LoadSharePointContext(HttpContextBase httpContext);
/// <summary> /// Validates if the given SharePointContext can be used with the specified HTTP context. /// </summary> /// <param name="spContext">The SharePointContext.</param> /// <param name="httpContext">The HTTP context.</param> /// <returns>True if the given SharePointContext can be used with the specified HTTP context.</returns> protected abstract bool ValidateSharePointContext(SharePointContext spContext, HttpContextBase httpContext);
/// <summary> /// Checks if it is necessary to redirect to SharePoint for user to authenticate. /// </summary> /// <param name="httpContext">The HTTP context.</param> /// <param name="redirectUrl">The redirect url to SharePoint if the status is ShouldRedirect. <c>Null</c> if the status is Ok or CanNotRedirect.</param> /// <returns>Redirection status.</returns> public static RedirectionStatus CheckRedirectionStatus(HttpContextBase httpContext, out Uri redirectUrl) { if (httpContext == null) { throw new ArgumentNullException("httpContext"); } redirectUrl = null; if (SharePointContextProvider.Current.GetSharePointContext(httpContext) != null) { return(RedirectionStatus.Ok); } const string SPHasRedirectedToSharePointKey = "SPHasRedirectedToSharePoint"; if (!string.IsNullOrEmpty(httpContext.Request.QueryString[SPHasRedirectedToSharePointKey])) { return(RedirectionStatus.CanNotRedirect); } Uri spHostUrl = SharePointContext.GetSPHostUrl(httpContext.Request); if (spHostUrl == null) { return(RedirectionStatus.CanNotRedirect); } if (StringComparer.OrdinalIgnoreCase.Equals(httpContext.Request.HttpMethod, "POST")) { return(RedirectionStatus.CanNotRedirect); } Uri requestUrl = httpContext.Request.Url; var queryNameValueCollection = HttpUtility.ParseQueryString(requestUrl.Query); // Removes the values that are included in {StandardTokens}, as {StandardTokens} will be inserted at the beginning of the query string. queryNameValueCollection.Remove(SharePointContext.SPHostUrlKey); queryNameValueCollection.Remove(SharePointContext.SPAppWebUrlKey); queryNameValueCollection.Remove(SharePointContext.SPLanguageKey); queryNameValueCollection.Remove(SharePointContext.SPClientTagKey); queryNameValueCollection.Remove(SharePointContext.SPProductNumberKey); // Adds SPHasRedirectedToSharePoint=1. queryNameValueCollection.Add(SPHasRedirectedToSharePointKey, "1"); UriBuilder returnUrlBuilder = new UriBuilder(requestUrl); returnUrlBuilder.Query = queryNameValueCollection.ToString(); // Inserts StandardTokens. const string StandardTokens = "{StandardTokens}"; string returnUrlString = returnUrlBuilder.Uri.AbsoluteUri; returnUrlString = returnUrlString.Insert(returnUrlString.IndexOf("?") + 1, StandardTokens + "&"); // Constructs redirect url. string redirectUrlString = TokenHelper.GetAppContextTokenRequestUrl(spHostUrl.AbsoluteUri, Uri.EscapeDataString(returnUrlString)); redirectUrl = new Uri(redirectUrlString, UriKind.Absolute); return(RedirectionStatus.ShouldRedirect); }
public static void SetHttpContext(HttpContextBase httpContextBase) { mockHttpContext = httpContextBase; }
public static void ResetHttpContext() { mockHttpContext = null; }
protected override void SaveSharePointContext(SharePointContext spContext, HttpContextBase httpContext) { httpContext.Session[SPContextKey] = spContext as SharePointHighTrustContext; }
/// <summary> /// Returns information about the requested route. /// </summary> /// <param name="httpContext">An object that encapsulates information about the HTTP request.</param> /// <returns>An object that contains the values from the route definition.</returns> public override RouteData GetRouteData(HttpContextBase httpContext) { // Request information string requestDomain = httpContext.Request.Headers["host"]; if (requestDomain.Contains("photomsk")) { return(null); } if (requestDomain.Contains("xn--n1aalg.xn--90ais")) { return(null); } if (requestDomain.Contains("fotomsk")) { return(null); } if (requestDomain.Contains("ngweb")) { return(null); } if (requestDomain.Contains("localhost")) { return(null); } if (!string.IsNullOrWhiteSpace(requestDomain)) { if (requestDomain.IndexOf(":", StringComparison.Ordinal) > 0) { requestDomain = requestDomain.Substring(0, requestDomain.IndexOf(":", StringComparison.Ordinal)); } } else { if (httpContext.Request.Url == null) { return(null); } requestDomain = httpContext.Request.Url.Host; } // Match domain and route Match domainMatch = _domainRegex.Match(requestDomain); if (domainMatch.Success == false) { return(null); } RouteData data = base.GetRouteData(httpContext); if (data == null) { return(null); } // Iterate matching domain groups for (int i = 1; i < domainMatch.Groups.Count; i++) { Group group = domainMatch.Groups[i]; if (group.Success) { string key = _domainRegex.GroupNameFromNumber(i); if (!string.IsNullOrEmpty(key) && !char.IsNumber(key, 0)) { if (!string.IsNullOrEmpty(group.Value)) { data.Values[key] = group.Value; } } } } data.DataTokens["Area"] = "Default"; data.DataTokens.Add("namespaces", new string[] { "PhotoMSK.Areas.Default.Controllers" }); return(data); }
public override bool IsB2BUserLoggedIn(HttpContextBase context) { return(B2BCheckoutService.IsB2BUserLoggedIn(HttpContext)); }
public PerRequestCacheManager(HttpContextBase context) { _context = context; }
public RoxyFilemanController(IPermissionService permissionService, HttpContextBase context) { this._permissionService = permissionService; this._context = context; this._r = this._context.Response; }
protected override bool AuthorizeCore(HttpContextBase httpContext) { return(SessionManager.user != null); }
internal byte[] ProcessRequestInternal(HttpContextBase context, string fileset, ClientDependencyType type, int version, byte[] outputBytes, OutputCachedPage page) { //get the compression type supported var clientCompression = context.GetClientCompression(); var x1 = ClientDependencySettings.Instance; if (x1 == null) { throw new Exception("x1"); } var x2 = x1.DefaultFileMapProvider; if (x2 == null) { throw new Exception("x2"); } //get the map to the composite file for this file set, if it exists. var map = ClientDependencySettings.Instance.DefaultFileMapProvider.GetCompositeFile(fileset, version, clientCompression.ToString()); string compositeFileName = ""; if (map != null && map.HasFileBytes) { ProcessFromFile(context, map, out compositeFileName, out outputBytes); } else { lock (Lock) { //check again... if (map != null && map.HasFileBytes) { //there's files there now, so process them ProcessFromFile(context, map, out compositeFileName, out outputBytes); } else { List <CompositeFileDefinition> fileDefinitions; byte[] fileBytes; if (ClientDependencySettings.Instance.DefaultCompositeFileProcessingProvider.UrlType == CompositeUrlType.MappedId) { //need to try to find the map by it's id/version (not compression) var filePaths = ClientDependencySettings.Instance.DefaultFileMapProvider.GetDependentFiles(fileset, version); if (filePaths == null) { throw new KeyNotFoundException("no map was found for the dependency key: " + fileset + " ,CompositeUrlType.MappedId requires that a map is found"); } //combine files and get the definition types of them (internal vs external resources) fileBytes = ClientDependencySettings.Instance.DefaultCompositeFileProcessingProvider .CombineFiles(filePaths.ToArray(), context, type, out fileDefinitions); } else { //need to do the combining, etc... and save the file map fileBytes = GetCombinedFiles(context, fileset, type, out fileDefinitions); } //compress data outputBytes = ClientDependencySettings.Instance.DefaultCompositeFileProcessingProvider.CompressBytes(clientCompression, fileBytes); context.AddCompressionResponseHeader(clientCompression); //save combined file var compositeFile = ClientDependencySettings.Instance .DefaultCompositeFileProcessingProvider .SaveCompositeFile(outputBytes, type, context.Server); if (compositeFile != null) { compositeFileName = compositeFile.FullName; if (!string.IsNullOrEmpty(compositeFileName)) { //Update the XML file map ClientDependencySettings.Instance.DefaultFileMapProvider.CreateUpdateMap(fileset, clientCompression.ToString(), fileDefinitions.Select(x => new BasicFile(type) { FilePath = x.Uri }), compositeFileName, //TODO: We should probably use the passed in version param? ClientDependencySettings.Instance.Version); } } } } } //set our caching params SetCaching(context, compositeFileName, fileset, clientCompression, page); return(outputBytes); }
CachePolicy ICachePolicyProvider.CreateCachePolicy(HttpContextBase context) { return(_provider.CreateCachePolicy(context)); }
public static void SetCrucialWorker(HttpContextBase context, int crucialWorkerID, string crucialWorkerName) { context.Session["FinishedProduct-CrucialWorker"] = crucialWorkerID.ToString() + "#@#" + crucialWorkerName; }
public void SignOut(HttpContextBase httpContext) { authenticationCookieManager.RemoveTokenCookie(httpContext); }
private static IAuthenticationManager GetAuthenticationManager(HttpContextBase context) { return(context.GetOwinContext().Authentication); }
public static void AddToResponseCookie(FormsAuthenticationTicket authenticationTicket, HttpContextBase httpContext) { var authenticationCookie = authenticationTicket == null ? new HttpCookie(CookieName) { Expires = DateTime.Now.AddYears(-1) } : new HttpCookie(CookieName, FormsAuthentication.Encrypt(authenticationTicket)); httpContext.Response.Cookies.Add(authenticationCookie); }
protected override bool ValidateSharePointContext(SharePointContext spContext, HttpContextBase httpContext) { SharePointHighTrustContext spHighTrustContext = spContext as SharePointHighTrustContext; if (spHighTrustContext != null) { Uri spHostUrl = SharePointContext.GetSPHostUrl(httpContext.Request); WindowsIdentity logonUserIdentity = httpContext.Request.LogonUserIdentity; return(spHostUrl == spHighTrustContext.SPHostUrl && logonUserIdentity != null && logonUserIdentity.IsAuthenticated && !logonUserIdentity.IsGuest && logonUserIdentity.User == spHighTrustContext.LogonUserIdentity.User); } return(false); }
public static async Task <ExternalLoginInfo> GetExternalLoginInfoAsync(HttpContextBase context) { return(await GetAuthenticationManager(context).GetExternalLoginInfoAsync()); }
public override void Execute(HttpContextBase context) { var httpReq = context.ToRequest(OperationName); ProcessRequestAsync(httpReq, httpReq.Response, OperationName); }
public static async Task LoginAsync(HttpContextBase context, ApplicationUser user, bool isPersistent) { log.Info($"Пользователь {user.VisibleName} (логин = {user.UserName}, id = {user.Id}) залогинился"); await new AuthenticationManager().InternalLoginAsync(context, user, isPersistent); }
/// <summary> /// The internal authentication check - to be implemented by the sub class. /// </summary> /// <param name="filterContext"> The filter context. </param> protected abstract void InternalAuthenticationCheck(HttpContextBase filterContext);
public static void Logout(HttpContextBase context) { GetAuthenticationManager(context).SignOut(); }
public override RouteData GetRouteData(HttpContextBase httpContext) { return(null); }
public ExecuteRequestForNextTask(UrlHelper urlHelper, HttpContextBase context) { _urlHelper = urlHelper; _context = context; }