congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
org.apache.shiro.web.util
Code IndexAdd Tabnine to your IDE (free)

How to use org.apache.shiro.web.util

Best Java code snippets using org.apache.shiro.web.util (Showing top 20 results out of 504)

origin: apache/shiro

public static ServletRequest getRequest(Object requestPairSource) {
  if (requestPairSource instanceof RequestPairSource) {
    return ((RequestPairSource) requestPairSource).getServletRequest();
  }
  return null;
}
origin: apache/shiro

public static ServletResponse getResponse(Object requestPairSource) {
  if (requestPairSource instanceof RequestPairSource) {
    return ((RequestPairSource) requestPairSource).getServletResponse();
  }
  return null;
}
origin: apache/shiro

/**
 * Create a new RedirectView with the given URL.
 * <p>The given URL will be considered as relative to the web server,
 * not as relative to the current ServletContext.
 *
 * @param url the URL to redirect to
 * @see #RedirectView(String, boolean)
 */
public RedirectView(String url) {
  setUrl(url);
}
origin: apache/shiro

  /**
   * Merely returns
   * <code>WebUtils.{@link org.apache.shiro.web.util.WebUtils#getPathWithinApplication(javax.servlet.http.HttpServletRequest) getPathWithinApplication(request)}</code>
   * and can be overridden by subclasses for custom request-to-application-path resolution behavior.
   *
   * @param request the incoming {@code ServletRequest}
   * @return the request's path within the appliation.
   */
  protected String getPathWithinApplication(ServletRequest request) {
    return WebUtils.getPathWithinApplication(WebUtils.toHttp(request));
  }
}
origin: apache/shiro

/**
 * Redirects the current request to a new URL based on the given parameters.
 *
 * @param request          the servlet request.
 * @param response         the servlet response.
 * @param url              the URL to redirect the user to.
 * @param queryParams      a map of parameters that should be set as request parameters for the new request.
 * @param contextRelative  true if the URL is relative to the servlet context path, or false if the URL is absolute.
 * @param http10Compatible whether to stay compatible with HTTP 1.0 clients.
 * @throws java.io.IOException if thrown by response methods.
 */
public static void issueRedirect(ServletRequest request, ServletResponse response, String url, Map queryParams, boolean contextRelative, boolean http10Compatible) throws IOException {
  RedirectView view = new RedirectView(url, contextRelative, http10Compatible);
  view.renderMergedOutputModel(queryParams, toHttp(request), toHttp(response));
}
origin: apache/shiro

/**
 * Redirects the current request to a new URL based on the given parameters and default values
 * for unspecified parameters.
 *
 * @param request  the servlet request.
 * @param response the servlet response.
 * @param url      the URL to redirect the user to.
 * @throws java.io.IOException if thrown by response methods.
 */
public static void issueRedirect(ServletRequest request, ServletResponse response, String url) throws IOException {
  issueRedirect(request, response, url, null, true, true);
}
origin: apache/shiro

public static HttpServletRequest getHttpRequest(Object requestPairSource) {
  ServletRequest request = getRequest(requestPairSource);
  if (request instanceof HttpServletRequest) {
    return (HttpServletRequest) request;
  }
  return null;
}
origin: apache/shiro

public static HttpServletResponse getHttpResponse(Object requestPairSource) {
  ServletResponse response = getResponse(requestPairSource);
  if (response instanceof HttpServletResponse) {
    return (HttpServletResponse) response;
  }
  return null;
}
origin: apache/shiro

public static boolean isWeb(Object requestPairSource) {
  return requestPairSource instanceof RequestPairSource && isWeb((RequestPairSource) requestPairSource);
}
origin: apache/shiro

public static boolean isHttp(Object requestPairSource) {
  return requestPairSource instanceof RequestPairSource && isHttp((RequestPairSource) requestPairSource);
}
origin: apache/shiro

/**
 * Convenience method merely delegates to
 * {@link WebUtils#saveRequest(javax.servlet.ServletRequest) WebUtils.saveRequest(request)} to save the request
 * state for reuse later.  This is mostly used to retain user request state when a redirect is issued to
 * return the user to their originally requested url/resource.
 * <p/>
 * If you need to save and then immediately redirect the user to login, consider using
 * {@link #saveRequestAndRedirectToLogin(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
 * saveRequestAndRedirectToLogin(request,response)} directly.
 *
 * @param request the incoming ServletRequest to save for re-use later (for example, after a redirect).
 */
protected void saveRequest(ServletRequest request) {
  WebUtils.saveRequest(request);
}
origin: apache/shiro

private static boolean isWeb(RequestPairSource source) {
  ServletRequest request = source.getServletRequest();
  ServletResponse response = source.getServletResponse();
  return request != null && response != null;
}
origin: apache/shiro

