You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by co...@apache.org on 2017/06/29 08:26:17 UTC

ranger git commit: RANGER-1671 - The admin service can't audit to Solr using Basic Authentication

Repository: ranger
Updated Branches:
  refs/heads/master fdb74d51f -> b7a1cc05c


RANGER-1671 - The admin service can't audit to Solr using Basic Authentication

Signed-off-by: Colm O hEigeartaigh <co...@apache.org>


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

Branch: refs/heads/master
Commit: b7a1cc05c9607e02ce91079ee0d62c5d547ba069
Parents: fdb74d5
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Tue Jun 27 13:17:44 2017 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Wed Jun 28 17:38:46 2017 +0100

----------------------------------------------------------------------
 security-admin/pom.xml                          |  4 +--
 .../java/org/apache/ranger/solr/SolrUtil.java   | 30 ++++++++++++--------
 2 files changed, 20 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/b7a1cc05/security-admin/pom.xml
----------------------------------------------------------------------
diff --git a/security-admin/pom.xml b/security-admin/pom.xml
index 486cd58..cc39be8 100644
--- a/security-admin/pom.xml
+++ b/security-admin/pom.xml
@@ -568,8 +568,8 @@
 					<configFile>enunciate.xml</configFile>
 					<enunciateArtifactId/>
 					<docsDir>docs/target/</docsDir>
-					<source>1.8</source>
-					<target>1.8</target>
+					<source>1.7</source>
+					<target>1.7</target>
 				</configuration>
 			</plugin>
         </plugins>

http://git-wip-us.apache.org/repos/asf/ranger/blob/b7a1cc05/security-admin/src/main/java/org/apache/ranger/solr/SolrUtil.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/solr/SolrUtil.java b/security-admin/src/main/java/org/apache/ranger/solr/SolrUtil.java
index 9cea529..3ba8a3e 100644
--- a/security-admin/src/main/java/org/apache/ranger/solr/SolrUtil.java
+++ b/security-admin/src/main/java/org/apache/ranger/solr/SolrUtil.java
@@ -38,6 +38,7 @@ import org.apache.solr.client.solrj.SolrClient;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrQuery.ORDER;
 import org.apache.solr.client.solrj.SolrRequest.METHOD;
+import org.apache.solr.client.solrj.request.QueryRequest;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.client.solrj.util.ClientUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -68,18 +69,23 @@ public class SolrUtil {
 		}
 	}
 
-        public QueryResponse runQuery(SolrClient solrClient, SolrQuery solrQuery) throws Throwable {
-		if (solrQuery != null) {
-                        QueryResponse response = null;
-			try {
-				response = solrClient.query(solrQuery, METHOD.POST);
-				return response;
-			} catch (Throwable e) {
-                                logger.error("Error from Solr server. ", e);
-                                throw e;
-			}
-		}
-		return null;
+	public QueryResponse runQuery(SolrClient solrClient, SolrQuery solrQuery) throws Throwable {
+	    if (solrQuery != null) {
+	        try {
+	            QueryRequest req = new QueryRequest(solrQuery, METHOD.POST);
+	            String username = PropertiesUtil.getProperty("ranger.solr.audit.user");
+	            String password = PropertiesUtil.getProperty("ranger.solr.audit.user.password");
+	            if (username != null && password != null) {
+	                req.setBasicAuthCredentials(username, password);
+	            }
+
+	            return req.process(solrClient);
+	        } catch (Throwable e) {
+	            logger.error("Error from Solr server. ", e);
+	            throw e;
+	        }
+	    }
+	    return null;
 	}
 
 	public QueryResponse searchResources(SearchCriteria searchCriteria,