X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Finternal%2Fkernel%2FNodeHttp.java;h=9a35e279ce28164ba6d53c79367c3b0f1021a2f8;hb=e91af5c65a42b3ff98400caa552965cdb3f730e6;hp=28c569bfdf6ff4908f9a28e10eeb736fe0581a8b;hpb=35904a4a72fe8a4908c345f73856711c7b4c472c;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/internal/kernel/NodeHttp.java b/org.argeo.cms/src/org/argeo/cms/internal/kernel/NodeHttp.java index 28c569bfd..9a35e279c 100644 --- a/org.argeo.cms/src/org/argeo/cms/internal/kernel/NodeHttp.java +++ b/org.argeo.cms/src/org/argeo/cms/internal/kernel/NodeHttp.java @@ -30,7 +30,6 @@ import org.osgi.service.http.NamespaceException; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; /** @@ -77,8 +76,7 @@ class NodeHttp implements KernelConstants, ArgeoJcrConstants { try { httpService.registerFilter("/", rootFilter, null, null); } catch (Exception e) { - throw new CmsException( - "Could not register root filter", e); + throw new CmsException("Could not register root filter", e); } } @@ -137,11 +135,11 @@ class NodeHttp implements KernelConstants, ArgeoJcrConstants { httpService.registerServlet(path, (Servlet) remotingServlet, ip, null); } - private Boolean isSessionAuthenticated(HttpSession httpSession) { - SecurityContext contextFromSession = (SecurityContext) httpSession - .getAttribute(SPRING_SECURITY_CONTEXT_KEY); - return contextFromSession != null; - } + // private Boolean isSessionAuthenticated(HttpSession httpSession) { + // SecurityContext contextFromSession = (SecurityContext) httpSession + // .getAttribute(SPRING_SECURITY_CONTEXT_KEY); + // return contextFromSession != null; + // } private void requestBasicAuth(HttpSession httpSession, HttpServletResponse response) { @@ -190,8 +188,12 @@ class NodeHttp implements KernelConstants, ArgeoJcrConstants { public void doFilter(HttpSession httpSession, HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException { - if (log.isTraceEnabled()) + if (log.isTraceEnabled()) { + log.trace(request.getRequestURL().append( + request.getQueryString() != null ? "?" + + request.getQueryString() : "")); logRequest(request); + } String servletPath = request.getServletPath(); @@ -221,7 +223,7 @@ class NodeHttp implements KernelConstants, ArgeoJcrConstants { int pathLength = path.length(); if (pathLength != 0 && (path.charAt(0) == '/') && !servletPath.endsWith("rwt-resources") - && !path.equals("/")) { + && path.lastIndexOf('/') != 0) { String newLocation = request.getServletPath() + "#" + path; response.setHeader("Location", newLocation); response.setStatus(HttpServletResponse.SC_FOUND); @@ -234,10 +236,10 @@ class NodeHttp implements KernelConstants, ArgeoJcrConstants { } private void logRequest(HttpServletRequest request) { - log.debug(request.getContextPath()); - log.debug(request.getServletPath()); - log.debug(request.getRequestURI()); - log.debug(request.getQueryString()); + log.debug("contextPath=" + request.getContextPath()); + log.debug("servletPath=" + request.getServletPath()); + log.debug("requestURI=" + request.getRequestURI()); + log.debug("queryString=" + request.getQueryString()); StringBuilder buf = new StringBuilder(); // headers Enumeration en = request.getHeaderNames(); @@ -277,10 +279,10 @@ class NodeHttp implements KernelConstants, ArgeoJcrConstants { FilterChain filterChain) throws IOException, ServletException { // Authenticate from session - if (isSessionAuthenticated(httpSession)) { - filterChain.doFilter(request, response); - return; - } + // if (isSessionAuthenticated(httpSession)) { + // filterChain.doFilter(request, response); + // return; + // } KernelUtils.anonymousLogin(authenticationManager); filterChain.doFilter(request, response); @@ -307,9 +309,9 @@ class NodeHttp implements KernelConstants, ArgeoJcrConstants { UsernamePasswordAuthenticationToken token = basicAuth(basicAuth); Authentication auth = authenticationManager.authenticate(token); SecurityContextHolder.getContext().setAuthentication(auth); - httpSession.setAttribute(SPRING_SECURITY_CONTEXT_KEY, - SecurityContextHolder.getContext()); - httpSession.setAttribute(ATTR_AUTH, Boolean.FALSE); + // httpSession.setAttribute(SPRING_SECURITY_CONTEXT_KEY, + // SecurityContextHolder.getContext()); + // httpSession.setAttribute(ATTR_AUTH, Boolean.FALSE); filterChain.doFilter(request, response); return; }