/**
 * Returns {@code true} if a session is allowed to be created for a subject-associated request, {@code false}
 * otherwise.
 * <p/>
 * <b>This method exists for Shiro's internal framework needs and should never be called by Shiro end-users.  It
 * could be changed/removed at any time.</b>
 *
 * @param requestPairSource a {@link RequestPairSource} instance, almost always a
 *                          {@link org.apache.shiro.web.subject.WebSubject WebSubject} instance.
 * @return {@code true} if a session is allowed to be created for a subject-associated request, {@code false}
 *         otherwise.
 */
public static boolean _isSessionCreationEnabled(Object requestPairSource) {
  if (requestPairSource instanceof RequestPairSource) {
    RequestPairSource source = (RequestPairSource) requestPairSource;
    return _isSessionCreationEnabled(source.getServletRequest());
  }
  return true; //by default
}
origin: apache/shiro

/**
 * Normalize a relative URI path that may have relative values ("/./",
 * "/../", and so on ) it it.  <strong>WARNING</strong> - This method is
 * useful only for normalizing application-generated paths.  It does not
 * try to perform security checks for malicious input.
 * Normalize operations were was happily taken from org.apache.catalina.util.RequestUtil in
 * Tomcat trunk, r939305
 *
 * @param path Relative path to be normalized
 * @return normalized path
 */
public static String normalize(String path) {
  return normalize(path, true);
}
origin: apache/shiro

/**
 * Find the Shiro {@link WebEnvironment} for this web application, which is typically loaded via
 * {@link org.apache.shiro.web.env.EnvironmentLoaderListener}.
 * <p/>
 * This implementation rethrows an exception that happened on environment startup to differentiate between a failed
 * environment startup and no environment at all.
 *
 * @param sc ServletContext to find the web application context for
 * @return the root WebApplicationContext for this web app, or <code>null</code> if none
 * @see org.apache.shiro.web.env.EnvironmentLoader#ENVIRONMENT_ATTRIBUTE_KEY
 * @since 1.2
 */
public static WebEnvironment getWebEnvironment(ServletContext sc) {
  return getWebEnvironment(sc, EnvironmentLoader.ENVIRONMENT_ATTRIBUTE_KEY);
}
origin: apache/shiro

/**
 * Returns the context path within the application based on the specified <code>request</code>.
 * <p/>
 * This implementation merely delegates to
 * {@link WebUtils#getPathWithinApplication(javax.servlet.http.HttpServletRequest) WebUtils.getPathWithinApplication(request)},
 * but can be overridden by subclasses for custom logic.
 *
 * @param request the incoming <code>ServletRequest</code>
 * @return the context path within the application.
 */
protected String getPathWithinApplication(ServletRequest request) {
  return WebUtils.getPathWithinApplication(WebUtils.toHttp(request));
}
origin: apache/shiro

/**
 * Issues an HTTP redirect to the specified URL after subject logout.  This implementation simply calls
 * {@code WebUtils.}{@link WebUtils#issueRedirect(javax.servlet.ServletRequest, javax.servlet.ServletResponse, String) issueRedirect(request,response,redirectUrl)}.
 *
 * @param request  the incoming Servlet request
 * @param response the outgoing Servlet response
 * @param redirectUrl the URL to where the browser will be redirected immediately after Subject logout.
 * @throws Exception if there is any error.
 */
protected void issueRedirect(ServletRequest request, ServletResponse response, String redirectUrl) throws Exception {
  WebUtils.issueRedirect(request, response, redirectUrl);
}
origin: apache/shiro

private static boolean isHttp(RequestPairSource source) {
  ServletRequest request = source.getServletRequest();
  ServletResponse response = source.getServletResponse();
  return request instanceof HttpServletRequest && response instanceof HttpServletResponse;
}
origin: apache/shiro

/**
 * Redirects the current request to a new URL based on the given parameters and default values
 * for unspecified parameters.
 *
 * @param request     the servlet request.
 * @param response    the servlet response.
 * @param url         the URL to redirect the user to.
 * @param queryParams a map of parameters that should be set as request parameters for the new request.
 * @throws java.io.IOException if thrown by response methods.
 */
public static void issueRedirect(ServletRequest request, ServletResponse response, String url, Map queryParams) throws IOException {
  issueRedirect(request, response, url, queryParams, true, true);
}
origin: apache/shiro

/**
 * Redirects the current request to a new URL based on the given parameters and default values
 * for unspecified parameters.
 *
 * @param request         the servlet request.
 * @param response        the servlet response.
 * @param url             the URL to redirect the user to.
 * @param queryParams     a map of parameters that should be set as request parameters for the new request.
 * @param contextRelative true if the URL is relative to the servlet context path, or false if the URL is absolute.
 * @throws java.io.IOException if thrown by response methods.
 */
public static void issueRedirect(ServletRequest request, ServletResponse response, String url, Map queryParams, boolean contextRelative) throws IOException {
  issueRedirect(request, response, url, queryParams, contextRelative, true);
}
org.apache.shiro.web.util

Most used classes

  • WebUtils
  • SavedRequest
  • RedirectView
    View that redirects to an absolute, context relative, or current request relative URL, exposing all
  • RequestPairSource
    A RequestPairSource is a component that can supply a ServletRequest and ServletResponse pair associa
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now