Class PortFilter

  • All Implemented Interfaces:
    javax.servlet.Filter, org.apache.shiro.util.Nameable, PathConfigProcessor
    Direct Known Subclasses:
    SslFilter

    public class PortFilter
    extends AuthorizationFilter
    A Filter that requires the request to be on a specific port, and if not, redirects to the same URL on that port.

    Example config:

     [filters]
     port.port = 80
     

    [urls] /some/path/** = port # override for just this path: /another/path/** = port[8080]

    Since:
    1.0
    • Constructor Detail

      • PortFilter

        public PortFilter()
    • Method Detail

      • getPort

        public int getPort()
      • setPort

        public void setPort​(int port)
      • toPort

        protected int toPort​(Object mappedValue)
      • getScheme

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

        protected boolean onAccessDenied​(javax.servlet.ServletRequest request,
                                         javax.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