@Override public void handleRequest (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws ServletException, IOException { // The request has been checked and the filename is valid for delivery final String sFilename = aRequestScope.attrs ().getAsString (REQUEST_ATTR_OBJECT_DELIVERY_FILENAME); onDeliverResource (aRequestScope, aUnifiedResponse, sFilename); if (LOGGER.isDebugEnabled ()) LOGGER.debug ("Delivered object with name '" + sFilename + "'"); } }
/** * Returns the name of the HTTP method with which this request was made, for * example, GET, POST, or PUT. Same as the value of the CGI variable * REQUEST_METHOD. * * @return a <code>String</code> specifying the name of the method with which * this request was made */ default String getMethod () { return getRequest ().getMethod (); }
/** * @return The container with all request parameters. Never <code>null</code>. */ @Nonnull default IRequestParamContainer params () { return getRequestScope ().params (); }
/** * @return Return the absolute context path. E.g. * <code>http://localhost:8080/context</code>. Never with a trailing * slash. * @see #getContextPath() */ @Nonnull default String getFullContextPath () { return RequestHelper.getFullServerName (getRequest ()).append (getContextPath ()).toString (); }
public void handleRequest (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { String sRedirectURL = aRequestScope.getContextPath () + m_sServletPath; final String sQueryString = aRequestScope.getQueryString (); if (StringHelper.hasText (sQueryString)) sRedirectURL += "?" + sQueryString; aUnifiedResponse.setRedirect (sRedirectURL); } }
/** * Get the full URL (incl. protocol) and parameters of the current request. * <br> * <code>http://hostname.com:81/context/servlet/path/a/b?c=123&d=789</code> * * @return The full URL of the current request. */ @Nonnull @Nonempty default String getURL () { return (String) attrs ().computeIfAbsent (ScopeManager.SCOPE_ATTRIBUTE_PREFIX_INTERNAL + "req-url", k -> RequestHelper.getURL (getRequest ())); }
if (!aRequestScope.isValid ()) aMetadata.addField ("Request scope", "!!!Present but invalid!!!"); aMetadata.addField ("Request URL", aRequestScope.getURL ()); aMetadata.addField ("User agent", RequestHelper.getUserAgent (aRequestScope.getRequest ()).getAsString ()); aMetadata.addField ("Remote IP address", aRequestScope.getRemoteAddr ()); final UAProfile aProfile = RequestHelper.getUAProfile (aRequestScope.getRequest ()); if (!aProfile.equals (UAProfile.EMPTY)) aMetadata.addField ("UAProfile", aProfile.toString ()); for (final Map.Entry <String, Object> aEntry : aRequestScope.attrs () .getSortedByKey (Comparator.naturalOrder ()) .entrySet ()) for (final Map.Entry <String, Object> aEntry : aRequestScope.params () .getSortedByKey (Comparator.naturalOrder ()) .entrySet ()) .getSessionScopeOfID (aRequestScope.getSessionID ()); final HttpServletRequest aHttpRequest = aRequestScope.getRequest (); try
final HttpServletRequest aHttpRequest = aRequestScope.getRequest (); final int nFirstColWidth = 250; aTable.addHeaderRow ().addCells (EText.MSG_NAME.getDisplayText (aDisplayLocale), EText.MSG_VALUE.getDisplayText (aDisplayLocale)); for (final Map.Entry <String, ICommonsList <String>> aEntry : aRequestScope.headers () .getAllHeaders () .getSortedByKey (IComparator.getComparatorCollating (aDisplayLocale)) EText.MSG_TYPE.getDisplayText (aDisplayLocale), EText.MSG_VALUE.getDisplayText (aDisplayLocale)); for (final Map.Entry <String, Object> aEntry : aRequestScope.attrs () .getSortedByKey (IComparator.getComparatorCollating (aDisplayLocale)) .entrySet ())
public void handleRequest (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { final HttpServletRequest aRequest = aRequestScope.getRequest (); final SimpleURL aURL = new SimpleURL (aRequestScope.getContextPath () + m_sServletPath); aURL.add ("httpError", true); aURL.addIf ("httpStatusCode", StringHelper.getToString (aRequest.getAttribute ("javax.servlet.error.status_code")), Objects::nonNull); aURL.addIf ("httpStatusMessage", StringHelper.getToString (aRequest.getAttribute ("javax.servlet.error.message")), Objects::nonNull); aURL.addIf ("httpRequestUri", StringHelper.getToString (aRequest.getAttribute ("javax.servlet.error.request_uri")), Objects::nonNull); aURL.addIf ("httpReferrer", aRequestScope.headers ().getFirstHeaderValue (CHttpHeader.REFERER), Objects::nonNull); aUnifiedResponse.setRedirect (aURL); } }
String sFunctionName = aRequestScope.getPathWithinServlet (); if (StringHelper.startsWith (sFunctionName, '/')) sFunctionName = sFunctionName.substring (1); aRequestScope.params ().remove (REQUEST_PARAM_JQUERY_NO_CACHE); aRequestScope.attrs ().putIn (SCOPE_ATTR_NAME, sFunctionName); aRequestScope.attrs ().putIn (SCOPE_ATTR_INVOKER, new Wrapper <> (aAjaxInvoker)); aRequestScope.attrs ().putIn (SCOPE_ATTR_EXECUTOR, aAjaxExecutor); return EContinue.CONTINUE;
/** * Prefix the passed href with the absolute server + context path in case the * passed href has no protocol yet. * * @param aRequestScope * The request web scope to be used. Required for cookie-less handling. * May not be <code>null</code>. * @param sHRef * The href to be extended. May not be <code>null</code>. * @return Either the original href if already absolute or * <code>http://servername:8123/webapp-context/<i>href</i></code> * otherwise. Never <code>null</code>. */ @Nonnull public static String getURIWithServerAndContext (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final String sHRef) { ValueEnforcer.notNull (aRequestScope, "RequestScope"); ValueEnforcer.notNull (sHRef, "HRef"); // If known protocol, keep it if (hasKnownProtocol (sHRef)) return sHRef; final String sContextPath = aRequestScope.getContextPath (); final String sURI = aRequestScope.getFullServerPath () + _getURIWithContext (sContextPath, sHRef); return aRequestScope.encodeURL (sURI); }
private void _onException (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse, @Nonnull final Throwable t) throws IOException, ServletException { if (LOGGER.isErrorEnabled ()) LOGGER.error ("An exception was caught in servlet processing for URL '" + aRequestScope.getURL () + "'", t); // Invoke exception handler if (m_aSimpleHandler.onException (aRequestScope, aUnifiedResponse, t).isContinue ()) { // Propagate exception if (t instanceof IOException) throw (IOException) t; if (t instanceof ServletException) throw (ServletException) t; throw new ServletException (t); } }
@Override @OverridingMethodsMustInvokeSuper public EContinue initRequestState (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) { // cut the leading "/" final String sFilename = URLHelper.urlDecode (aRequestScope.getPathWithinServlet ()); if (StringHelper.hasNoText (sFilename) || !isValidFilenameAccordingToTheRules (sFilename) || isPossibleDirectoryTraversalRequest (sFilename)) { // Send the same error code as if it is simply not found to confuse // attackers :) LOGGER.warn ("Illegal delivery request '" + sFilename + "'"); aUnifiedResponse.setStatus (HttpServletResponse.SC_NOT_FOUND); return EContinue.BREAK; } // Filename seems to be safe aRequestScope.attrs ().putIn (REQUEST_ATTR_OBJECT_DELIVERY_FILENAME, sFilename); return EContinue.CONTINUE; }
String sKey = aRequestScope.getPathWithinServlet (); if (sKey.length () > 0) sKey = sKey.substring (1); final Enumeration <String> aEnum = aRequestScope.getRequest ().getParameterNames (); while (aEnum.hasMoreElements ()) final String [] aParamValues = aRequestScope.getRequest ().getParameterValues (sParamName); if (aParamValues != null) for (final String sParamValue : aParamValues)
LOGGER.debug ("DataTables AJAX request: " + CollectionHelper.getSortedByKey (aRequestScope.params ())); final int nDraw = aRequestScope.params ().getAsInt (DRAW); final int nDisplayStart = Math.max (aRequestScope.params ().getAsInt (START, 0), 0); final int nDisplayLength = aRequestScope.params ().getAsInt (LENGTH, DataTablesLengthMenu.COUNT_ALL); final String sSearchValue = aRequestScope.params ().getAsString (SEARCH_VALUE); final boolean bSearchRegEx = aRequestScope.params ().getAsBoolean (SEARCH_REGEX, false); final IRequestParamMap aOrder = aRequestScope.getRequestParamMap ().getMap (ORDER); if (aOrder != null) final IRequestParamMap aColumns = aRequestScope.getRequestParamMap ().getMap (COLUMNS); if (aColumns != null) final String sDataTablesID = aRequestScope.params ().getAsString (OBJECT_ID); final DataTablesServerData aServerData = UIStateRegistry.getCurrent () .getCastedState (DataTablesServerData.OT_DATATABLES,
/** * Prefix the passed href with the relative context path in case the passed * href has no protocol yet. * * @param aRequestScope * The request web scope to be used. Required for cookie-less handling. * May not be <code>null</code>. * @param sHRef * The href to be extended. May not be <code>null</code>. * @return Either the original href if already absolute or * <code>/webapp-context/<i>href</i></code> otherwise. Never * <code>null</code>. */ @Nonnull public static String getURIWithContext (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final String sHRef) { ValueEnforcer.notNull (aRequestScope, "RequestScope"); ValueEnforcer.notNull (sHRef, "HRef"); // If known protocol, keep it if (hasKnownProtocol (sHRef)) return sHRef; final String sContextPath = aRequestScope.getContextPath (); return aRequestScope.encodeURL (_getURIWithContext (sContextPath, sHRef)); }
WSSecurityException AS4HttpDebug.debug ( () -> "RECEIVE-START at " + aRequestScope.getFullContextAndServletPath ()); final HttpServletRequest aHttpServletRequest = aRequestScope.getRequest ();
/** * Check if this request uses a Cookie based session handling (meaning cookies * are enabled) or whether the session ID needs to be appended to a URL. * * @return <code>true</code> if the session ID is passed via cookies. */ default boolean areCookiesEnabled () { // Just check whether the session ID is appended to the URL or not return "a".equals (encodeURL ("a")); }
/** * Prefix the passed href with the absolute server + context path in case the * passed href has no protocol yet.<br> * Important: this method does not add the session ID in case cookies are * disabled by the client! * * @param sHRef * The href to be extended. May not be <code>null</code>. * @return Either the original href if already absolute or * <code>http://servername:8123/webapp-context/<i>href</i></code> * otherwise. Never <code>null</code>. */ @Nonnull public static String getURIWithServerAndContext (@Nonnull final String sHRef) { // If known protocol, keep it if (hasKnownProtocol (sHRef)) return sHRef; final IRequestWebScopeWithoutResponse aRequestScope = WebScopeManager.getRequestScope (); final String sContextPath = aRequestScope.getContextPath (); return aRequestScope.getFullServerPath () + _getURIWithContext (sContextPath, sHRef); }