@Override public String postStep(HTTPRequest request) { //Yes: Set for monthly data limit. if (request.isPartSet("yes")) return FirstTimeWizardToadlet.WIZARD_STEP.BANDWIDTH_MONTHLY.name(); //No: Set for data rate limit. /*else if (request.isPartSet("no"))*/ return FirstTimeWizardToadlet.WIZARD_STEP.BANDWIDTH_RATE.name(); //Back: FirstTimeWizardToadlet handles that. } }
/** * Doesn't make any changes, just passes result on to SECURITY_NETWORK. * @param request Checked for "opennet" value. */ @Override public String postStep(HTTPRequest request) { if (request.isPartSet("opennet")) { return FirstTimeWizardToadlet.WIZARD_STEP.SECURITY_NETWORK+"&opennet="+ request.getPartAsStringFailsafe("opennet", 5); } else { //Nothing selected when "next" clicked. Display choice again. return FirstTimeWizardToadlet.WIZARD_STEP.OPENNET.name(); } } }
private String selectedValue(HTTPRequest request) { if (request.isParameterSet(filenameField()) && (request.isParameterSet(selectDir) || request.isParameterSet(selectFile))) { //Request is a GET. return request.getParam(filenameField()); } else if (request.isPartSet(filenameField()) && (request.isPartSet(selectDir) || request.isPartSet(selectFile))) { //Request is a POST. return request.getPartAsStringFailsafe(filenameField(), MAX_POST_SIZE); } return null; }
@Override public String postStep(HTTPRequest request) { setAutoUpdate(Boolean.parseBoolean(request.getPartAsStringFailsafe("autodeploy", 10))); setUPnP(request.isPartSet("upnp")); return FirstTimeWizardToadlet.WIZARD_STEP.OPENNET.name(); }
if(newThreatLevel == null || !request.isPartSet("security-levels.networkThreatLevel")) { return redirectTo.toString(); if (request.isPartSet("return-from-confirm")) { if((!request.isPartSet("security-levels.networkThreatLevel.confirm")) && (!request.isPartSet("security-levels.networkThreatLevel.tryConfirm"))) { displayConfirmationBox(redirectTo, networkThreatLevel); return redirectTo.toString(); } else if((!request.isPartSet("security-levels.networkThreatLevel.confirm")) && request.isPartSet("security-levels.networkThreatLevel.tryConfirm")) {
public void handleMethodPOST(URI uri, HTTPRequest request, ToadletContext ctx) throws ToadletContextClosedException, IOException { MultiValueTable<String, String> headers = new MultiValueTable<String, String>(); if (request.isPartSet("dismiss-user-alert")) { int userAlertHashCode = request.getIntPart("disable", -1); ctx.getAlertManager().dismissAlert(userAlertHashCode); } String redirect; try { redirect = request.getPartAsStringThrowing("redirectToAfterDisable", 1024); } catch (SizeLimitExceededException | NoSuchElementException e) { redirect = "."; } // hard whitelist of allowed origins to avoid https://www.owasp.org/index.php/Unvalidated_Redirects_and_Forwards_Cheat_Sheet // TODO: Parse the URL to ensure that it is a valid fproxy URL if (!("/alerts/".equals(redirect) || "/".equals(redirect) || "/#bookmarks".equals(redirect))) { redirect = "."; } headers.put("Location", redirect); ctx.sendReplyHeaders(302, "Found", headers, null, 0); }
(request.isPartSet("presetLow") || request.isPartSet("presetHigh") || request.isPartSet("presetNone"))) { if (request.isPartSet("presetLow")) { stepSECURITY_PHYSICAL.setThreatLevel(SecurityLevels.PHYSICAL_THREAT_LEVEL.NORMAL, stepSECURITY_PHYSICAL.getCurrentLevel()); } else if (request.isPartSet("presetHigh")) { } else if (request.isPartSet("back")) { stepURL(redirectTarget)), "GET"); if (newRequest.isPartSet("opennet")) { redirectTarget = WIZARD_STEP.SECURITY_NETWORK.name(); persistFields = new PersistFields(persistFields.preset, newRequest);
private void sendBookmarkFeeds(HTTPRequest req, BookmarkItem item, String publicDescription) { for(DarknetPeerNode peer : core.node.getDarknetConnections()) if(req.isPartSet("node_" + peer.hashCode())) peer.sendBookmarkFeed(item.getURI(), item.getName(), publicDescription, item.hasAnActivelink()); }
if (request.isPartSet("doAction") && request.getPartAsStringFailsafe("action",25).equals("send_n2ntm")) { PageNode page = ctx.getPageMaker().getPageNode(l10n("sendMessageTitle"), ctx); HTMLNode pageNode = page.outer; HashMap<String, String> peers = new HashMap<String, String>(); for(DarknetPeerNode pn : peerNodes) { if (request.isPartSet("node_"+pn.hashCode())) { String peer_name = pn.getName(); String peer_hash = String.valueOf(pn.hashCode()); writeHTMLReply(ctx, 200, "OK", pageNode.generate()); return; } else if (request.isPartSet("doAction") && request.getPartAsStringFailsafe("action",25).equals("update_notes")) { if (request.isPartSet("peerPrivateNote_"+pn.hashCode())) { if(!request.getPartAsStringFailsafe("peerPrivateNote_"+pn.hashCode(),250).equals(pn.getPrivateDarknetCommentNote())) { pn.setPrivateDarknetCommentNote(request.getPartAsStringFailsafe("peerPrivateNote_"+pn.hashCode(),250)); } else if (request.isPartSet("doAction") && request.getPartAsStringFailsafe("action",25).equals("enable")) { if (request.isPartSet("node_"+pn.hashCode())) { pn.enablePeer(); } else if (request.isPartSet("doAction") && request.getPartAsStringFailsafe("action",25).equals("disable")) { if (request.isPartSet("node_"+pn.hashCode())) { pn.disablePeer(); } else if (request.isPartSet("doAction") && request.getPartAsStringFailsafe("action",25).equals("set_burst_only")) {
return; if (request.isPartSet("add")) {
if (request.isPartSet("filter-local")) { try { FilterOperation filterOperation = getFilterOperation(request); } else if (request.isPartSet(LocalFileBrowserToadlet.selectFile)) { handleFilterRequest(request, ctx, core, true); } else if (request.isPartSet("filter-upload")) { handleFilterRequest(request, ctx, core, false); } else {
if (request.isPartSet("confirm-reset-to-defaults")) { PageNode page = ctx.getPageMaker().getPageNode( l10n("confirmResetTitle"), ctx); if (request.isPartSet(LocalFileBrowserToadlet.selectDir) || request.isPartSet("decline-default-reset")) { handleMethodGET(uri, request, ctx); return; Logger.minor(this, "Current config prefix is " + prefix); boolean resetToDefault = request.isPartSet("reset-to-defaults"); if (resetToDefault && logMINOR) { Logger.minor(this, "Resetting to defaults"); if (request.isPartSet(prefix + '.' + configName)) { if (request.isPartSet(wrapperConfigName)) { value = request.getPartAsStringFailsafe(wrapperConfigName, MAX_PARAM_VALUE_SIZE);
if(req.isPartSet("AddDefaultBookmarks")) { bookmarkManager.reAddDefaultBookmarks(); this.writeTemporaryRedirect(ctx, "Ok", "/"); else bookmark = bookmarkManager.getItemByPath(bookmarkPath); if(bookmark == null && !req.isPartSet("cancelCut")) { pageMaker.getInfobox("infobox-error", NodeL10n.getBase().getString("BookmarkEditorToadlet.error"), content, "bookmark-error", false). addChild("#", NodeL10n.getBase().getString("BookmarkEditorToadlet.bookmarkDoesNotExist", new String[]{"bookmark"}, new String[]{bookmarkPath})); if(req.isPartSet("confirmdelete")) { bookmarkManager.removeBookmark(bookmarkPath); bookmarkManager.storeBookmarks(); } else if(req.isPartSet("cancelCut")) cutedPath = null; else if("edit".equals(action) || "addItem".equals(action) || "addCat".equals(action)) { if(req.isPartSet("name")) name = req.getPartAsStringFailsafe("name", MAX_NAME_LENGTH); boolean hasAnActivelink = req.isPartSet("hasAnActivelink"); if(bookmark instanceof BookmarkItem) { BookmarkItem item = (BookmarkItem) bookmark; boolean hasAnActivelink = req.isPartSet("hasAnActivelink"); if (!isValidName(name)) { addNameError(pageMaker, content);
if(request.isPartSet("n2nm-browse")) if (request.isPartSet("n2nm-upload") || request.isPartSet(LocalFileBrowserToadlet.selectFile) || request.isPartSet("send")) { File filename = null; String message = request.getPartAsStringFailsafe("message", 5 * 1024); HTMLNode peerTableInfobox = contentNode.addChild("div", "class", "infobox infobox-normal"); DarknetPeerNode[] peerNodes = node.getDarknetConnections(); if(request.isPartSet(LocalFileBrowserToadlet.selectFile)) { String fnam = request.getPartAsStringFailsafe("filename", 1024); if(fnam != null && fnam.length() > 0) { peerTableHeaderRow.addChild("th", l10n("sendStatus")); for (DarknetPeerNode pn: peerNodes) { if (request.isPartSet("node_" + pn.hashCode())) { int status; return; } else if(request.isPartSet("n2nm-upload")) { try{ HTTPUploadedFile file = request.getUploadedFile("n2nm-upload");
return; if(request.isPartSet("seclevels")) { if(newThreatLevel != null) { if(newThreatLevel != node.securityLevels.getNetworkThreatLevel()) { if(!request.isPartSet(confirm) && !request.isPartSet(tryConfirm)) { HTMLNode warning = node.securityLevels.getConfirmWarning(newThreatLevel, confirm); if(warning != null) { changedAnything = true; } else if(request.isPartSet(confirm)) { if(request.isPartSet("masterPassword")) { String masterPassword = request.getPartAsStringFailsafe("masterPassword", 1024); if (masterPassword.isEmpty()) { if(request.isPartSet("redirect")) { String to = request.getPartAsStringFailsafe("redirect", 100); if(to.startsWith("/")) {
if (request.isPartSet("submit-official")) { final String pluginName = request.getPartAsStringFailsafe("plugin-name", 40); final String pluginSource = request.getPartAsStringFailsafe("pluginSource", 10); return; if (request.isPartSet("submit-other")) { final String pluginName = request.getPartAsStringFailsafe("plugin-url", 200); final boolean fileonly = "on".equalsIgnoreCase(request.getPartAsStringFailsafe("fileonly", 20)); return; if (request.isPartSet("submit-freenet")) { final String pluginName = request.getPartAsStringFailsafe("plugin-uri", 300); if (request.isPartSet("cancel")){ headers.put("Location", "/plugins/"); ctx.sendReplyHeaders(302, "Found", headers, null, 0); String pluginSpecification = getPluginSpecification(pm, pluginThreadName); pm.killPlugin(pluginThreadName, MAX_THREADED_UNLOAD_WAIT_TIME, false); if (request.isPartSet("purge")) { pm.removeCachedCopy(pluginSpecification); boolean purge = request.isPartSet("purge"); String pluginThreadName = request.getPartAsStringFailsafe("reloadconfirm", MAX_PLUGIN_NAME_LENGTH); final String fn = getPluginSpecification(pm, pluginThreadName);
updateForm.addChild("input", new String[]{"type", "name", "value"}, new String[]{"submit", "updateconfirm", l10n("update")}); writeHTMLReply(ctx, 200, "OK", pageNode.generate()); } else if (request.isPartSet("getThreadDump")) { if(!ctx.checkFormPassword(request)) return; PageNode page = ctx.getPageMaker().getPageNode(l10n("threadDumpTitle"), ctx); } else if (request.isPartSet("disable")) { if(!ctx.checkFormPassword(request)) return; int validAlertsRemaining = 0; } else if (request.isPartSet("key") && request.isPartSet("filename")) { if(!ctx.checkFormPassword(request)) return; bucket.free(); return; } else if (request.isPartSet("key")) { if(!ctx.checkFormPassword(request)) return; String key; } else if (request.isPartSet("exit")) { PageNode page = ctx.getPageMaker().getPageNode(l10n("shutdownConfirmTitle"), ctx); HTMLNode pageNode = page.outer; writeHTMLReply(ctx, 200, "OK", pageNode.generate()); return; } else if (request.isPartSet("shutdownconfirm")) { if(!ctx.checkFormPassword(request)) return; MultiValueTable<String, String> headers = new MultiValueTable<String, String>();
if (req.isPartSet(configName)) { curValue = req.getPartAsStringFailsafe(configName, MAX_PARAM_VALUE_SIZE); if (req.isPartSet("select-for") && req.isPartSet(LocalFileBrowserToadlet.selectDir)) { overriddenOption = req.getPartAsStringFailsafe("select-for", MAX_PARAM_VALUE_SIZE); if (req.isPartSet(fullName)) { value = req.getPartAsStringFailsafe(fullName, MAX_PARAM_VALUE_SIZE);