Refine search
/** * Expose the specified request attribute if not already present. * @param request current servlet request * @param name the name of the attribute * @param value the suggested value of the attribute */ private static void exposeRequestAttributeIfNotPresent(ServletRequest request, String name, Object value) { if (request.getAttribute(name) == null) { request.setAttribute(name, value); } }
/** * Expose the specified request attribute if not already present. * @param request current servlet request * @param name the name of the attribute * @param value the suggested value of the attribute */ private static void exposeRequestAttributeIfNotPresent(ServletRequest request, String name, Object value) { if (request.getAttribute(name) == null) { request.setAttribute(name, value); } }
/** * Obtain the {@link WebAsyncManager} for the current request, or if not * found, create and associate it with the request. */ public static WebAsyncManager getAsyncManager(ServletRequest servletRequest) { WebAsyncManager asyncManager = null; Object asyncManagerAttr = servletRequest.getAttribute(WEB_ASYNC_MANAGER_ATTRIBUTE); if (asyncManagerAttr instanceof WebAsyncManager) { asyncManager = (WebAsyncManager) asyncManagerAttr; } if (asyncManager == null) { asyncManager = new WebAsyncManager(); servletRequest.setAttribute(WEB_ASYNC_MANAGER_ATTRIBUTE, asyncManager); } return asyncManager; }
/** * Obtain the {@link WebAsyncManager} for the current request, or if not * found, create and associate it with the request. */ public static WebAsyncManager getAsyncManager(ServletRequest servletRequest) { WebAsyncManager asyncManager = null; Object asyncManagerAttr = servletRequest.getAttribute(WEB_ASYNC_MANAGER_ATTRIBUTE); if (asyncManagerAttr instanceof WebAsyncManager) { asyncManager = (WebAsyncManager) asyncManagerAttr; } if (asyncManager == null) { asyncManager = new WebAsyncManager(); servletRequest.setAttribute(WEB_ASYNC_MANAGER_ATTRIBUTE, asyncManager); } return asyncManager; }
@Override public void forward(final ServletRequest request, final ServletResponse response) throws ServletException, IOException { final Object oldIt = request.getAttribute(MODEL_ATTRIBUTE_NAME); final Object oldResolvingClass = request.getAttribute(RESOLVING_CLASS_ATTRIBUTE_NAME); request.setAttribute(RESOLVING_CLASS_ATTRIBUTE_NAME, viewable.getResolvingClass()); request.setAttribute(OLD_MODEL_ATTRIBUTE_NAME, viewable.getModel()); request.setAttribute(MODEL_ATTRIBUTE_NAME, viewable.getModel()); request.setAttribute(BASE_PATH_ATTRIBUTE_NAME, basePath); request.setAttribute(REQUEST_ATTRIBUTE_NAME, request); request.setAttribute(RESPONSE_ATTRIBUTE_NAME, response); dispatcher.forward(request, response); request.setAttribute(RESOLVING_CLASS_ATTRIBUTE_NAME, oldResolvingClass); request.setAttribute(MODEL_ATTRIBUTE_NAME, oldIt); }
/** * Get a crumb value based on user specific information in the request. * @param request */ public String getCrumb(ServletRequest request) { String crumb = null; if (request != null) { crumb = (String) request.getAttribute(CRUMB_ATTRIBUTE); } if (crumb == null) { crumb = issueCrumb(request, getDescriptor().getCrumbSalt()); if (request != null) { if ((crumb != null) && crumb.length()>0) { request.setAttribute(CRUMB_ATTRIBUTE, crumb); } else { request.removeAttribute(CRUMB_ATTRIBUTE); } } } return crumb; }
boolean hasAlreadyFilteredAttribute = request.getAttribute(alreadyFilteredAttributeName) != null; request.setAttribute(alreadyFilteredAttributeName, Boolean.TRUE); try { doFilterInternal(httpRequest, httpResponse, filterChain);
if (request.getAttribute(AuthConfig.DRUID_AUTHENTICATION_RESULT) != null) { filterChain.doFilter(request, response); return; request.setAttribute( AuthConfig.DRUID_AUTHENTICATION_RESULT, new AuthenticationResult(clientPrincipal, authorizerName, name, null)
HttpServletResponse httpResponse = (HttpServletResponse) response; boolean hasAlreadyFilteredAttribute = request .getAttribute(this.alreadyFilteredAttributeName) != null; request.setAttribute(this.alreadyFilteredAttributeName, Boolean.TRUE); try { doFilterInternal(httpRequest, httpResponse, filterChain);
(AuthenticationCachingFilter) GeoServerCompositeFilter.this, (HttpServletRequest) request); if (cacheKey != null) request.setAttribute(CACHE_KEY_ATTRIBUTE, cacheKey); Authentication postAuthentication = SecurityContextHolder.getContext().getAuthentication(); String cacheKey = (String) request.getAttribute(CACHE_KEY_ATTRIBUTE); if (postAuthentication != null && cacheKey != null) { Integer idleSecs = (Integer) request.getAttribute(CACHE_KEY_IDLE_SECS); Integer liveSecs = (Integer) request.getAttribute(CACHE_KEY_LIVE_SECS); request.setAttribute(CACHE_KEY_ATTRIBUTE, null); request.setAttribute(CACHE_KEY_IDLE_SECS, null); request.setAttribute(CACHE_KEY_LIVE_SECS, null);
boolean hasAlreadyFilteredAttribute = request.getAttribute(alreadyFilteredAttributeName) != null; request.setAttribute(alreadyFilteredAttributeName, Boolean.TRUE); try { doFilterInternal(httpRequest, httpResponse, filterChain);
}catch (Exception x) { logger.error("Uncaught Exception:", x); if (req.getAttribute("javax.servlet.error.exception") == null) { req.setAttribute("javax.servlet.error.exception", x);
throws ServletException, IOException { String alreadyFilteredAttributeName = getAlreadyFilteredAttributeName(); if ( request.getAttribute(alreadyFilteredAttributeName) != null ) { log.trace("Filter '{}' already executed. Proceeding without invoking this filter.", getName()); filterChain.doFilter(request, response); request.setAttribute(alreadyFilteredAttributeName, Boolean.TRUE);
TraceContext context = (TraceContext) request.getAttribute(TraceContext.class.getName()); if (context != null) { request.setAttribute(SpanCustomizer.class.getName(), span.customizer()); request.setAttribute(TraceContext.class.getName(), span.context());
Integer mark = (Integer) req.getAttribute(markKey); if (mark != null) { req.setAttribute(markKey, mark+1); } else { req.setAttribute(markKey, 0); req.removeAttribute(markKey); } else { req.setAttribute(markKey, mark - 1);
/** * If request is filtered, returns true, otherwise marks request as filtered * and returns false. * A return value of false, indicates that the filter has not yet run. * A return value of true, indicates that the filter has run for this * request, and processing should not continue. * <P/> * Note that the method will mark the request as filtered on first * invocation. * <p/> * @see #ATTRIB_RUN_ONCE_EXT * @see #ATTRIB_RUN_ONCE_VALUE * * @param pRequest the servlet request * @return {@code true} if the request is already filtered, otherwise * {@code false}. */ private boolean isRunOnce(final ServletRequest pRequest) { // If request already filtered, return true (skip) if (pRequest.getAttribute(attribRunOnce) == ATTRIB_RUN_ONCE_VALUE) { return true; } // Set attribute and return false (continue) pRequest.setAttribute(attribRunOnce, ATTRIB_RUN_ONCE_VALUE); return false; }
@Override public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { if (request.getAttribute(ALREADY_FILTERED_ATTRIBUTE) != null) { chain.doFilter(request, response); } else { request.setAttribute(ALREADY_FILTERED_ATTRIBUTE, Boolean.TRUE); try { this.initializer.setLoggerContext(); chain.doFilter(request, response); } finally { this.initializer.clearLoggerContext(); } } }
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { Object apiGwContext = servletRequest.getAttribute(RequestReader.API_GATEWAY_CONTEXT_PROPERTY); if (apiGwContext == null) { log.warn("API Gateway context is null"); filterChain.doFilter(servletRequest, servletResponse); } if (!AwsProxyRequestContext.class.isAssignableFrom(apiGwContext.getClass())) { log.warn("API Gateway context object is not of valid type"); filterChain.doFilter(servletRequest, servletResponse); } AwsProxyRequestContext ctx = (AwsProxyRequestContext)apiGwContext; if (ctx.getIdentity() == null) { log.warn("Identity context is null"); filterChain.doFilter(servletRequest, servletResponse); } String cognitoIdentityId = ctx.getIdentity().getCognitoIdentityId(); if (cognitoIdentityId == null || "".equals(cognitoIdentityId.trim())) { log.warn("Cognito identity id in request is null"); } servletRequest.setAttribute(COGNITO_IDENTITY_ATTRIBUTE, cognitoIdentityId); filterChain.doFilter(servletRequest, servletResponse); }
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { Object apiGwContext = servletRequest.getAttribute(RequestReader.API_GATEWAY_CONTEXT_PROPERTY); if (apiGwContext == null) { log.warn("API Gateway context is null"); filterChain.doFilter(servletRequest, servletResponse); } if (!AwsProxyRequestContext.class.isAssignableFrom(apiGwContext.getClass())) { log.warn("API Gateway context object is not of valid type"); filterChain.doFilter(servletRequest, servletResponse); } AwsProxyRequestContext ctx = (AwsProxyRequestContext)apiGwContext; if (ctx.getIdentity() == null) { log.warn("Identity context is null"); filterChain.doFilter(servletRequest, servletResponse); } String cognitoIdentityId = ctx.getIdentity().getCognitoIdentityId(); if (cognitoIdentityId == null || "".equals(cognitoIdentityId.trim())) { log.warn("Cognito identity id in request is null"); } servletRequest.setAttribute(COGNITO_IDENTITY_ATTRIBUTE, cognitoIdentityId); filterChain.doFilter(servletRequest, servletResponse); }
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { Object apiGwContext = servletRequest.getAttribute(RequestReader.API_GATEWAY_CONTEXT_PROPERTY); if (apiGwContext == null) { log.warn("API Gateway context is null"); filterChain.doFilter(servletRequest, servletResponse); } if (!AwsProxyRequestContext.class.isAssignableFrom(apiGwContext.getClass())) { log.warn("API Gateway context object is not of valid type"); filterChain.doFilter(servletRequest, servletResponse); } AwsProxyRequestContext ctx = (AwsProxyRequestContext)apiGwContext; if (ctx.getIdentity() == null) { log.warn("Identity context is null"); filterChain.doFilter(servletRequest, servletResponse); } String cognitoIdentityId = ctx.getIdentity().getCognitoIdentityId(); if (cognitoIdentityId == null || "".equals(cognitoIdentityId.trim())) { log.warn("Cognito identity id in request is null"); } servletRequest.setAttribute(COGNITO_IDENTITY_ATTRIBUTE, cognitoIdentityId); filterChain.doFilter(servletRequest, servletResponse); }