disable i2ptunnel nonce checking if console password is set

This commit is contained in:
zzz
2010-03-17 16:23:20 +00:00
parent 0f1eb464e8
commit 05597ae914

View File

@ -42,8 +42,6 @@ public class IndexBean {
private long _prevNonce2; private long _prevNonce2;
private long _curNonce; private long _curNonce;
private long _nextNonce; private long _nextNonce;
/** deprecated unimplemented, now using routerconsole realm */
private String _passphrase;
private String _type; private String _type;
private String _name; private String _name;
@ -82,7 +80,8 @@ public class IndexBean {
public static final int STANDBY = 4; public static final int STANDBY = 4;
/** deprecated unimplemented, now using routerconsole realm */ /** deprecated unimplemented, now using routerconsole realm */
public static final String PROP_TUNNEL_PASSPHRASE = "i2ptunnel.passphrase"; //public static final String PROP_TUNNEL_PASSPHRASE = "i2ptunnel.passphrase";
public static final String PROP_TUNNEL_PASSPHRASE = "consolePassword";
static final String PROP_NONCE = IndexBean.class.getName() + ".nonce"; static final String PROP_NONCE = IndexBean.class.getName() + ".nonce";
static final String PROP_NONCE_OLD = PROP_NONCE + '2'; static final String PROP_NONCE_OLD = PROP_NONCE + '2';
static final String CLIENT_NICKNAME = "shared clients"; static final String CLIENT_NICKNAME = "shared clients";
@ -129,7 +128,6 @@ public class IndexBean {
/** deprecated unimplemented, now using routerconsole realm */ /** deprecated unimplemented, now using routerconsole realm */
public void setPassphrase(String phrase) { public void setPassphrase(String phrase) {
_passphrase = phrase;
} }
public void setAction(String action) { public void setAction(String action) {
@ -145,20 +143,16 @@ public class IndexBean {
} }
} }
/** deprecated unimplemented, now using routerconsole realm */ /** just check if console password option is set, jetty will do auth */
private boolean validPassphrase(String proposed) { private boolean validPassphrase() {
if (proposed == null) return false;
String pass = _context.getProperty(PROP_TUNNEL_PASSPHRASE); String pass = _context.getProperty(PROP_TUNNEL_PASSPHRASE);
if ( (pass != null) && (pass.trim().length() > 0) ) return pass != null && pass.trim().length() > 0;
return pass.trim().equals(proposed.trim());
else
return false;
} }
private String processAction() { private String processAction() {
if ( (_action == null) || (_action.trim().length() <= 0) || ("Cancel".equals(_action))) if ( (_action == null) || (_action.trim().length() <= 0) || ("Cancel".equals(_action)))
return ""; return "";
if ( (_prevNonce != _curNonce) && (_prevNonce2 != _curNonce) && (!validPassphrase(_passphrase)) ) if ( (_prevNonce != _curNonce) && (_prevNonce2 != _curNonce) && (!validPassphrase()) )
return "Invalid form submission, probably because you used the 'back' or 'reload' button on your browser. Please resubmit."; return "Invalid form submission, probably because you used the 'back' or 'reload' button on your browser. Please resubmit.";
if ("Stop all".equals(_action)) if ("Stop all".equals(_action))
return stopAll(); return stopAll();