Class PortFilter

java.lang.Object
org.apache.shiro.web.servlet.ServletContextSupport
org.apache.shiro.web.servlet.AbstractFilter
org.apache.shiro.web.servlet.NameableFilter
org.apache.shiro.web.servlet.OncePerRequestFilter
org.apache.shiro.web.servlet.AdviceFilter
All Implemented Interfaces:
jakarta.servlet.Filter, org.apache.shiro.lang.util.Nameable
Direct Known Subclasses:
SslFilter

public class PortFilter extends AuthorizationFilter
A copy of Shiro's 1.2.0 PortFilter that works with tapestry-security 0.4.x A Filter that requires the request to be on a specific port, and if not, redirects to the same URL on that port.
Since:
0.4.1
  • Field Details

  • Constructor Details

  • Method Details

    • getPort

      public int getPort()
    • setPort

      public void setPort(int port)
    • toPort

      protected int toPort(Object mappedValue)
    • isAccessAllowed

      protected boolean isAccessAllowed(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, Object mappedValue) throws Exception
      Description copied from class: AccessControlFilter
      Returns true if the request is allowed to proceed through the filter normally, or false if the request should be handled by the onAccessDenied(request,response,mappedValue) method instead.
      Specified by:
      isAccessAllowed in class AccessControlFilter
      Parameters:
      request - the incoming ServletRequest
      response - the outgoing ServletResponse
      mappedValue - the filter-specific config value mapped to this filter in the URL rules mappings.
      Returns:
      true if the request should proceed through the filter normally, false if the request should be processed by this filter's AccessControlFilter.onAccessDenied(ServletRequest,ServletResponse,Object) method instead.
      Throws:
      Exception - if an error occurs during processing.
    • getScheme

      protected String getScheme(String requestScheme, int port)
    • onAccessDenied

      protected boolean onAccessDenied(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, Object mappedValue) throws IOException
      Redirects the request to the same exact incoming URL, but with the port listed in the filter's configuration.
      Overrides:
      onAccessDenied in class AccessControlFilter
      Parameters:
      request - the incoming ServletRequest
      response - the outgoing ServletResponse
      mappedValue - the config specified for the filter in the matching request's filter chain.
      Returns:
      false always to force a redirect.
      Throws:
      IOException