Generate SSK key pair from first connected node.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 22 May 2009 05:33:54 +0000 (07:33 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 22 May 2009 05:33:54 +0000 (07:33 +0200)
src/net/pterodactylus/jsite/core/NodeManager.java

index a73a563..f7b231d 100644 (file)
@@ -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<Node>, 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.");
        }
 
        //