[ambari] branch branch-2.7 updated (afbbb73 -> 3d379f0)

2019-11-28 Thread aonishuk
This is an automated email from the ASF dual-hosted git repository.

aonishuk pushed a change to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/ambari.git.


from afbbb73  AMBARI-25433. Ambari should add login and password to urls 
populated from VDF (aonishuk)
 add 3d379f0  AMBARI-25433. Adding VDF fails with paywalled repos/urls 
(aonishuk)

No new revisions were added by this update.

Summary of changes:
 .../server/controller/internal/VersionDefinitionResourceProvider.java | 4 
 .../main/java/org/apache/ambari/server/state/stack/RepositoryXml.java | 4 +++-
 2 files changed, 3 insertions(+), 5 deletions(-)



[ambari] 02/02: AMBARI-25433. Ambari should add login and password to urls populated from VDF (aonishuk)

2019-11-28 Thread aonishuk
This is an automated email from the ASF dual-hosted git repository.

aonishuk pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/ambari.git

commit afbbb73db5a4f2adad2dd4e0e777f7c5109b2099
Author: Andrew Onishuk 
AuthorDate: Thu Nov 28 14:30:40 2019 +0200

AMBARI-25433. Ambari should add login and password to urls populated from 
VDF (aonishuk)
---
 .../internal/VersionDefinitionResourceProvider.java  | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
index 97cf917..0779f26 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
@@ -21,6 +21,7 @@ import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
 import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -581,6 +582,7 @@ public class VersionDefinitionResourceProvider extends 
AbstractAuthorizedResourc
   } else {
 URLStreamProvider provider = new URLStreamProvider(connectTimeout, 
readTimeout,
 ComponentSSLConfiguration.instance());
+provider.setSetupTruststoreForHttps(false);
 
 stream = provider.readFrom(definitionUrl);
   }
@@ -615,12 +617,14 @@ public class VersionDefinitionResourceProvider extends 
AbstractAuthorizedResourc
 
 entity.setStack(stackEntity);
 
-String credentials;
-try {
-  URL url = new URL(holder.url);
-  credentials = url.getUserInfo();
-} catch (MalformedURLException e) {
-  throw new AmbariException(String.format("Could not parse url %s", 
holder.url), e);
+String credentials = null;
+if (holder.url != null) {
+  try {
+URI uri = new URI(holder.url);
+credentials = uri.getUserInfo();
+  } catch (URISyntaxException e) {
+throw new AmbariException(String.format("Could not parse url %s", 
holder.url), e);
+  }
 }
 
 List repos = 
holder.xml.repositoryInfo.getRepositories(credentials);



[ambari] branch branch-2.7 updated (767a168 -> afbbb73)

2019-11-28 Thread aonishuk
This is an automated email from the ASF dual-hosted git repository.

aonishuk pushed a change to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/ambari.git.


from 767a168  Merge pull request #3140 from hiveww/AMBARI-25425-branch-2.7
 new 9a1c248  AMBARI-25433. Ambari should add login and password to urls 
populated from VDF (aonishuk)
 new afbbb73  AMBARI-25433. Ambari should add login and password to urls 
populated from VDF (aonishuk)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../VersionDefinitionResourceProvider.java | 18 +++-
 .../ambari/server/state/stack/RepositoryXml.java   | 25 --
 2 files changed, 40 insertions(+), 3 deletions(-)



[ambari] 01/02: AMBARI-25433. Ambari should add login and password to urls populated from VDF (aonishuk)

2019-11-28 Thread aonishuk
This is an automated email from the ASF dual-hosted git repository.

aonishuk pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/ambari.git

commit 9a1c24863dee62d769c0e3d80e8daa25be0fc17c
Author: Andrew Onishuk 
AuthorDate: Thu Nov 28 13:03:54 2019 +0200

AMBARI-25433. Ambari should add login and password to urls populated from 
VDF (aonishuk)
---
 .../VersionDefinitionResourceProvider.java | 14 +++-
 .../ambari/server/state/stack/RepositoryXml.java   | 25 --
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
index 9882147..97cf917 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
@@ -19,7 +19,9 @@ package org.apache.ambari.server.controller.internal;
 
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
 import java.net.URI;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -29,6 +31,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.ambari.annotations.Experimental;
 import org.apache.ambari.annotations.ExperimentalFeature;
@@ -611,7 +615,15 @@ public class VersionDefinitionResourceProvider extends 
AbstractAuthorizedResourc
 
 entity.setStack(stackEntity);
 
-List repos = holder.xml.repositoryInfo.getRepositories();
+String credentials;
+try {
+  URL url = new URL(holder.url);
+  credentials = url.getUserInfo();
+} catch (MalformedURLException e) {
+  throw new AmbariException(String.format("Could not parse url %s", 
holder.url), e);
+}
+
+List repos = 
holder.xml.repositoryInfo.getRepositories(credentials);
 
 // Add service repositories (these are not contained by the VDF but are 
there in the stack model)
 ListMultimap stackReposByOs =
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/RepositoryXml.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/RepositoryXml.java
index ccb25e8..c872deb 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/RepositoryXml.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/RepositoryXml.java
@@ -22,7 +22,8 @@ import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
@@ -31,6 +32,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
 
+import com.google.common.base.Strings;
 import org.apache.ambari.server.stack.Validable;
 import org.apache.ambari.server.state.RepositoryInfo;
 
@@ -40,6 +42,7 @@ import org.apache.ambari.server.state.RepositoryInfo;
 @XmlRootElement(name="reposinfo")
 @XmlAccessorType(XmlAccessType.FIELD)
 public class RepositoryXml implements Validable{
+  private static final Pattern HTTP_URL_PROTOCOL_PATTERN = 
Pattern.compile("((http(s)*:\\/\\/))");
 
   @XmlElement(name="latest")
   private String latestUri;
@@ -219,6 +222,16 @@ public class RepositoryXml implements Validable{
* @return the list of repositories consumable by the web service.
*/
   public List getRepositories() {
+return getRepositories(null);
+  }
+
+  /**
+   * @param credentials string with column separated username and password to 
be inserted in basurl.
+   *If set to null baseurl is not changed.
+   *
+   * @return the list of repositories consumable by the web service.
+   */
+  public List getRepositories(String credentials) {
 List repos = new ArrayList<>();
 
 for (RepositoryXml.Os o : getOses()) {
@@ -227,7 +240,15 @@ public class RepositoryXml implements Validable{
 for (RepositoryXml.Repo r : o.getRepos()) {
 
   RepositoryInfo ri = new RepositoryInfo();
-  ri.setBaseUrl(r.getBaseUrl());
+  String baseUrl = r.getBaseUrl();
+
+  // add credentials from VDF url to baseurl.
+  if (!Strings.isNullOrEmpty(credentials)) {
+Matcher matcher = HTTP_URL_PROTOCOL_PATTERN.matcher(baseUrl);
+baseUrl = matcher.replaceAll("$1" + credentials + "@");
+  }
+
+  ri.setBaseUrl(baseUrl);