Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D6F5F18CA3 for ; Thu, 3 Dec 2015 16:22:47 +0000 (UTC) Received: (qmail 93588 invoked by uid 500); 3 Dec 2015 16:22:47 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 93544 invoked by uid 500); 3 Dec 2015 16:22:47 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 93535 invoked by uid 99); 3 Dec 2015 16:22:47 -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, 03 Dec 2015 16:22:47 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 88AE4E6803; Thu, 3 Dec 2015 16:22:47 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: acosentino@apache.org To: commits@camel.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: camel git commit: CAMEL-9386: Camel-git: Support credentials in clone operation Date: Thu, 3 Dec 2015 16:22:47 +0000 (UTC) Repository: camel Updated Branches: refs/heads/camel-2.16.x d35647f90 -> 85bbbb2f0 CAMEL-9386: Camel-git: Support credentials in clone operation Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/85bbbb2f Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/85bbbb2f Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/85bbbb2f Branch: refs/heads/camel-2.16.x Commit: 85bbbb2f01cedcc6887cec15ff4324efad25ff0d Parents: d35647f Author: Andrea Cosentino Authored: Thu Dec 3 17:16:05 2015 +0100 Committer: Andrea Cosentino Committed: Thu Dec 3 17:22:08 2015 +0100 ---------------------------------------------------------------------- .../org/apache/camel/component/git/producer/GitProducer.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/85bbbb2f/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java ---------------------------------------------------------------------- diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java index 31d1bd4..3c225e8 100644 --- a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java +++ b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java @@ -154,7 +154,12 @@ public class GitProducer extends DefaultProducer { try { File localRepo = new File(endpoint.getLocalPath(), ""); if (!localRepo.exists()) { - result = git.cloneRepository().setURI(endpoint.getRemotePath()).setDirectory(new File(endpoint.getLocalPath(), "")).call(); + if (ObjectHelper.isNotEmpty(endpoint.getUsername()) && ObjectHelper.isNotEmpty(endpoint.getPassword())) { + UsernamePasswordCredentialsProvider credentials = new UsernamePasswordCredentialsProvider(endpoint.getUsername(), endpoint.getPassword()); + result = git.cloneRepository().setCredentialsProvider(credentials).setURI(endpoint.getRemotePath()).setDirectory(new File(endpoint.getLocalPath(), "")).call(); + } else { + result = git.cloneRepository().setURI(endpoint.getRemotePath()).setDirectory(new File(endpoint.getLocalPath(), "")).call(); + } } else { throw new IllegalArgumentException("The local repository directory already exists"); }