|
@@ -1,16 +1,9 @@
|
|
|
package com.xt.js.gkaq.common;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
-
|
|
|
import javax.servlet.ServletRequest;
|
|
|
import javax.servlet.ServletResponse;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
-import org.apache.shiro.SecurityUtils;
|
|
|
-import org.apache.shiro.subject.Subject;
|
|
|
import org.apache.shiro.web.filter.authz.PortFilter;
|
|
|
-import org.apache.shiro.web.filter.authz.SslFilter;
|
|
|
-import org.apache.shiro.web.util.WebUtils;
|
|
|
|
|
|
/**
|
|
|
* httpÐÒéÇëÇó¹ýÂËÆ÷£¬²Î¿¼{@link org.apache.shiro.web.filter.authz.SslFilter}
|
|
@@ -60,43 +53,4 @@ public class HttpFilter extends PortFilter {
|
|
|
throws Exception {
|
|
|
return super.isAccessAllowed(request, response, mappedValue);
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * Redirects the request to the same exact incoming URL, but with the port listed in the filter's configuration.
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * the incoming <code>ServletRequest</code>
|
|
|
- * @param response
|
|
|
- * the outgoing <code>ServletResponse</code>
|
|
|
- * @param mappedValue
|
|
|
- * the config specified for the filter in the matching request's filter chain.
|
|
|
- * @return {@code false} always to force a redirect.
|
|
|
- */
|
|
|
- protected boolean onAccessDenied2(ServletRequest request, ServletResponse response, Object mappedValue)
|
|
|
- throws IOException {
|
|
|
-
|
|
|
- //just redirect to the specified port:
|
|
|
- int port = toPort(mappedValue);
|
|
|
- Subject subject = SecurityUtils.getSubject();
|
|
|
- String scheme = getScheme(request.getScheme(), port);
|
|
|
-
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
- sb.append(scheme).append("://");
|
|
|
- sb.append(request.getServerName());
|
|
|
- if (port != PortFilter.DEFAULT_HTTP_PORT && port != SslFilter.DEFAULT_HTTPS_PORT) {
|
|
|
- sb.append(":");
|
|
|
- sb.append(port);
|
|
|
- }
|
|
|
- if (request instanceof HttpServletRequest) {
|
|
|
- sb.append(WebUtils.toHttp(request).getRequestURI());
|
|
|
- String query = WebUtils.toHttp(request).getQueryString();
|
|
|
- if (query != null) {
|
|
|
- sb.append("?").append(query);
|
|
|
- }
|
|
|
- }
|
|
|
- System.err.println(sb.toString() + " isAuthenticated:" + subject.isAuthenticated());
|
|
|
- WebUtils.issueRedirect(request, response, sb.toString());
|
|
|
-
|
|
|
- return false;
|
|
|
- }
|
|
|
}
|