diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigKeyringHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigKeyringHandler.java index 9cb3bfcebb3c8175e1aab1d6ed759d5c534d397d..cb54c77ffac8757fa38d11c33af1bc09975d82e4 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigKeyringHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigKeyringHandler.java @@ -6,7 +6,7 @@ import net.i2p.data.SessionKey; import net.i2p.util.ConvertToHash; /** - * Support additions via B64 Destkey, B64 Desthash, or blahblah.i2p + * Support additions via B64 Destkey, B64 Desthash, blahblah.i2p, and others supported by ConvertToHash */ public class ConfigKeyringHandler extends FormHandler { private String _peer; @@ -14,21 +14,36 @@ public class ConfigKeyringHandler extends FormHandler { @Override protected void processForm() { - if ("Add key".equals(_action)) { - if (_peer == null || _key == null) { - addFormError("You must enter a destination and a key"); + if (_action == null) return; + boolean adding = _action.startsWith("Add"); + if (adding || _action.startsWith("Delete")) { + if (_peer == null) + addFormError("You must enter a destination"); + if (_key == null && adding) + addFormError("You must enter a key"); + if (_peer == null || (_key == null && adding)) return; - } Hash h = ConvertToHash.getHash(_peer); - SessionKey sk = new SessionKey(); - try { - sk.fromBase64(_key); - } catch (DataFormatException dfe) {} - if (h != null && h.getData() != null && sk.getData() != null) { - _context.keyRing().put(h, sk); - addFormNotice("Key for " + h.toBase64() + " added to keyring"); - } else { - addFormError("Invalid destination or key"); + if (adding) { + SessionKey sk = new SessionKey(); + try { + sk.fromBase64(_key); + } catch (DataFormatException dfe) {} + if (h != null && h.getData() != null && sk.getData() != null) { + _context.keyRing().put(h, sk); + addFormNotice("Key for " + h.toBase64() + " added to keyring"); + } else { + addFormError("Invalid destination or key"); + } + } else { // Delete + if (h != null && h.getData() != null) { + if (_context.keyRing().remove(h) != null) + addFormNotice("Key for " + h.toBase64() + " removed from keyring"); + else + addFormNotice("Key for " + h.toBase64() + " not found in keyring"); + } else { + addFormError("Invalid destination"); + } } } else { addFormError("Unsupported"); diff --git a/apps/routerconsole/jsp/configkeyring.jsp b/apps/routerconsole/jsp/configkeyring.jsp index 88957858de8804eef8e937895edd686555919eca..0c054a7d236590594ba9de8dee02d910d02729da 100644 --- a/apps/routerconsole/jsp/configkeyring.jsp +++ b/apps/routerconsole/jsp/configkeyring.jsp @@ -40,9 +40,9 @@ <td class="mediumtags" align="right">Dest. name, hash, or full key:</td> <td><textarea name="peer" cols="44" rows="1" style="height: 3em;" wrap="off"></textarea></td> </tr><tr> - <td class="mediumtags" align="right">Session Key:</td> + <td class="mediumtags" align="right">Encryption Key:</td> <td><input type="text" size="55" name="key" /></td> </tr><tr> - <td></td> - <td align="right"><input type="submit" name="action" value="Add key" /></td> + <td align="right" colspan="2"><input type="submit" name="action" value="Add key" /> + <input type="submit" name="action" value="Delete key" /> <input type="reset" value="Cancel" /></td> </tr></table></div></form></div></div></body></html> diff --git a/router/java/src/net/i2p/router/PersistentKeyRing.java b/router/java/src/net/i2p/router/PersistentKeyRing.java index c92437111b78a95c1ac7b41493c1a0b3d14fae58..af7c8c8dec6fa39b167c433a9c41f30a83c8d832 100644 --- a/router/java/src/net/i2p/router/PersistentKeyRing.java +++ b/router/java/src/net/i2p/router/PersistentKeyRing.java @@ -67,7 +67,7 @@ public class PersistentKeyRing extends KeyRing { @Override public void renderStatusHTML(Writer out) throws IOException { StringBuilder buf = new StringBuilder(1024); - buf.append("\n<table><tr><th align=\"left\">Destination Hash<th align=\"left\">Name or Dest.<th align=\"left\">Session Key</tr>"); + buf.append("\n<table><tr><th align=\"left\">Destination Hash<th align=\"left\">Name or Dest.<th align=\"left\">Encryption Key</tr>"); for (Entry<Hash, SessionKey> e : entrySet()) { buf.append("\n<tr><td>"); Hash h = e.getKey();