- @SuppressWarnings("unused")
- private HighLevelClient findUnusedClient(boolean wait, boolean markAsUsed) {
- synchronized (syncObject) {
- HighLevelClient freeHighLevelClient = null;
- while (freeHighLevelClient == null) {
- for (HighLevelClient highLevelClient: nodeClients.values()) {
- if (!usedConnections.contains(highLevelClient)) {
- freeHighLevelClient = highLevelClient;
- break;
- }
- }
- if (freeHighLevelClient != null) {
- if (markAsUsed) {
- usedConnections.add(freeHighLevelClient);
- }
- return freeHighLevelClient;
- }
- if (!wait) {
- return null;
- }
+ FcpClient getFcpClient(Node node) {
+ return nodeClients.get(node);
+ }
+
+ /**
+ * Generates a new SSK key pair.
+ *
+ * @return An array with the private key at index <code>0</code> and the
+ * public key at index <code>1</code>
+ * @throws IOException
+ * if an I/O error occurs communicating with the node
+ * @throws JSiteException
+ * 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");
+ }
+ FcpException fcpException = null;
+ for (FcpClient fcpClient : nodeClients.values()) {
+ try {
+ SSKKeypair sskKeypair = fcpClient.generateKeyPair();
+ return new String[] { sskKeypair.getInsertURI(), sskKeypair.getRequestURI() };
+ } catch (FcpException fcpe1) {
+ fcpException = fcpe1;