Changeset 6b6aaab8


Ignore:
Timestamp:
Mar 9, 2011 5:16:28 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
f71dfe50
Parents:
8bbcb0b
Message:
  • configui.jsp: Fix lang setting broken by previous nonce change
  • Console: Consolidate nonce handling
Location:
apps/routerconsole
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/web/FormHandler.java

    r8bbcb0b r6b6aaab8  
    2727    private boolean _processed;
    2828    private boolean _valid;
     29    private static final String NONCE_SUFFIX = ".nonce";
     30    private static final String PREV_SUFFIX = "Prev";
    2931   
    3032    public FormHandler() {
     
    163165        }
    164166       
    165         String nonce = System.getProperty(getClass().getName() + ".nonce");
    166         String noncePrev = System.getProperty(getClass().getName() + ".noncePrev");
     167        String nonce = System.getProperty(getClass().getName() + NONCE_SUFFIX);
     168        String noncePrev = nonce + PREV_SUFFIX;
    167169        if ( ( (nonce == null) || (!_nonce.equals(nonce)) ) &&
    168170             ( (noncePrev == null) || (!_nonce.equals(noncePrev)) ) ) {
     
    202204    }
    203205   
     206    /**
     207     *  Generate a new nonce, store old and new in the system properties.
     208     *  Only call once per page!
     209     *  @return a new random long as a String
     210     *  @since 0.8.5
     211     */
     212    public String getNewNonce() {
     213        String prop = getClass().getName() + NONCE_SUFFIX;
     214        String prev = System.getProperty(prop);
     215        if (prev != null)
     216            System.setProperty(prop + PREV_SUFFIX, prev);
     217        String rv = Long.toString(_context.random().nextLong());
     218        System.setProperty(prop, rv);
     219        return rv;
     220    }
     221
    204222    /** translate a string */
    205223    public String _(String s) {
  • apps/routerconsole/jsp/config.jsp

    r8bbcb0b r6b6aaab8  
    2323<div class="configure">
    2424 <form action="" method="POST">
    25  <% String prev = System.getProperty("net.i2p.router.web.ConfigNetHandler.nonce");
    26     if (prev != null) System.setProperty("net.i2p.router.web.ConfigNetHandler.noncePrev", prev);
    27     System.setProperty("net.i2p.router.web.ConfigNetHandler.nonce", new java.util.Random().nextLong()+""); %>
    28  <input type="hidden" name="nonce" value="<%=System.getProperty("net.i2p.router.web.ConfigNetHandler.nonce")%>" >
     25 <input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
    2926 <input type="hidden" name="action" value="blah" >
    3027 <h3><%=intl._("Bandwidth limiter")%></h3><p>
  • apps/routerconsole/jsp/configadvanced.jsp

    r8bbcb0b r6b6aaab8  
    2626 <div class="wideload">
    2727 <form action="" method="POST">
    28  <% String prev = System.getProperty("net.i2p.router.web.ConfigAdvancedHandler.nonce");
    29     if (prev != null) System.setProperty("net.i2p.router.web.ConfigAdvancedHandler.noncePrev", prev);
    30     System.setProperty("net.i2p.router.web.ConfigAdvancedHandler.nonce", new java.util.Random().nextLong()+""); %>
    31  <input type="hidden" name="nonce" value="<%=System.getProperty("net.i2p.router.web.ConfigAdvancedHandler.nonce")%>" >
     28 <input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
    3229 <input type="hidden" name="action" value="blah" >
    3330 <h3><%=intl._("Advanced I2P Configuration")%></h3>
  • apps/routerconsole/jsp/configclients.jsp

    r8bbcb0b r6b6aaab8  
    2929 <jsp:getProperty name="formhandler" property="allMessages" />
    3030 <div class="configure">
    31  <% String prev = System.getProperty("net.i2p.router.web.ConfigClientsHandler.nonce");
    32     if (prev != null) System.setProperty("net.i2p.router.web.ConfigClientsHandler.noncePrev", prev);
    33     String pageNonce = Long.toString(new java.util.Random().nextLong());
    34     System.setProperty("net.i2p.router.web.ConfigClientsHandler.nonce", pageNonce); %>
     31<%
     32    String pageNonce = formhandler.getNewNonce();
     33%>
    3534 <h3><%=intl._("Client Configuration")%></h3><p>
    3635 <%=intl._("The Java clients listed below are started by the router and run in the same JVM.")%>
  • apps/routerconsole/jsp/configkeyring.jsp

    r8bbcb0b r6b6aaab8  
    2828
    2929 <form action="" method="POST">
    30  <% String prev = System.getProperty("net.i2p.router.web.ConfigKeyringHandler.nonce");
    31     if (prev != null) System.setProperty("net.i2p.router.web.ConfigKeyringHandler.noncePrev", prev);
    32     System.setProperty("net.i2p.router.web.ConfigKeyringHandler.nonce", new java.util.Random().nextLong()+""); %>
    33  <input type="hidden" name="nonce" value="<%=System.getProperty("net.i2p.router.web.ConfigKeyringHandler.nonce")%>" >
     30 <input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
    3431 <h3><%=intl._("Manual Keyring Addition")%></h3><p>
    3532 <%=intl._("Enter keys for encrypted remote destinations here.")%>
  • apps/routerconsole/jsp/configlogging.jsp

    r8bbcb0b r6b6aaab8  
    2222<div class="configure">
    2323 <form action="" method="POST">
    24  <% String prev = System.getProperty("net.i2p.router.web.ConfigLoggingHandler.nonce");
    25     if (prev != null) System.setProperty("net.i2p.router.web.ConfigLoggingHandler.noncePrev", prev);
    26     System.setProperty("net.i2p.router.web.ConfigLoggingHandler.nonce", new java.util.Random().nextLong()+""); %>
    27  <input type="hidden" name="nonce" value="<%=System.getProperty("net.i2p.router.web.ConfigLoggingHandler.nonce")%>" >
     24 <input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
    2825 <input type="hidden" name="action" value="blah" >
    2926 <h3><%=intl._("Configure I2P Logging Options")%></h3>
  • apps/routerconsole/jsp/configpeer.jsp

    r8bbcb0b r6b6aaab8  
    3030 <div class="configure">
    3131 <form action="configpeer" method="POST">
    32  <% String prev = System.getProperty("net.i2p.router.web.ConfigPeerHandler.nonce");
    33     if (prev != null) System.setProperty("net.i2p.router.web.ConfigPeerHandler.noncePrev", prev);
    34     System.setProperty("net.i2p.router.web.ConfigPeerHandler.nonce", new java.util.Random().nextLong()+""); %>
    35  <input type="hidden" name="nonce" value="<%=System.getProperty("net.i2p.router.web.ConfigPeerHandler.nonce")%>" />
     32 <input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
    3633 <a name="sh"> </a>
    3734 <a name="unsh"> </a>
  • apps/routerconsole/jsp/configreseed.jsp

    r8bbcb0b r6b6aaab8  
    2424<jsp:getProperty name="formhandler" property="allMessages" />
    2525<div class="configure"><form action="" method="POST">
    26 <%  String prev = System.getProperty("net.i2p.router.web.ConfigReseedHandler.nonce");
    27     if (prev != null) System.setProperty("net.i2p.router.web.ConfigReseedHandler.noncePrev", prev);
    28     System.setProperty("net.i2p.router.web.ConfigReseedHandler.nonce", new java.util.Random().nextLong()+""); %>
    29 <input type="hidden" name="nonce" value="<%=System.getProperty("net.i2p.router.web.ConfigReseedHandler.nonce")%>" >
     26<input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
    3027<h3><%=intl._("Reseeding Configuration")%></h3>
    3128<p><%=intl._("Reseeding is the bootstrapping process used to find other routers when you first install I2P, or when your router has too few router references remaining.")%>
  • apps/routerconsole/jsp/configservice.jsp

    r8bbcb0b r6b6aaab8  
    2020 <div class="configure">
    2121 <form action="" method="POST">
    22  <% String prev = System.getProperty("net.i2p.router.web.ConfigServiceHandler.nonce");
    23     if (prev != null) System.setProperty("net.i2p.router.web.ConfigServiceHandler.noncePrev", prev);
    24     System.setProperty("net.i2p.router.web.ConfigServiceHandler.nonce", new java.util.Random().nextLong()+""); %>
    25  <input type="hidden" name="nonce" value="<%=System.getProperty("net.i2p.router.web.ConfigServiceHandler.nonce")%>" >
     22 <input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
    2623 <h3><%=intl._("Shutdown the router")%></h3>
    2724 <p><%=intl._("Graceful shutdown lets the router satisfy the agreements it has already made before shutting down, but may take a few minutes.")%>
  • apps/routerconsole/jsp/configstats.jsp

    r8bbcb0b r6b6aaab8  
    6868 <div class="configure">
    6969 <form id="statsForm" name="statsForm" action="" method="POST">
    70  <% String prev = System.getProperty("net.i2p.router.web.ConfigStatsHandler.nonce");
    71     if (prev != null) System.setProperty("net.i2p.router.web.ConfigStatsHandler.noncePrev", prev);
    72     System.setProperty("net.i2p.router.web.ConfigStatsHandler.nonce", new java.util.Random().nextLong()+""); %>
    7370 <input type="hidden" name="action" value="foo" >
    74  <input type="hidden" name="nonce" value="<%=System.getProperty("net.i2p.router.web.ConfigStatsHandler.nonce")%>" >
     71 <input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
    7572 <h3><%=intl._("Configure I2P Stat Collection")%></h3>
    7673 <p><%=intl._("Enable full stats?")%>
  • apps/routerconsole/jsp/configtunnels.jsp

    r8bbcb0b r6b6aaab8  
    3232<div class="wideload">
    3333<form action="" method="POST">
    34  <% String prev = System.getProperty("net.i2p.router.web.ConfigTunnelsHandler.nonce");
    35     if (prev != null) System.setProperty("net.i2p.router.web.ConfigTunnelsHandler.noncePrev", prev);
    36     System.setProperty("net.i2p.router.web.ConfigTunnelsHandler.nonce", new java.util.Random().nextLong()+""); %>
    37  <input type="hidden" name="nonce" value="<%=System.getProperty("net.i2p.router.web.ConfigTunnelsHandler.nonce")%>" >
     34 <input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
    3835 <input type="hidden" name="action" value="blah" >
    3936 <jsp:getProperty name="tunnelshelper" property="form" />
  • apps/routerconsole/jsp/configui.jsp

    r8bbcb0b r6b6aaab8  
    2525<div class="configure"><div class="topshimten"><h3><%=uihelper._("Router Console Theme")%></h3></div>
    2626 <form action="" method="POST">
    27  <% String prev = System.getProperty("net.i2p.router.web.ConfigUIHandler.nonce");
    28     if (prev != null) System.setProperty("net.i2p.router.web.ConfigUIHandler.noncePrev", prev);
    29     System.setProperty("net.i2p.router.web.ConfigUIHandler.nonce", new java.util.Random().nextLong()+""); %>
    30  <input type="hidden" name="nonce" value="<%=System.getProperty("net.i2p.router.web.ConfigUIHandler.nonce")%>" >
     27<%
     28    /** lang setting is done in css.jsi, not in ConfigUIHandler */
     29    String consoleNonce = System.getProperty("router.consoleNonce");
     30    if (consoleNonce == null) {
     31        consoleNonce = Long.toString(new java.util.Random().nextLong());
     32        System.setProperty("router.consoleNonce", consoleNonce);
     33    }
     34%>
     35 <input type="hidden" name="consoleNonce" value="<%=consoleNonce%>" >
     36 <input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
    3137 <input type="hidden" name="action" value="blah" >
    3238<%
  • apps/routerconsole/jsp/configupdate.jsp

    r8bbcb0b r6b6aaab8  
    2424<div class="configure">
    2525 <form action="" method="POST">
    26  <% String prev = System.getProperty("net.i2p.router.web.ConfigUpdateHandler.nonce");
    27     if (prev != null) System.setProperty("net.i2p.router.web.ConfigUpdateHandler.noncePrev", prev);
    28     System.setProperty("net.i2p.router.web.ConfigUpdateHandler.nonce", new java.util.Random().nextLong()+""); %>
    29  <input type="hidden" name="nonce" value="<%=System.getProperty("net.i2p.router.web.ConfigUpdateHandler.nonce")%>" >
     26 <input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
    3027 <% /* set hidden default */ %>
    3128 <input type="submit" name="action" value="" style="display:none" >
Note: See TracChangeset for help on using the changeset viewer.