Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 07B6317780 for ; Thu, 11 Jun 2015 11:47:06 +0000 (UTC) Received: (qmail 28637 invoked by uid 500); 11 Jun 2015 11:47:06 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 28604 invoked by uid 500); 11 Jun 2015 11:47:05 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 28595 invoked by uid 99); 11 Jun 2015 11:47:05 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Jun 2015 11:47:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 7A2AA1A4A53 for ; Thu, 11 Jun 2015 11:47:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.771 X-Spam-Level: X-Spam-Status: No, score=0.771 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 3IHcpqfnOzyK for ; Thu, 11 Jun 2015 11:47:01 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id BED244BB86 for ; Thu, 11 Jun 2015 11:47:00 +0000 (UTC) Received: (qmail 26510 invoked by uid 99); 11 Jun 2015 11:47:00 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Jun 2015 11:47:00 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1EBF8E05DD; Thu, 11 Jun 2015 11:47:00 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.incubator.apache.org Date: Thu, 11 Jun 2015 11:47:04 -0000 Message-Id: In-Reply-To: <2f198cd384eb477f918d09c7408e0030@git.apache.org> References: <2f198cd384eb477f918d09c7408e0030@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [06/50] [abbrv] incubator-ignite git commit: merge from ignite-1000 merge from ignite-1000 Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/f8a87769 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/f8a87769 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/f8a87769 Branch: refs/heads/ignite-gg-10249 Commit: f8a877691181063199a5d476a036dfb428118ea5 Parents: 57957d9 Author: Denis Magda Authored: Tue Jun 9 09:02:00 2015 +0300 Committer: Denis Magda Committed: Tue Jun 9 09:02:00 2015 +0300 ---------------------------------------------------------------------- .../cloud/TcpDiscoveryCloudIpFinder.java | 25 +++++++++++++------- .../TcpDiscoveryCloudIpFinderSelfTest.java | 3 +-- 2 files changed, 18 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f8a87769/modules/cloud/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinder.java ---------------------------------------------------------------------- diff --git a/modules/cloud/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinder.java b/modules/cloud/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinder.java index 2637742..7555b16 100644 --- a/modules/cloud/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinder.java +++ b/modules/cloud/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinder.java @@ -30,6 +30,7 @@ import org.jclouds.*; import org.jclouds.compute.*; import org.jclouds.compute.domain.*; import org.jclouds.domain.*; +import org.jclouds.googlecloud.*; import org.jclouds.location.reference.*; import java.io.*; @@ -97,7 +98,7 @@ import java.util.concurrent.atomic.*; * <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.cloud.TcpDiscoveryCloudIpFinder"/> * <property name="provider" value="google-compute-engine"/> * <property name="identity" value="your_service_account_email"/> - * <property name="credentialPath" value="path_to_pem_file"/> + * <property name="credentialPath" value="path_to_json_key"/> * <property name="zones"> * <list> * <value>us-central1-a</value> @@ -253,8 +254,7 @@ public class TcpDiscoveryCloudIpFinder extends TcpDiscoveryIpFinderAdapter { /** * Sets the path to a credential that is used during authentication on the cloud. * - * This method should be used when an access key or private key is stored in a plain or PEM file without - * a passphrase. + * This method should be used when an access key or private key is stored in a file. * Content of the file, referred by @{code credentialPath}, is fully read and used as a access key or private key * during authentication. * @@ -322,7 +322,7 @@ public class TcpDiscoveryCloudIpFinder extends TcpDiscoveryIpFinderAdapter { throw new IgniteSpiException("Both credential and credentialPath are set. Use only one method."); if (credentialPath != null) - credential = getPrivateKeyFromFile(); + credential = getCredentialFromFile(); try { ContextBuilder ctxBuilder = ContextBuilder.newBuilder(provider); @@ -398,13 +398,22 @@ public class TcpDiscoveryCloudIpFinder extends TcpDiscoveryIpFinderAdapter { } /** - * Retrieves a private key from the secrets file. + * Reads credential info from {@link #credentialPath} and returns in a string format. * - * @return Private key + * @return Credential in {@code String} representation. + * @throws IgniteSpiException In case of error. */ - private String getPrivateKeyFromFile() throws IgniteSpiException { + private String getCredentialFromFile() throws IgniteSpiException { try { - return Files.toString(new File(credentialPath), Charsets.UTF_8); + String fileContents = Files.toString(new File(credentialPath), Charsets.UTF_8); + + if (provider.equals("google-compute-engine")) { + Supplier credentialSupplier = new GoogleCredentialsFromJson(fileContents); + + return credentialSupplier.get().credential; + } + + return fileContents; } catch (IOException e) { throw new IgniteSpiException("Failed to retrieve the private key from the file: " + credentialPath, e); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f8a87769/modules/cloud/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinderSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/cloud/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinderSelfTest.java b/modules/cloud/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinderSelfTest.java index aba0760..d1d945f 100644 --- a/modules/cloud/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinderSelfTest.java +++ b/modules/cloud/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinderSelfTest.java @@ -101,9 +101,8 @@ public class TcpDiscoveryCloudIpFinderSelfTest extends if (provider.equals("google-compute-engine")) ipFinder.setCredentialPath(IgniteCloudTestSuite.getSecretKey(provider)); - else { + else ipFinder.setCredential(IgniteCloudTestSuite.getSecretKey(provider)); - } Collection addresses = ipFinder.getRegisteredAddresses();