ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject incubator-ranger git commit: RANGER-339: Fix for potential NPE, remove dead code
Date Thu, 26 Mar 2015 23:54:04 GMT
Repository: incubator-ranger
Updated Branches:
  refs/heads/master 87446272e -> b1bfbc572


RANGER-339: Fix for potential NPE, remove dead code


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

Branch: refs/heads/master
Commit: b1bfbc572cd2a2974403abb7c023b5390c21f55d
Parents: 8744627
Author: Abhay Kulkarni <akulkarni@hortonworks.com>
Authored: Thu Mar 26 16:52:54 2015 -0700
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Thu Mar 26 16:52:54 2015 -0700

----------------------------------------------------------------------
 .../java/org/apache/ranger/biz/AssetMgr.java    | 131 +++++++++----------
 .../java/org/apache/ranger/biz/UserMgr.java     |   7 +-
 .../org/apache/ranger/patch/BaseLoader.java     |   2 +-
 .../ranger/service/XAccessAuditService.java     |  25 ++--
 .../apache/ranger/service/XAssetService.java    |  56 ++++----
 .../apache/ranger/service/XAuditMapService.java |   2 +-
 .../apache/ranger/service/XGroupService.java    |   2 +-
 .../apache/ranger/service/XPermMapService.java  |   2 +-
 .../apache/ranger/service/XResourceService.java |   8 +-
 .../apache/ranger/service/XTrxLogService.java   |  34 ++---
 .../org/apache/ranger/service/XUserService.java |   6 +-
 .../process/PolicyMgrUserGroupBuilder.java      |  30 +++--
 .../config/UserGroupSyncConfig.java             |   6 +-
 .../poc/RangerClientUserGroupMapping.java       |  42 +++---
 .../unix/jaas/ConsolePromptCallbackHandler.java |  14 +-
 15 files changed, 190 insertions(+), 177 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/b1bfbc57/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java b/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java
index 9d11256..4750081 100644
--- a/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java
+++ b/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java
@@ -68,22 +68,7 @@ import org.apache.ranger.service.XTrxLogService;
 import org.apache.ranger.service.XUserService;
 import org.apache.ranger.solr.SolrAccessAuditsService;
 import org.apache.ranger.util.RestUtil;
