ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [21/25] ambari git commit: AMBARI-19010. Log Search external login credential let every user in (oleewere)
Date Tue, 29 Nov 2016 22:01:31 GMT
AMBARI-19010. Log Search external login credential let every user in (oleewere)

Change-Id: Iab889180bfb4916fd06240588b6cdd80493889a1


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f31f3f64
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f31f3f64
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f31f3f64

Branch: refs/heads/branch-feature-AMBARI-18456
Commit: f31f3f646610a2e480279989d6790437e5362cb8
Parents: a952843
Author: oleewere <oleewere@gmail.com>
Authored: Tue Nov 29 13:16:51 2016 +0100
Committer: oleewere <oleewere@gmail.com>
Committed: Tue Nov 29 18:03:42 2016 +0100

----------------------------------------------------------------------
 .../ambari/logsearch/common/ExternalServerClient.java   | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f31f3f64/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java
index 1207373..230ca8c 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java
@@ -23,9 +23,11 @@ import javax.inject.Named;
 import javax.ws.rs.client.Invocation;
 import javax.ws.rs.client.WebTarget;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 
 import org.apache.ambari.logsearch.conf.AuthPropsConfig;
 import org.apache.ambari.logsearch.util.SSLUtil;
+import org.apache.commons.httpclient.auth.InvalidCredentialsException;
 import org.apache.log4j.Logger;
 import org.glassfish.jersey.client.JerseyClient;
 import org.glassfish.jersey.client.JerseyClientBuilder;
@@ -64,9 +66,15 @@ public class ExternalServerClient {
     WebTarget target = client.target(url);
     LOG.debug("URL: " + url);
     
-    Invocation.Builder invocationBuilder =  target.request(MediaType.APPLICATION_JSON_TYPE);
+    Invocation.Builder invocationBuilder =  target.request();
     try {
-      return invocationBuilder.get().readEntity(klass);
+      Response response = invocationBuilder.get();
+      if (response.getStatus() != Response.Status.OK.getStatusCode()
+        && response.getStatus() != Response.Status.FOUND.getStatusCode()) {
+        throw new InvalidCredentialsException(String.format("External auth failed with status
code: %d, response: %s",
+          response.getStatus(), response.readEntity(String.class)));
+      }
+      return response.readEntity(klass);
     } catch (Exception e) {
       throw new Exception(e.getCause());
     } finally {


Mime
View raw message