Examples of SshKey


Examples of org.jclouds.digitalocean.domain.SshKey

      DigitalOceanApi api = api(server.getUrl("/"));
      KeyPairApi keyPairApi = api.getKeyPairApi();

      try {
         String publicKey = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-rsa.txt"));
         SshKey key = keyPairApi.edit(47, publicKey);

         assertRequestHasParameters(server.takeRequest(), "/ssh_keys/47/edit",
               ImmutableMultimap.of("ssh_pub_key", publicKey));

         assertEquals(key.getId(), 47);
         assertEquals(key.getName(), "my_key");
         assertNotNull(key.getPublicKey());
      } finally {
         api.close();
         server.shutdown();
      }
   }
View Full Code Here

Examples of org.jclouds.digitalocean.domain.SshKey

   }

   @Test(dependsOnMethods = "testCreateKey")
   public void testEditKey() throws IOException {
      String newKey = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-dsa.txt"));
      SshKey updated = api.getKeyPairApi().edit(key.getId(), newKey);

      assertNotNull(updated.getPublicKey(), "The SSH key should have a public key");
      assertEquals(updated.getPublicKey().getAlgorithm(), "DSA");
   }
View Full Code Here

Examples of org.jclouds.digitalocean.domain.SshKey

      CreateDropletOptions.Builder options = CreateDropletOptions.builder();

      // Create a default keypair for the node so it has a known private key
      Map<String, String> defaultKeys = keyGenerator.get();
      logger.debug(">> creating default keypair for node...");
      SshKey defaultKey = api.getKeyPairApi().create(name, defaultKeys.get("public"));
      logger.debug(">> keypair created! %s", defaultKey);
      options.addSshKeyId(defaultKey.getId());

      // Check if there is a key to authorize in the portable options
      if (!Strings.isNullOrEmpty(template.getOptions().getPublicKey())) {
         logger.debug(">> creating user keypair for node...");
         // The DigitalOcean API accepts multiple key pairs with the same name. It will be useful to identify all
         // keypairs associated with the node when it comes to destroy it
         SshKey key = api.getKeyPairApi().create(name, template.getOptions().getPublicKey());
         logger.debug(">> keypair created! %s", key);
         options.addSshKeyId(key.getId());
      }

      // DigitalOcean specific options
      if (!templateOptions.getSshKeyIds().isEmpty()) {
         options.addSshKeyIds(templateOptions.getSshKeyIds());
View Full Code Here

Examples of org.jclouds.digitalocean.domain.SshKey

   }

   @Test(dependsOnMethods = "testCreateKey")
   public void testEditKey() throws IOException {
      String newKey = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-dsa.txt"));
      SshKey updated = api.getKeyPairApi().edit(key.getId(), newKey);

      assertNotNull(updated.getPublicKey(), "The SSH key should have a public key");
      assertEquals(updated.getPublicKey().getAlgorithm(), "DSA");
   }
View Full Code Here

Examples of org.jclouds.digitalocean.domain.SshKey

      DigitalOceanApi api = api(server.getUrl("/"));
      KeyPairApi keyPairApi = api.getKeyPairApi();

      try {
         SshKey key = keyPairApi.get(47);

         assertRequestHasCommonFields(server.takeRequest(), "/ssh_keys/47");
         assertEquals(key.getId(), 47);
         assertEquals(key.getName(), "my_key");
         assertNotNull(key.getPublicKey());
      } finally {
         api.close();
         server.shutdown();
      }
   }
View Full Code Here

Examples of org.jclouds.digitalocean.domain.SshKey

      DigitalOceanApi api = api(server.getUrl("/"));
      KeyPairApi keyPairApi = api.getKeyPairApi();

      try {
         SshKey key = keyPairApi.get(47);

         assertRequestHasCommonFields(server.takeRequest(), "/ssh_keys/47");
         assertNull(key);
      } finally {
         api.close();
View Full Code Here

Examples of org.jclouds.digitalocean.domain.SshKey

      DigitalOceanApi api = api(server.getUrl("/"));
      KeyPairApi keyPairApi = api.getKeyPairApi();

      try {
         String publicKey = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-rsa.txt"));
         SshKey key = keyPairApi.create("my_key", publicKey);

         assertRequestHasParameters(server.takeRequest(), "/ssh_keys/new",
               ImmutableMultimap.of("name", "my_key", "ssh_pub_key", publicKey));

         assertEquals(key.getId(), 47);
         assertEquals(key.getName(), "my_key");
         assertNotNull(key.getPublicKey());
      } finally {
         api.close();
         server.shutdown();
      }
   }
View Full Code Here

Examples of org.jclouds.digitalocean.domain.SshKey

      DigitalOceanApi api = api(server.getUrl("/"));
      KeyPairApi keyPairApi = api.getKeyPairApi();

      try {
         String publicKey = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-rsa.txt"));
         SshKey key = keyPairApi.edit(47, publicKey);

         assertRequestHasParameters(server.takeRequest(), "/ssh_keys/47/edit",
               ImmutableMultimap.of("ssh_pub_key", publicKey));

         assertEquals(key.getId(), 47);
         assertEquals(key.getName(), "my_key");
         assertNotNull(key.getPublicKey());
      } finally {
         api.close();
         server.shutdown();
      }
   }
View Full Code Here

Examples of org.jclouds.digitalocean.domain.SshKey

      CreateDropletOptions.Builder options = CreateDropletOptions.builder();

      // Create a default keypair for the node so it has a known private key
      Map<String, String> defaultKeys = keyGenerator.get();
      logger.debug(">> creating default keypair for node...");
      SshKey defaultKey = api.getKeyPairApi().create(name, defaultKeys.get("public"));
      logger.debug(">> keypair created! %s", defaultKey);
      options.addSshKeyId(defaultKey.getId());

      // Check if there is a key to authorize in the portable options
      if (!Strings.isNullOrEmpty(template.getOptions().getPublicKey())) {
         logger.debug(">> creating user keypair for node...");
         // The DigitalOcean API accepts multiple key pairs with the same name. It will be useful to identify all
         // keypairs associated with the node when it comes to destroy it
         SshKey key = api.getKeyPairApi().create(name, template.getOptions().getPublicKey());
         logger.debug(">> keypair created! %s", key);
         options.addSshKeyId(key.getId());
      }

      // DigitalOcean specific options
      if (!templateOptions.getSshKeyIds().isEmpty()) {
         options.addSshKeyIds(templateOptions.getSshKeyIds());
View Full Code Here

Examples of org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.security.SSHKey

            }
            rs = pstmt.executeQuery();

            List<SSHKey> keys = new ArrayList<SSHKey>(4);
            while (rs.next()) {
                SSHKey key = new SSHKey(
                        rs.getString("owner"),
                        rs.getString("keyname"),
                        rs.getString("pubkey"),
                        rs.getString("fingerprint"));
                keys.add(key);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.