move dest-to-hash conversion to new helper class
This commit is contained in:
@ -2,9 +2,9 @@ package net.i2p.router.web;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.data.DataFormatException;
|
||||
import net.i2p.data.Destination;
|
||||
import net.i2p.data.Hash;
|
||||
import net.i2p.data.SessionKey;
|
||||
import net.i2p.util.ConvertToHash;
|
||||
|
||||
/**
|
||||
* Support additions via B64 Destkey, B64 Desthash, or blahblah.i2p
|
||||
@ -19,27 +19,12 @@ public class ConfigKeyringHandler extends FormHandler {
|
||||
addFormError("You must enter a destination and a key");
|
||||
return;
|
||||
}
|
||||
Hash h = new Hash();
|
||||
try {
|
||||
h.fromBase64(_peer);
|
||||
} catch (DataFormatException dfe) {}
|
||||
if (h.getData() == null) {
|
||||
try {
|
||||
Destination d = new Destination();
|
||||
d.fromBase64(_peer);
|
||||
h = d.calculateHash();
|
||||
} catch (DataFormatException dfe) {}
|
||||
}
|
||||
if (h.getData() == null) {
|
||||
Destination d = _context.namingService().lookup(_peer);
|
||||
if (d != null)
|
||||
h = d.calculateHash();
|
||||
}
|
||||
Hash h = ConvertToHash.getHash(_peer);
|
||||
SessionKey sk = new SessionKey();
|
||||
try {
|
||||
sk.fromBase64(_key);
|
||||
} catch (DataFormatException dfe) {}
|
||||
if (h.getData() != null && sk.getData() != null) {
|
||||
if (h != null && h.getData() != null && sk.getData() != null) {
|
||||
_context.keyRing().put(h, sk);
|
||||
addFormNotice("Key for " + h.toBase64() + " added to keyring");
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user