protected void initThreadLocals(HttpServletRequest request) throws Exception { HttpSession session = request.getSession(); User user = (User) session.getAttribute(WebKeys.USER); initThreadLocals(user); PrincipalThreadLocal.setPassword(PortalUtil.getUserPassword(request)); }
protected HttpServletRequest setCredentials( HttpServletRequest request, HttpSession session, long userId) throws Exception { User user = UserLocalServiceUtil.getUser(userId); String userIdString = String.valueOf(userId); request = new ProtectedServletRequest(request, userIdString); session.setAttribute(WebKeys.USER, user); session.setAttribute(_AUTHENTICATED_USER, userIdString); if (_usePermissionChecker) { PrincipalThreadLocal.setName(userId); PrincipalThreadLocal.setPassword(PortalUtil.getUserPassword(request)); PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user, false); PermissionThreadLocal.setPermissionChecker(permissionChecker); } return request; }
protected String getPassword(HttpServletRequest request) { return PortalUtil.getUserPassword(request); }
@Override public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { User user = null; try { user = _getUser(request); PrincipalThreadLocal.setName(user.getUserId()); PrincipalThreadLocal.setPassword(PortalUtil.getUserPassword(request)); PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user); PermissionThreadLocal.setPermissionChecker(permissionChecker); if (_lastModified) { long lastModified = getLastModified(request); if (lastModified > 0) { long ifModifiedSince = request.getDateHeader(HttpHeaders.IF_MODIFIED_SINCE); if ((ifModifiedSince > 0) && (ifModifiedSince == lastModified)) { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); return; } } if (lastModified > 0) { response.setDateHeader(HttpHeaders.LAST_MODIFIED, lastModified); } } String path = HttpUtil.fixPath(request.getPathInfo()); String[] pathArray = StringUtil.split(path, CharPool.SLASH); if (pathArray.length == 0) { sendGroups(response, user, request.getServletPath() + StringPool.SLASH + path); } else { if (_PATH_DDM.equals(pathArray[0])) { sendDDMRecordFile(request, response, pathArray); } else if (Validator.isNumber(pathArray[0])) { sendFile(request, response, user, pathArray); } else { if (isLegacyImageGalleryImageId(request, response)) { return; } Image image = getImage(request, true); if (image != null) { writeImage(image, request, response); } else { sendDocumentLibrary( request, response, user, request.getServletPath() + StringPool.SLASH + path, pathArray); } } } } catch (NoSuchFileEntryException nsfee) { PortalUtil.sendError(HttpServletResponse.SC_NOT_FOUND, nsfee, request, response); } catch (PrincipalException pe) { processPrincipalException(pe, user, request, response); } catch (Exception e) { PortalUtil.sendError(e, request, response); } }