-import org.apache.ranger.view.VXAccessAuditList;
-import org.apache.ranger.view.VXAsset;
-import org.apache.ranger.view.VXAuditMap;
-import org.apache.ranger.view.VXAuditMapList;
-import org.apache.ranger.view.VXLong;
-import org.apache.ranger.view.VXPermMap;
-import org.apache.ranger.view.VXPermMapList;
-import org.apache.ranger.view.VXPolicy;
-import org.apache.ranger.view.VXPolicyExportAuditList;
-import org.apache.ranger.view.VXResource;
-import org.apache.ranger.view.VXResourceList;
-import org.apache.ranger.view.VXResponse;
-import org.apache.ranger.view.VXStringList;
-import org.apache.ranger.view.VXTrxLog;
-import org.apache.ranger.view.VXTrxLogList;
-import org.apache.ranger.view.VXUser;
+import org.apache.ranger.view.*;
 import org.codehaus.jackson.JsonGenerationException;
 import org.codehaus.jackson.map.JsonMappingException;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -1756,39 +1741,42 @@ public class AssetMgr extends AssetMgrBase {
 
 	public VXAccessAuditList getAccessLogs(SearchCriteria searchCriteria) {
 
-		if (searchCriteria != null && searchCriteria.getParamList() != null
-				&& searchCriteria.getParamList().size() > 0) {
-			int clientTimeOffsetInMinute = RestUtil.getClientTimeOffset();
-			java.util.Date temp = null;
-			DateUtil dateUtil = new DateUtil();
-			if (searchCriteria.getParamList().containsKey("startDate")) {
-				temp = (java.util.Date) searchCriteria.getParamList().get(
-						"startDate");
-				temp = dateUtil.getDateFromGivenDate(temp, 0, 0, 0, 0);
-				temp = dateUtil.addTimeOffset(temp, clientTimeOffsetInMinute);
-				searchCriteria.getParamList().put("startDate", temp);
-			}
-			if (searchCriteria.getParamList().containsKey("endDate")) {
-				temp = (java.util.Date) searchCriteria.getParamList().get(
-						"endDate");
-				temp = dateUtil.getDateFromGivenDate(temp, 0, 23, 59, 59);
-				temp = dateUtil.addTimeOffset(temp, clientTimeOffsetInMinute);
-				searchCriteria.getParamList().put("endDate", temp);
-			}
+        if (searchCriteria == null) {
+            searchCriteria = new SearchCriteria();
+        }
+        if (searchCriteria.getParamList() != null
+                && searchCriteria.getParamList().size() > 0) {
+            int clientTimeOffsetInMinute = RestUtil.getClientTimeOffset();
+            java.util.Date temp = null;
+            DateUtil dateUtil = new DateUtil();
+            if (searchCriteria.getParamList().containsKey("startDate")) {
+                temp = (java.util.Date) searchCriteria.getParamList().get(
+                        "startDate");
+                temp = dateUtil.getDateFromGivenDate(temp, 0, 0, 0, 0);
+                temp = dateUtil.addTimeOffset(temp, clientTimeOffsetInMinute);
+                searchCriteria.getParamList().put("startDate", temp);
+            }
+            if (searchCriteria.getParamList().containsKey("endDate")) {
+                temp = (java.util.Date) searchCriteria.getParamList().get(
+                        "endDate");
+                temp = dateUtil.getDateFromGivenDate(temp, 0, 23, 59, 59);
+                temp = dateUtil.addTimeOffset(temp, clientTimeOffsetInMinute);
+                searchCriteria.getParamList().put("endDate", temp);
+            }
+
+        }
+        if (searchCriteria.getSortType() == null) {
+            searchCriteria.setSortType("desc");
+        } else if (!searchCriteria.getSortType().equalsIgnoreCase("asc") && !searchCriteria.getSortType().equalsIgnoreCase("desc"))
{
+            searchCriteria.setSortType("desc");
+        }
+        if (xaBizUtil.getAuditDBType().equalsIgnoreCase(RangerBizUtil.AUDIT_STORE_SOLR))
{
+            return solrAccessAuditsService.searchXAccessAudits(searchCriteria);
+        } else {
+            return xAccessAuditService.searchXAccessAudits(searchCriteria);
+        }
+    }
 
-		}
-		if(searchCriteria.getSortType()==null){
-			searchCriteria.setSortType("desc");
-		}else if(!searchCriteria.getSortType().equalsIgnoreCase("asc")&& !searchCriteria.getSortType().equalsIgnoreCase("desc")){
-			searchCriteria.setSortType("desc");
-		}
-		if (xaBizUtil.getAuditDBType().equalsIgnoreCase(RangerBizUtil.AUDIT_STORE_SOLR)) {
-			return solrAccessAuditsService.searchXAccessAudits(searchCriteria);
-		} else {
-			return xAccessAuditService.searchXAccessAudits(searchCriteria);
-		}
-		//return xAccessAuditService.searchXAccessAudits(searchCriteria);
-	}
 
 	public VXTrxLogList getTransactionReport(String transactionId) {
 		List<XXTrxLog> xTrxLogList = rangerDaoManager.getXXTrxLog()
@@ -1854,30 +1842,29 @@ public class AssetMgr extends AssetMgrBase {
 	@Override
 	public VXPolicyExportAuditList searchXPolicyExportAudits(
 			SearchCriteria searchCriteria) {
-		if (searchCriteria != null && searchCriteria.getParamList() != null
-				&& searchCriteria.getParamList().size() > 0) {
-
-			int clientTimeOffsetInMinute = RestUtil.getClientTimeOffset();
-			java.util.Date temp = null;
-			DateUtil dateUtil = new DateUtil();
-			if (searchCriteria.getParamList().containsKey("startDate")) {
-				temp = (java.util.Date) searchCriteria.getParamList().get(
-						"startDate");
-				temp = dateUtil.getDateFromGivenDate(temp, 0, 0, 0, 0);
-				temp = dateUtil.addTimeOffset(temp, clientTimeOffsetInMinute);
-				searchCriteria.getParamList().put("startDate", temp);
-			}
-			if (searchCriteria.getParamList().containsKey("endDate")) {
-				temp = (java.util.Date) searchCriteria.getParamList().get(
-						"endDate");
-				temp = dateUtil.getDateFromGivenDate(temp, 0, 23, 59, 59);
-				temp = dateUtil.addTimeOffset(temp, clientTimeOffsetInMinute);
-				searchCriteria.getParamList().put("endDate", temp);
-			}
-		}
-	
-		return xPolicyExportAuditService.searchXPolicyExportAudits(searchCriteria);
-	}
+        if (searchCriteria != null && searchCriteria.getParamList() != null
+                && searchCriteria.getParamList().size() > 0) {
+
+            int clientTimeOffsetInMinute = RestUtil.getClientTimeOffset();
+            java.util.Date temp = null;
+            DateUtil dateUtil = new DateUtil();
+            if (searchCriteria.getParamList().containsKey("startDate")) {
+                temp = (java.util.Date) searchCriteria.getParamList().get(
+                        "startDate");
+                temp = dateUtil.getDateFromGivenDate(temp, 0, 0, 0, 0);
+                temp = dateUtil.addTimeOffset(temp, clientTimeOffsetInMinute);
+                searchCriteria.getParamList().put("startDate", temp);
+            }
+            if (searchCriteria.getParamList().containsKey("endDate")) {
+                temp = (java.util.Date) searchCriteria.getParamList().get(
+                        "endDate");
+                temp = dateUtil.getDateFromGivenDate(temp, 0, 23, 59, 59);
+                temp = dateUtil.addTimeOffset(temp, clientTimeOffsetInMinute);
+                searchCriteria.getParamList().put("endDate", temp);
+            }
+        }
+        return xPolicyExportAuditService.searchXPolicyExportAudits(searchCriteria);
+    }
 	
 	public VXAsset getXAsset(Long id){
 		UserSessionBase currentUserSession = ContextUtil

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/b1bfbc57/security-admin/src/main/java/org/apache/ranger/biz/UserMgr.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/biz/UserMgr.java b/security-admin/src/main/java/org/apache/ranger/biz/UserMgr.java
index 78c6c00..420b37d 100644
--- a/security-admin/src/main/java/org/apache/ranger/biz/UserMgr.java
+++ b/security-admin/src/main/java/org/apache/ranger/biz/UserMgr.java
@@ -1081,8 +1081,11 @@ public class UserMgr {
 								MessageEnums.OPER_NOT_ALLOWED_FOR_STATE);*/
 			}
 		}
