/** * Callbacks need a unique ID */ public String createUniqueId() { return idGenerator.generate(); }
public String addFileTransfer(FileTransfer generator) throws IOException { String id = idGenerator.generate(); putFileTransfer(id, generator); HttpServletRequest request = WebContextFactory.get().getHttpServletRequest(); return "'" + request.getContextPath() + request.getServletPath() + downloadHandlerUrl + id + "'"; }
/** * Generates and returns a new unique id suitable to use for the * CSRF session cookie. This method is itself exempted from CSRF checking. */ public String generateId() { WebContext webContext = WebContextFactory.get(); // If the current session already has a set DWRSESSIONID then we return that HttpServletRequest request = webContext.getHttpServletRequest(); HttpSession sess = request.getSession(false); if (sess != null && sess.getAttribute(ATTRIBUTE_DWRSESSIONID) != null) { return (String) sess.getAttribute(ATTRIBUTE_DWRSESSIONID); } // Otherwise generate a fresh ID IdGenerator idGenerator = webContext.getContainer().getBean(IdGenerator.class); return idGenerator.generate(); }