Java code to set Router Console password for dr|z3d

This commit is contained in:
sponge
2009-08-19 10:31:51 +00:00
parent ea7a9c259f
commit 8bbe7fabb3
4 changed files with 81 additions and 0 deletions

View File

@ -1,4 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/1">
<file>file:/usblv/NetBeansProjects/wi2p.i2p/apps/BOB/src/net/i2p/BOB/BOB.java</file>
</open-files>
</project-private>

View File

@ -0,0 +1,61 @@
package net.i2p.router.web;
/**
* Handler to deal with console config.
*
*/
public class ConfigConsoleHandler extends FormHandler {
private boolean _forceRestart;
private boolean _shouldSave;
private String _configPass;
// This is possibly the wrong place for this...
// private String _configPort;
@Override
protected void processForm() {
if(_shouldSave) {
saveChanges();
} else {
// noop
}
}
public void setShouldsave(String moo) {
_shouldSave = true;
}
public void setRestart(String moo) {
_forceRestart = true;
}
public void setConfigPass(String val) {
_configPass = val.trim();
}
/**
* The user made changes to the config and wants to save them, so
* lets go ahead and do so.
*
*/
private void saveChanges() {
if(_configPass != null) {
_context.router().setConfigSetting("consolePassword", _configPass);
} else {
_context.router().setConfigSetting("consolePassword", "");
}
boolean saved = _context.router().saveConfig();
if(saved) {
addFormNotice("Configuration saved successfully");
} else {
addFormNotice("Error saving the configuration (applied but not saved) - please see the error logs");
}
if(_forceRestart) {
addFormNotice("Performing a soft restart");
_context.router().restart();
addFormNotice("Soft restart complete");
}
}
}

View File

@ -0,0 +1,14 @@
package net.i2p.router.web;
public class ConfigConsoleHelper extends HelperBase {
private String consolePassword="consolePassword";
public ConfigConsoleHelper() {}
public String getSettings() {
StringBuilder buf = new StringBuilder(4*1024);
buf.append(consolePassword);
return buf.toString();
}
}

View File

@ -1,3 +1,6 @@
2009-08-19 sponge
* Java code to set Router Console password for dr|z3d
2009-08-18 dr|z3d
* Fixes for sidepanel
* Overhauled classic theme for i2ptunnels