-
-		return mapXXPortalUserToVXPortalUserForDefaultAccount(xXPortalUser);
+        if (xXPortalUser != null) {
+            return mapXXPortalUserToVXPortalUserForDefaultAccount(xXPortalUser);
+        }else {
+            return null;
+        }
 	}
 
 	private VXPortalUser mapXXPortalUserToVXPortalUserForDefaultAccount(XXPortalUser user) {

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/b1bfbc57/security-admin/src/main/java/org/apache/ranger/patch/BaseLoader.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/patch/BaseLoader.java b/security-admin/src/main/java/org/apache/ranger/patch/BaseLoader.java
index 61b46af..014dedc 100644
--- a/security-admin/src/main/java/org/apache/ranger/patch/BaseLoader.java
+++ b/security-admin/src/main/java/org/apache/ranger/patch/BaseLoader.java
@@ -146,7 +146,7 @@ public abstract class BaseLoader {
 	long currTime =  DateUtil.getUTCDate().getTime();
 	String retStr = formatTimeTaken(currTime - startTime);
 	if (currTime - startTime > 0 && countSoFar > 0) {
-	    double rateSoFar = countSoFar * 1000 / (currTime - startTime);
+	    double rateSoFar = (double)(countSoFar * 1000) / (currTime - startTime);
 	    retStr = retStr + " " + ". Rate so far for " + countSoFar + " is "
 		    + twoDForm.format(rateSoFar);
 

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/b1bfbc57/security-admin/src/main/java/org/apache/ranger/service/XAccessAuditService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/XAccessAuditService.java
b/security-admin/src/main/java/org/apache/ranger/service/XAccessAuditService.java
index ef9bc46..a8999a9 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/XAccessAuditService.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/XAccessAuditService.java
@@ -147,21 +147,22 @@ public class XAccessAuditService extends XAccessAuditServiceBase<XXAccessAudit,
 	 * @return
 	 */
 	public VXAccessAuditList searchXAccessAudits(SearchCriteria searchCriteria) {
-		VXAccessAuditList returnList = new VXAccessAuditList();
-		List<VXAccessAudit> xAccessAuditList = new ArrayList<VXAccessAudit>();
+        VXAccessAuditList returnList = new VXAccessAuditList();
+        List<VXAccessAudit> xAccessAuditList = new ArrayList<VXAccessAudit>();
 
-		List<XXAccessAudit> resultList = (List<XXAccessAudit>)searchResources(searchCriteria,
-				searchFields, sortFields, returnList);
+        List<XXAccessAudit> resultList = (List<XXAccessAudit>) searchResources(searchCriteria,
+                searchFields, sortFields, returnList);
 
-		// Iterate over the result list and create the return list
-		for (XXAccessAudit gjXAccessAudit : resultList) {
-			VXAccessAudit vXAccessAudit = populateViewBean(gjXAccessAudit);
-			xAccessAuditList.add(vXAccessAudit);
-		}
+        // Iterate over the result list and create the return list
+        for (XXAccessAudit gjXAccessAudit : resultList) {
+            VXAccessAudit vXAccessAudit = populateViewBean(gjXAccessAudit);
+            xAccessAuditList.add(vXAccessAudit);
+        }
 
-		returnList.setVXAccessAudits(xAccessAuditList);
-		return returnList;
-	}
+
+        returnList.setVXAccessAudits(xAccessAuditList);
+        return returnList;
+    }
 	
 	public VXAccessAudit populateViewBean(XXAccessAudit gjXAccessAudit) {
 		VXAccessAudit vXAccessAudit = new VXAccessAudit();

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/b1bfbc57/security-admin/src/main/java/org/apache/ranger/service/XAssetService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/XAssetService.java b/security-admin/src/main/java/org/apache/ranger/service/XAssetService.java
index 6c99705..1d6f42c 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/XAssetService.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/XAssetService.java
@@ -117,33 +117,35 @@ public class XAssetService extends XAssetServiceBase<XXAsset, VXAsset>
{
 	@Override
 	protected XXAsset mapViewToEntityBean(VXAsset vObj, XXAsset mObj,
 			int OPERATION_CONTEXT) {
-		String oldConfig = (mObj != null) ? mObj.getConfig() : null;
-		super.mapViewToEntityBean(vObj, mObj, OPERATION_CONTEXT);
-		String config = vObj.getConfig();
-		if (config != null && !config.isEmpty()) {
-			Map<String, String> configMap = jsonUtil.jsonToMap(config);
-			Entry<String, String> passwordEntry = getPasswordEntry(configMap);
-			if (passwordEntry != null) {
-				// If "*****" then get password from db and update
-				String password = passwordEntry.getValue();
-				if (password != null) {
-					if (password.equals(hiddenPasswordString)) {
-						if (oldConfig != null && !oldConfig.isEmpty()) {
-							Map<String, String> oldConfigMap = jsonUtil
-									.jsonToMap(oldConfig);
-							Entry<String, String> oldPasswordEntry 
-									= getPasswordEntry(oldConfigMap);
-							if (oldPasswordEntry != null) {
-								configMap.put(oldPasswordEntry.getKey(),
-										oldPasswordEntry.getValue());
-							}
-						}
-					}
-					config = jsonUtil.readMapToString(configMap);
-				}
-			}
-		}
-		mObj.setConfig(config);
+        if (vObj != null && mObj != null) {
+            String oldConfig = (mObj != null) ? mObj.getConfig() : null;
+            super.mapViewToEntityBean(vObj, mObj, OPERATION_CONTEXT);
+            String config = vObj.getConfig();
+            if (config != null && !config.isEmpty()) {
+                Map<String, String> configMap = jsonUtil.jsonToMap(config);
+                Entry<String, String> passwordEntry = getPasswordEntry(configMap);
+                if (passwordEntry != null) {
+                    // If "*****" then get password from db and update
+                    String password = passwordEntry.getValue();
+                    if (password != null) {
+                        if (password.equals(hiddenPasswordString)) {
+                            if (oldConfig != null && !oldConfig.isEmpty()) {
+                                Map<String, String> oldConfigMap = jsonUtil
+                                        .jsonToMap(oldConfig);
+                                Entry<String, String> oldPasswordEntry
+                                        = getPasswordEntry(oldConfigMap);
+                                if (oldPasswordEntry != null) {
+                                    configMap.put(oldPasswordEntry.getKey(),
+                                            oldPasswordEntry.getValue());
+                                }
+                            }
+                        }
+                        config = jsonUtil.readMapToString(configMap);
+                    }
+                }
+            }
+            mObj.setConfig(config);
+        }
 		return mObj;
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/b1bfbc57/security-admin/src/main/java/org/apache/ranger/service/XAuditMapService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/XAuditMapService.java
b/security-admin/src/main/java/org/apache/ranger/service/XAuditMapService.java
index a669280..c00ca74 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/XAuditMapService.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/XAuditMapService.java
@@ -78,7 +78,7 @@ public class XAuditMapService extends
 	}
 
 	public List<XXTrxLog> getTransactionLog(VXAuditMap vObj, VXAuditMap mObj, String action){
-		if(vObj == null && (action == null || !action.equalsIgnoreCase("update"))){
+		if(vObj == null || action == null || (action.equalsIgnoreCase("update") && mObj
== null)){
 			return null;
 		}
 		

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/b1bfbc57/security-admin/src/main/java/org/apache/ranger/service/XGroupService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/XGroupService.java b/security-admin/src/main/java/org/apache/ranger/service/XGroupService.java
index 580c31c..d31e178 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/XGroupService.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/XGroupService.java
@@ -154,7 +154,7 @@ public class XGroupService extends XGroupServiceBase<XXGroup, VXGroup>
{
 	}
 
 	public List<XXTrxLog> getTransactionLog(VXGroup vObj, XXGroup mObj, String action){
-		if(vObj == null && (action == null || !action.equalsIgnoreCase("update"))){
+		if(vObj == null || action == null || (action.equalsIgnoreCase("update") && mObj
== null)){
 			return null;
 		}
 		

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/b1bfbc57/security-admin/src/main/java/org/apache/ranger/service/XPermMapService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/XPermMapService.java b/security-admin/src/main/java/org/apache/ranger/service/XPermMapService.java
index 9b8247c..34109ae 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/XPermMapService.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/XPermMapService.java
@@ -150,7 +150,7 @@ public class XPermMapService extends XPermMapServiceBase<XXPermMap,
VXPermMap> {
 	}
 	
 	public List<XXTrxLog> getTransactionLog(VXPermMap vObj, VXPermMap mObj, String action){
-		if(vObj == null && (action == null || !action.equalsIgnoreCase("update"))){
+		if(vObj == null || action == null || (action.equalsIgnoreCase("update") && mObj
== null)){
 			return null;
 		}
 		

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/b1bfbc57/security-admin/src/main/java/org/apache/ranger/service/XResourceService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/XResourceService.java
b/security-admin/src/main/java/org/apache/ranger/service/XResourceService.java
index a7e2f12..1faec21 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/XResourceService.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/XResourceService.java
@@ -424,9 +424,9 @@ public class XResourceService extends
 
 	@Override
 	protected XXResource mapViewToEntityBean(VXResource vObj, XXResource mObj, int OPERATION_CONTEXT)
{
-		super.mapViewToEntityBean(vObj, mObj, OPERATION_CONTEXT);
-		mObj.setUdfs(vObj.getUdfs());
-		if(vObj!=null && mObj!=null){
+        if(vObj!=null && mObj!=null){
+		    super.mapViewToEntityBean(vObj, mObj, OPERATION_CONTEXT);
+		    mObj.setUdfs(vObj.getUdfs());
 			XXPortalUser xXPortalUser= null;
 			if(mObj.getAddedByUserId()==null || mObj.getAddedByUserId()==0){
 				if(!stringUtil.isEmpty(vObj.getOwner())){
@@ -951,7 +951,7 @@ public class XResourceService extends
 	}
 	
 	public List<XXTrxLog> getTransactionLog(VXResource vObj, XXResource mObj, String action){
-		if(vObj == null && (action == null || !action.equalsIgnoreCase("update"))){
+		if(vObj == null || action == null || (action.equalsIgnoreCase("update") && mObj
== null)) {
 			return null;
 		}
 

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/b1bfbc57/security-admin/src/main/java/org/apache/ranger/service/XTrxLogService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/XTrxLogService.java b/security-admin/src/main/java/org/apache/ranger/service/XTrxLogService.java
index 7edce5b..3c3ac64 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/XTrxLogService.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/XTrxLogService.java
@@ -438,22 +438,22 @@ public class XTrxLogService extends XTrxLogServiceBase<XXTrxLog,
VXTrxLog> {
 
 	@Override
 	protected VXTrxLog mapEntityToViewBean(VXTrxLog vObj, XXTrxLog mObj) {
-		super.mapEntityToViewBean(vObj, mObj);
-		if(mObj!=null && vObj!=null){
-			XXPortalUser xXPortalUser=null;
-			if(stringUtil.isEmpty(vObj.getOwner())){
-				xXPortalUser= rangerDaoManager.getXXPortalUser().getById(mObj.getAddedByUserId());	
-				if(xXPortalUser!=null){
-					vObj.setOwner(xXPortalUser.getLoginId());
-				}
-			}
-			if(stringUtil.isEmpty(vObj.getUpdatedBy())){
-				xXPortalUser= rangerDaoManager.getXXPortalUser().getById(mObj.getUpdatedByUserId());
	
-				if(xXPortalUser!=null){
-					vObj.setUpdatedBy(xXPortalUser.getLoginId());
-				}
-			}
-		}
-		return vObj;
+        if(mObj!=null && vObj!=null){
+            super.mapEntityToViewBean(vObj, mObj);
+            XXPortalUser xXPortalUser=null;
+            if(stringUtil.isEmpty(vObj.getOwner())){
+                xXPortalUser= rangerDaoManager.getXXPortalUser().getById(mObj.getAddedByUserId());
+                if(xXPortalUser!=null){
+                    vObj.setOwner(xXPortalUser.getLoginId());
+                }
+            }
+            if(stringUtil.isEmpty(vObj.getUpdatedBy())){
+                xXPortalUser= rangerDaoManager.getXXPortalUser().getById(mObj.getUpdatedByUserId());
+                if(xXPortalUser!=null){
+                    vObj.setUpdatedBy(xXPortalUser.getLoginId());
+                }
+            }
+        }
+        return vObj;
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/b1bfbc57/security-admin/src/main/java/org/apache/ranger/service/XUserService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/XUserService.java b/security-admin/src/main/java/org/apache/ranger/service/XUserService.java
index d847ca0..c70fbb8 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/XUserService.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/XUserService.java
@@ -261,8 +261,10 @@ public class XUserService extends XUserServiceBase<XXUser, VXUser>
{
 
 	public List<XXTrxLog> getTransactionLog(VXUser vObj, VXPortalUser mObj,
 			String action) {
-		if (vObj == null || action == null || (action.equalsIgnoreCase("update") && mObj
== null))
-	    		return null;
+
+		if (vObj == null || action == null || (action.equalsIgnoreCase("update") && mObj
== null)) {
+			return null;
+		}
 
 		List<XXTrxLog> trxLogList = new ArrayList<XXTrxLog>();
 		try {

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/b1bfbc57/ugsync/src/main/java/org/apache/ranger/ldapusersync/process/PolicyMgrUserGroupBuilder.java
----------------------------------------------------------------------
diff --git a/ugsync/src/main/java/org/apache/ranger/ldapusersync/process/PolicyMgrUserGroupBuilder.java
b/ugsync/src/main/java/org/apache/ranger/ldapusersync/process/PolicyMgrUserGroupBuilder.java
index 44932ad..7cd06cc 100644
--- a/ugsync/src/main/java/org/apache/ranger/ldapusersync/process/PolicyMgrUserGroupBuilder.java
+++ b/ugsync/src/main/java/org/apache/ranger/ldapusersync/process/PolicyMgrUserGroupBuilder.java
@@ -126,7 +126,7 @@ public class PolicyMgrUserGroupBuilder implements UserGroupSink {
 	}
 
 	
-	public void init() throws Throwable {
+	public synchronized void init() throws Throwable {
 		recordsToPullPerCall = config.getMaxRecordsPerAPICall() ;
 		policyMgrBaseUrl = config.getPolicyManagerBaseURL() ;
 		isMockRun = config.isMockRunEnabled() ;
@@ -164,24 +164,28 @@ public class PolicyMgrUserGroupBuilder implements UserGroupSink {
 	
 	
 	private void rebuildUserGroupMap() {
-		
-		for(XUserInfo user : xuserList) {
-			addUserToList(user);
+
+        List<XUserInfo> newUsers = new ArrayList<XUserInfo>();
+        for(XUserInfo user : xuserList) {
+			addUserToList(user, newUsers);
 		}
-		
+        xuserList.addAll(newUsers);
+
+        List<XGroupInfo> newGroups = new ArrayList<XGroupInfo>();
 		for(XGroupInfo group : xgroupList) {
-			addGroupToList(group);
+			addGroupToList(group, newGroups);
 		}
-		
+        xgroupList.addAll(newGroups);
+
 		for(XUserGroupInfo ug : xusergroupList) {
 			addUserGroupToList(ug);
 		}
 	}
 	
 	
-	private void addUserToList(XUserInfo aUserInfo) {
+	private void addUserToList(XUserInfo aUserInfo, List<XUserInfo> newUsers) {
 		if (! xuserList.contains(aUserInfo)) {
-			xuserList.add(aUserInfo) ;
+            newUsers.add(aUserInfo);
 		}
 		
 		String userId = aUserInfo.getId() ;
@@ -198,10 +202,10 @@ public class PolicyMgrUserGroupBuilder implements UserGroupSink {
 	}
 	
 
-	private void addGroupToList(XGroupInfo aGroupInfo) {
+	private void addGroupToList(XGroupInfo aGroupInfo, List<XGroupInfo> newGroups) {
 		
 		if (! xgroupList.contains(aGroupInfo) ) {
-			xgroupList.add(aGroupInfo) ;
+            newGroups.add(aGroupInfo);
 		}
 
 		if (aGroupInfo.getName() != null) {
@@ -437,7 +441,7 @@ public class PolicyMgrUserGroupBuilder implements UserGroupSink {
 	    ret = gson.fromJson(response, XUserInfo.class) ;
 
 	    if (ret != null) {
-	    	addUserToList(ret);
+	    	addUserToList(ret, xuserList);
 	    }
 		
 		return ret ;
@@ -467,7 +471,7 @@ public class PolicyMgrUserGroupBuilder implements UserGroupSink {
 	    ret = gson.fromJson(response, XGroupInfo.class) ;
 	    
 	    if (ret != null) {
-	    	addGroupToList(ret);
+	    	addGroupToList(ret, xgroupList);
 	    }
 		
 		return ret ;

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/b1bfbc57/ugsync/src/main/java/org/apache/ranger/unixusersync/config/UserGroupSyncConfig.java
----------------------------------------------------------------------
diff --git a/ugsync/src/main/java/org/apache/ranger/unixusersync/config/UserGroupSyncConfig.java
b/ugsync/src/main/java/org/apache/ranger/unixusersync/config/UserGroupSyncConfig.java
index 204a39c..6e98b34 100644
--- a/ugsync/src/main/java/org/apache/ranger/unixusersync/config/UserGroupSyncConfig.java
+++ b/ugsync/src/main/java/org/apache/ranger/unixusersync/config/UserGroupSyncConfig.java
@@ -280,7 +280,7 @@ public class UserGroupSyncConfig  {
 	public long getSleepTimeInMillisBetweenCycle() throws Throwable {
 		String val =  prop.getProperty(UGSYNC_SLEEP_TIME_IN_MILLIS_BETWEEN_CYCLE_PARAM) ;
 		if (val == null) {
-			if (LGSYNC_SOURCE_CLASS.equals(getUserGroupSource())) {
+			if (LGSYNC_SOURCE_CLASS.equals(getUserGroupSource().getClass().getName())) {
 				return UGSYNC_SLEEP_TIME_IN_MILLIS_BETWEEN_CYCLE_LDAP_DEFAULT_VALUE ;
 			} else {
 				return UGSYNC_SLEEP_TIME_IN_MILLIS_BETWEEN_CYCLE_UNIX_DEFAULT_VALUE ;
@@ -389,9 +389,9 @@ public class UserGroupSyncConfig  {
 		}
 		
 		val = val.trim().toLowerCase();
-		if (val.equals(0) || val.startsWith("base")) {
+		if (val.equals("0") || val.startsWith("base")) {
 			return 0; // object scope
-		} else if (val.equals(1) || val.startsWith("one")) {
+		} else if (val.equals("1") || val.startsWith("one")) {
 			return 1; // one level scope
 		} else {
 			return 2; // subtree scope

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/b1bfbc57/ugsync/src/main/java/org/apache/ranger/unixusersync/poc/RangerClientUserGroupMapping.java
----------------------------------------------------------------------
diff --git a/ugsync/src/main/java/org/apache/ranger/unixusersync/poc/RangerClientUserGroupMapping.java
b/ugsync/src/main/java/org/apache/ranger/unixusersync/poc/RangerClientUserGroupMapping.java
index 4ac922d..408e861 100644
--- a/ugsync/src/main/java/org/apache/ranger/unixusersync/poc/RangerClientUserGroupMapping.java
+++ b/ugsync/src/main/java/org/apache/ranger/unixusersync/poc/RangerClientUserGroupMapping.java
@@ -1,22 +1,22 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
  package org.apache.ranger.unixusersync.poc;
 
 import java.io.BufferedReader;
@@ -44,6 +44,10 @@ public class RangerClientUserGroupMapping {
 	    while ((strLine = br.readLine()) != null)  {
 	    	
 	    	ListRangerUser userList = ListRangerUser.parseUser(strLine);
+
+            if (userList == null) {
+                continue;
+            }
 		 
 	    	HashMap<String, String> map = new HashMap<String, String>();
          

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/b1bfbc57/unixauthclient/src/main/java/org/apache/ranger/authentication/unix/jaas/ConsolePromptCallbackHandler.java
----------------------------------------------------------------------
diff --git a/unixauthclient/src/main/java/org/apache/ranger/authentication/unix/jaas/ConsolePromptCallbackHandler.java
b/unixauthclient/src/main/java/org/apache/ranger/authentication/unix/jaas/ConsolePromptCallbackHandler.java
index 62a3d5a..f1400b2 100644
--- a/unixauthclient/src/main/java/org/apache/ranger/authentication/unix/jaas/ConsolePromptCallbackHandler.java
+++ b/unixauthclient/src/main/java/org/apache/ranger/authentication/unix/jaas/ConsolePromptCallbackHandler.java
@@ -42,13 +42,23 @@ public class ConsolePromptCallbackHandler implements CallbackHandler {
 		          NameCallback nc = (NameCallback)cb ;
 		          System.out.print(nc.getPrompt());
 		          System.out.flush();
-		          nc.setName(reader.readLine());
+                  String line = null;
+
+                  while (line == null) {
+                    line = reader.readLine();
+                  }
+		          nc.setName(line);
 			}
 			else if (cb instanceof PasswordCallback) {
 		          PasswordCallback pc = (PasswordCallback)cb;
 		          System.out.print(pc.getPrompt());
 		          System.out.flush();
-		          pc.setPassword(reader.readLine().toCharArray());				
+
+                  String line = null;
+                  while (line == null) {
+                    line = reader.readLine();
+                  }
+		          pc.setPassword(line.toCharArray());
 			}
 			else {
 				System.out.println("Unknown callbacl [" + cb.getClass().getName() + "]") ;


Mime
View raw message