Changeset 7745bd8


Ignore:
Timestamp:
Sep 1, 2009 2:50:22 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
e392469
Parents:
01bed932
Message:
  • configkeyring.jsp: Add delete and cancel buttons
Files:
3 edited

Legend:

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

    r01bed932 r7745bd8  
    77
    88/**
    9  *  Support additions via B64 Destkey, B64 Desthash, or blahblah.i2p
     9 *  Support additions via B64 Destkey, B64 Desthash, blahblah.i2p, and others supported by ConvertToHash
    1010 */
    1111public class ConfigKeyringHandler extends FormHandler {
     
    1515    @Override
    1616    protected void processForm() {
    17         if ("Add key".equals(_action)) {
    18             if (_peer == null || _key == null) {
    19                 addFormError("You must enter a destination and a key");
     17        if (_action == null) return;
     18        boolean adding = _action.startsWith("Add");
     19        if (adding || _action.startsWith("Delete")) {
     20            if (_peer == null)
     21                addFormError("You must enter a destination");
     22            if (_key == null && adding)
     23                addFormError("You must enter a key");
     24            if (_peer == null || (_key == null && adding))
    2025                return;
    21             }
    2226            Hash h = ConvertToHash.getHash(_peer);
    23             SessionKey sk = new SessionKey();
    24             try {
    25                 sk.fromBase64(_key);
    26             } catch (DataFormatException dfe) {}
    27             if (h != null && h.getData() != null && sk.getData() != null) {
    28                 _context.keyRing().put(h, sk);
    29                 addFormNotice("Key for " + h.toBase64() + " added to keyring");
    30             } else {
    31                 addFormError("Invalid destination or key");
     27            if (adding) {
     28                SessionKey sk = new SessionKey();
     29                try {
     30                    sk.fromBase64(_key);
     31                } catch (DataFormatException dfe) {}
     32                if (h != null && h.getData() != null && sk.getData() != null) {
     33                    _context.keyRing().put(h, sk);
     34                    addFormNotice("Key for " + h.toBase64() + " added to keyring");
     35                } else {
     36                    addFormError("Invalid destination or key");
     37                }
     38            } else {  // Delete
     39                if (h != null && h.getData() != null) {
     40                    if (_context.keyRing().remove(h) != null)
     41                        addFormNotice("Key for " + h.toBase64() + " removed from keyring");
     42                    else
     43                        addFormNotice("Key for " + h.toBase64() + " not found in keyring");
     44                } else {
     45                    addFormError("Invalid destination");
     46                }
    3247            }
    3348        } else {
  • apps/routerconsole/jsp/configkeyring.jsp

    r01bed932 r7745bd8  
    4141          <td><textarea name="peer" cols="44" rows="1" style="height: 3em;" wrap="off"></textarea></td>
    4242        </tr><tr>
    43           <td class="mediumtags" align="right">Session Key:</td>
     43          <td class="mediumtags" align="right">Encryption Key:</td>
    4444          <td><input type="text" size="55" name="key" /></td>
    4545        </tr><tr>
    46           <td></td>
    47           <td align="right"><input type="submit" name="action" value="Add key" /></td>
     46          <td align="right" colspan="2"><input type="submit" name="action" value="Add key" />
     47             <input type="submit" name="action" value="Delete key" /> <input type="reset" value="Cancel" /></td>
    4848</tr></table></div></form></div></div></body></html>
  • router/java/src/net/i2p/router/PersistentKeyRing.java

    r01bed932 r7745bd8  
    6868    public void renderStatusHTML(Writer out) throws IOException {
    6969        StringBuilder buf = new StringBuilder(1024);
    70         buf.append("\n<table><tr><th align=\"left\">Destination Hash<th align=\"left\">Name or Dest.<th align=\"left\">Session Key</tr>");
     70        buf.append("\n<table><tr><th align=\"left\">Destination Hash<th align=\"left\">Name or Dest.<th align=\"left\">Encryption Key</tr>");
    7171        for (Entry<Hash, SessionKey> e : entrySet()) {
    7272            buf.append("\n<tr><td>");
Note: See TracChangeset for help on using the changeset viewer.