From: David ‘Bombe’ Roden Date: Fri, 22 May 2009 05:33:54 +0000 (+0200) Subject: Generate SSK key pair from first connected node. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=a8bc3ffc9cf0cb7f18bc9dde44825e948ed3add2;p=jSite2.git Generate SSK key pair from first connected node. --- diff --git a/src/net/pterodactylus/jsite/core/NodeManager.java b/src/net/pterodactylus/jsite/core/NodeManager.java index a73a563..f7b231d 100644 --- a/src/net/pterodactylus/jsite/core/NodeManager.java +++ b/src/net/pterodactylus/jsite/core/NodeManager.java @@ -40,6 +40,7 @@ import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; +import net.pterodactylus.fcp.SSKKeypair; import net.pterodactylus.fcp.highlevel.FcpClient; import net.pterodactylus.fcp.highlevel.FcpException; import net.pterodactylus.jsite.util.IdGenerator; @@ -385,14 +386,22 @@ public class NodeManager implements Iterable, PropertyChangeListener { * @throws IOException * if an I/O error occurs communicating with the node * @throws JSiteException - * if there is a problem with the node + * if there is no connected node */ public String[] generateKeyPair() throws IOException, JSiteException { logger.log(Level.FINEST, "generateKeyPair()"); if (nodes.isEmpty()) { throw new NoNodeException("no node configured"); } - return null; + for (FcpClient fcpClient : nodeClients.values()) { + try { + SSKKeypair sskKeypair = fcpClient.generateKeyPair(); + return new String[] { sskKeypair.getInsertURI(), sskKeypair.getRequestURI() }; + } catch (FcpException fcpe1) { + /* ignore, we’ll throw later on if needs be. */ + } + } + throw new JSiteException("Could not get SSK key pair from any node."); } //