From a8bc3ffc9cf0cb7f18bc9dde44825e948ed3add2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 22 May 2009 07:33:54 +0200 Subject: [PATCH] Generate SSK key pair from first connected node. --- src/net/pterodactylus/jsite/core/NodeManager.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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."); } // -- 2.7.4