camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [3/3] camel git commit: CAMEL-9386: Camel-git: Support credentials in clone operation
Date Thu, 03 Dec 2015 16:21:30 GMT
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/8aa54686
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8aa54686
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8aa54686

Branch: refs/heads/master
Commit: 8aa54686335ee08e96497d87bc327ed28c0e79d3
Parents: 78aa386
Author: Andrea Cosentino <ancosen@gmail.com>
Authored: Thu Dec 3 17:16:05 2015 +0100
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Thu Dec 3 17:16:55 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/8aa54686/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");
             }


Mime
View raw message