Repository: ranger Updated Branches: refs/heads/master cdde1b6e8 -> 1d18e76da
http://git-wip-us.apache.org/repos/asf/ranger/blob/1d18e76d/security-admin/src/main/java/org/apache/ranger/service/AbstractBaseResourceService.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/service/AbstractBaseResourceService.java b/security-admin/src/main/java/org/apache/ranger/service/AbstractBaseResourceService.java index 9a4aa3b..3c2f263 100644 --- a/security-admin/src/main/java/org/apache/ranger/service/AbstractBaseResourceService.java +++ b/security-admin/src/main/java/org/apache/ranger/service/AbstractBaseResourceService.java @@ -499,18 +499,15 @@ public abstract class AbstractBaseResourceService<T extends XXDBBase, V extends if (tUser != null) { if (tUser.getPublicScreenName() != null && !tUser.getPublicScreenName().trim().isEmpty() - && !tUser.getPublicScreenName().trim() - .equalsIgnoreCase("null")) { + && !"null".equalsIgnoreCase(tUser.getPublicScreenName().trim())) { viewBean.setOwner(tUser.getPublicScreenName()); } else { if (tUser.getFirstName() != null && !tUser.getFirstName().trim().isEmpty() - && !tUser.getFirstName().trim() - .equalsIgnoreCase("null")) { + && !"null".equalsIgnoreCase(tUser.getFirstName().trim())) { if (tUser.getLastName() != null && !tUser.getLastName().trim().isEmpty() - && !tUser.getLastName().trim() - .equalsIgnoreCase("null")) { + && !"null".equalsIgnoreCase(tUser.getLastName().trim())) { viewBean.setOwner(tUser.getFirstName() + " " + tUser.getLastName()); } else { @@ -528,18 +525,15 @@ public abstract class AbstractBaseResourceService<T extends XXDBBase, V extends if (tUser != null) { if (tUser.getPublicScreenName() != null && !tUser.getPublicScreenName().trim().isEmpty() - && !tUser.getPublicScreenName().trim() - .equalsIgnoreCase("null")) { + && !"null".equalsIgnoreCase(tUser.getPublicScreenName().trim())) { viewBean.setUpdatedBy(tUser.getPublicScreenName()); } else { if (tUser.getFirstName() != null && !tUser.getFirstName().trim().isEmpty() - && !tUser.getFirstName().trim() - .equalsIgnoreCase("null")) { + && !"null".equalsIgnoreCase(tUser.getFirstName().trim())) { if (tUser.getLastName() != null && !tUser.getLastName().trim().isEmpty() - && !tUser.getLastName().trim() - .equalsIgnoreCase("null")) { + && !"null".equalsIgnoreCase(tUser.getLastName().trim())) { viewBean.setUpdatedBy(tUser.getFirstName() + " " + tUser.getLastName()); } else { @@ -860,7 +854,7 @@ public abstract class AbstractBaseResourceService<T extends XXDBBase, V extends // Add sort type String sortType = searchCriteria.getSortType(); - if (sortType != null && sortType.equalsIgnoreCase("desc")) { + if (sortType != null && "desc".equalsIgnoreCase(sortType)) { criteria.orderBy(criteriaBuilder.desc(from.get(sortByField))); } else { criteria.orderBy(criteriaBuilder.asc(from.get(sortByField))); http://git-wip-us.apache.org/repos/asf/ranger/blob/1d18e76d/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java b/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java index 00c08db..ede73bf 100644 --- a/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java +++ b/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java @@ -154,7 +154,7 @@ public class RangerPolicyService extends RangerPolicyServiceBase<XXPolicy, Range Field[] superClassFields = vObj.getClass().getSuperclass() .getDeclaredFields(); for (Field field : superClassFields) { - if (field.getName().equalsIgnoreCase("isEnabled")) { + if ("isEnabled".equalsIgnoreCase(field.getName())) { XXTrxLog xTrx = processFieldToCreateTrxLog(field, objectName, nameField, vObj, mObj, action); if (xTrx != null) { trxLogList.add(xTrx); @@ -189,23 +189,23 @@ public class RangerPolicyService extends RangerPolicyServiceBase<XXPolicy, Range boolean isEnum = vTrxLogAttr.isEnum(); if (isEnum) { - } else if (fieldName.equalsIgnoreCase(POLICY_RESOURCE_CLASS_FIELD_NAME)) { + } else if (POLICY_RESOURCE_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { value = processPolicyResourcesForTrxLog(field.get(vObj)); - } else if (fieldName.equalsIgnoreCase(POLICY_ITEM_CLASS_FIELD_NAME)) { + } else if (POLICY_ITEM_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { value = processPolicyItemsForTrxLog(field.get(vObj)); - } else if (fieldName.equalsIgnoreCase(DENYPOLICY_ITEM_CLASS_FIELD_NAME)) { + } else if (DENYPOLICY_ITEM_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { value = processPolicyItemsForTrxLog(field.get(vObj)); - } else if (fieldName.equalsIgnoreCase(POLICY_NAME_CLASS_FIELD_NAME)){ + } else if (POLICY_NAME_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)){ value = processPolicyNameForTrxLog(field.get(vObj)); - } else if (fieldName.equalsIgnoreCase(ALLOW_EXCEPTIONS_CLASS_FIELD_NAME)){ + } else if (ALLOW_EXCEPTIONS_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)){ value = processPolicyItemsForTrxLog(field.get(vObj)); - } else if (fieldName.equalsIgnoreCase(DENY_EXCEPTIONS_CLASS_FIELD_NAME)){ + } else if (DENY_EXCEPTIONS_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)){ value = processPolicyItemsForTrxLog(field.get(vObj)); - } else if (fieldName.equalsIgnoreCase(DATAMASK_POLICY_ITEM_CLASS_FIELD_NAME)){ + } else if (DATAMASK_POLICY_ITEM_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)){ value = processDataMaskPolicyItemsForTrxLog(field.get(vObj)); - } else if (fieldName.equalsIgnoreCase(ROWFILTER_POLICY_ITEM_CLASS_FIELD_NAME)){ + } else if (ROWFILTER_POLICY_ITEM_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)){ value = processRowFilterPolicyItemForTrxLog(field.get(vObj)); - } else if (fieldName.equalsIgnoreCase(IS_ENABLED_CLASS_FIELD_NAME)){ + } else if (IS_ENABLED_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)){ value = String.valueOf(processIsEnabledClassFieldNameForTrxLog(field.get(vObj))); } @@ -239,107 +239,107 @@ public class RangerPolicyService extends RangerPolicyServiceBase<XXPolicy, Range } } RangerPolicy oldPolicy = populateViewBean(mObj); - if (fieldName.equalsIgnoreCase(POLICY_RESOURCE_CLASS_FIELD_NAME)) { + if (POLICY_RESOURCE_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { if (oldPolicy != null) { oldValue = processPolicyResourcesForTrxLog(oldPolicy.getResources()); } - } else if (fieldName.equalsIgnoreCase(POLICY_ITEM_CLASS_FIELD_NAME)) { + } else if (POLICY_ITEM_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { if (oldPolicy != null) { oldValue = processPolicyItemsForTrxLog(oldPolicy.getPolicyItems()); } - } else if (fieldName.equalsIgnoreCase(DENYPOLICY_ITEM_CLASS_FIELD_NAME)) { + } else if (DENYPOLICY_ITEM_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { if (oldPolicy != null) { oldValue = processPolicyItemsForTrxLog(oldPolicy.getDenyPolicyItems()); } - } else if (fieldName.equalsIgnoreCase(POLICY_NAME_CLASS_FIELD_NAME)){ + } else if (POLICY_NAME_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)){ if (oldPolicy != null) { oldValue = processPolicyNameForTrxLog(oldPolicy.getName()); } - } else if (fieldName.equalsIgnoreCase(POLICY_DESCRIPTION_CLASS_FIELD_NAME)){ + } else if (POLICY_DESCRIPTION_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)){ if (oldPolicy != null) { oldValue = processPolicyNameForTrxLog(oldPolicy.getDescription()); } - } else if (fieldName.equalsIgnoreCase(ALLOW_EXCEPTIONS_CLASS_FIELD_NAME)) { + } else if (ALLOW_EXCEPTIONS_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { if (oldPolicy != null) { oldValue = processPolicyItemsForTrxLog(oldPolicy.getAllowExceptions()); } - } else if (fieldName.equalsIgnoreCase(DENY_EXCEPTIONS_CLASS_FIELD_NAME)) { + } else if (DENY_EXCEPTIONS_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { if (oldPolicy != null) { oldValue = processPolicyItemsForTrxLog(oldPolicy.getDenyExceptions()); } - } else if (fieldName.equalsIgnoreCase(DATAMASK_POLICY_ITEM_CLASS_FIELD_NAME)) { + } else if (DATAMASK_POLICY_ITEM_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { if (oldPolicy != null) { oldValue = processDataMaskPolicyItemsForTrxLog(oldPolicy.getDataMaskPolicyItems()); } - } else if (fieldName.equalsIgnoreCase(ROWFILTER_POLICY_ITEM_CLASS_FIELD_NAME)) { + } else if (ROWFILTER_POLICY_ITEM_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { if (oldPolicy != null) { oldValue = processRowFilterPolicyItemForTrxLog(oldPolicy.getRowFilterPolicyItems()); } - }else if (fieldName.equalsIgnoreCase(IS_ENABLED_CLASS_FIELD_NAME)) { + }else if (IS_ENABLED_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { if (oldPolicy != null) { oldValue = String.valueOf(processIsEnabledClassFieldNameForTrxLog(oldPolicy.getIsEnabled())); } } if (oldValue == null || oldValue.equalsIgnoreCase(value)) { return null; - } else if (fieldName.equalsIgnoreCase(POLICY_RESOURCE_CLASS_FIELD_NAME)) { + } else if (POLICY_RESOURCE_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { // Compare old and new resources if(compareTwoPolicyResources(value, oldValue)) { return null; } - } else if (fieldName.equalsIgnoreCase(POLICY_ITEM_CLASS_FIELD_NAME)) { + } else if (POLICY_ITEM_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { //Compare old and new policyItems if(compareTwoPolicyItemList(value, oldValue)) { return null; } - } else if (fieldName.equalsIgnoreCase(POLICY_NAME_CLASS_FIELD_NAME)) { + } else if (POLICY_NAME_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { //compare old and new policyName if(compareTwoPolicyName(value, oldValue)) { return null; } - } else if (fieldName.equalsIgnoreCase(DENYPOLICY_ITEM_CLASS_FIELD_NAME)) { + } else if (DENYPOLICY_ITEM_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { //compare old and new denyPolicyItem if(compareTwoPolicyItemList(value, oldValue)) { return null; } - } else if (fieldName.equalsIgnoreCase(ALLOW_EXCEPTIONS_CLASS_FIELD_NAME)) { + } else if (ALLOW_EXCEPTIONS_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { //compare old and new allowExceptions if(compareTwoPolicyItemList(value, oldValue)) { return null; } - } else if (fieldName.equalsIgnoreCase(DENY_EXCEPTIONS_CLASS_FIELD_NAME)) { + } else if (DENY_EXCEPTIONS_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { //compare old and new denyExceptions if(compareTwoPolicyItemList(value, oldValue)) { return null; } - } else if (fieldName.equalsIgnoreCase(POLICY_DESCRIPTION_CLASS_FIELD_NAME)) { + } else if (POLICY_DESCRIPTION_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { //compare old and new Description if(org.apache.commons.lang.StringUtils.equals(value, oldValue)) { return null; } - } else if (fieldName.equalsIgnoreCase(DATAMASK_POLICY_ITEM_CLASS_FIELD_NAME)) { + } else if (DATAMASK_POLICY_ITEM_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { //compare old and new dataMaskPolicyItems if(compareTwoDataMaskingPolicyItemList(value, oldValue)) { return null; } - } else if (fieldName.equalsIgnoreCase(ROWFILTER_POLICY_ITEM_CLASS_FIELD_NAME)) { + } else if (ROWFILTER_POLICY_ITEM_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { //compare old and new rowFilterPolicyItems if(compareTwoRowFilterPolicyItemList(value, oldValue)) { return null; } - } else if (fieldName.equalsIgnoreCase(IS_ENABLED_CLASS_FIELD_NAME)) { + } else if (IS_ENABLED_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { if (oldPolicy != null) { oldValue=processPolicyNameForTrxLog(String.valueOf(oldPolicy.getIsEnabled())); } - } else if (fieldName.equalsIgnoreCase(IS_AUDIT_ENABLED_CLASS_FIELD_NAME)) { + } else if (IS_AUDIT_ENABLED_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { if (oldPolicy != null) { oldValue=processPolicyNameForTrxLog(String.valueOf(oldPolicy.getIsAuditEnabled())); } - } else if (fieldName.equalsIgnoreCase(IS_ENABLED_CLASS_FIELD_NAME)) { + } else if (IS_ENABLED_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { if(compareTwoPolicyName(value, oldValue)) { return null; } - } else if (fieldName.equalsIgnoreCase(IS_AUDIT_ENABLED_CLASS_FIELD_NAME)) { + } else if (IS_AUDIT_ENABLED_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) { if(compareTwoPolicyName(value, oldValue)) { return null; } http://git-wip-us.apache.org/repos/asf/ranger/blob/1d18e76d/security-admin/src/main/java/org/apache/ranger/service/RangerServiceService.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceService.java b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceService.java index c666a1c..f194b18 100644 --- a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceService.java +++ b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceService.java @@ -157,7 +157,7 @@ public class RangerServiceService extends RangerServiceServiceBase<XXService, Ra } Field[] superClassFields = vObj.getClass().getSuperclass().getDeclaredFields(); for(Field field : superClassFields) { - if(field.getName().equalsIgnoreCase("isEnabled")) { + if("isEnabled".equalsIgnoreCase(field.getName())) { XXTrxLog xTrx = processFieldToCreateTrxLog(field, objectName, nameField, vObj, mObj, action); if(xTrx != null) { trxLogList.add(xTrx); @@ -243,7 +243,7 @@ public class RangerServiceService extends RangerServiceServiceBase<XXService, Ra } } else if (!entry.getValue().equalsIgnoreCase( xConfig.get(key))) { - if (key.equalsIgnoreCase("password") + if ("password".equalsIgnoreCase(key) && entry.getValue().equalsIgnoreCase( hiddenPasswordString)) { continue; @@ -295,7 +295,7 @@ public class RangerServiceService extends RangerServiceServiceBase<XXService, Ra Map<String, String> configs = service.getConfigs(); String pwd = configs.get(ServiceDBStore.CONFIG_KEY_PASSWORD); - if(!stringUtil.isEmpty(pwd) && pwd.equalsIgnoreCase(ServiceDBStore.HIDDEN_PASSWORD_STR)) { + if(!stringUtil.isEmpty(pwd) && ServiceDBStore.HIDDEN_PASSWORD_STR.equalsIgnoreCase(pwd)) { XXServiceConfigMap pwdConfig = daoMgr.getXXServiceConfigMap().findByServiceAndConfigKey(service.getId(), ServiceDBStore.CONFIG_KEY_PASSWORD); if(pwdConfig != null) { http://git-wip-us.apache.org/repos/asf/ranger/blob/1d18e76d/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 81c720d..3aab900 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 @@ -233,7 +233,7 @@ public class XAssetService extends XAssetServiceBase<XXAsset, VXAsset> { } public List<XXTrxLog> getTransactionLog(VXAsset vObj, XXAsset mObj, String action){ - if(vObj == null ||action == null || (action.equalsIgnoreCase("update") && mObj == null)){ + if(vObj == null ||action == null || ("update".equalsIgnoreCase(action) && mObj == null)){ return null; } @@ -267,14 +267,14 @@ public class XAssetService extends XAssetServiceBase<XXAsset, VXAsset> { value = ""+field.get(vObj); } - if(action.equalsIgnoreCase("create")){ + if("create".equalsIgnoreCase(action)){ if(stringUtil.isEmpty(value)){ continue; } xTrxLog.setNewValue(value); - } else if(action.equalsIgnoreCase("delete")){ + } else if("delete".equalsIgnoreCase(action)){ xTrxLog.setPreviousValue(value); - } else if(action.equalsIgnoreCase("update")){ + } else if("update".equalsIgnoreCase(action)){ String oldValue = null; Field[] mFields = mObj.getClass().getDeclaredFields(); for(Field mField : mFields){ @@ -291,7 +291,7 @@ public class XAssetService extends XAssetServiceBase<XXAsset, VXAsset> { break; } } - if(fieldName.equalsIgnoreCase("config")){ + if("config".equalsIgnoreCase(fieldName)){ Map<String, String> vConfig = jsonUtil.jsonToMap(value); Map<String, String> xConfig = jsonUtil.jsonToMap(oldValue); @@ -303,7 +303,7 @@ public class XAssetService extends XAssetServiceBase<XXAsset, VXAsset> { if (!xConfig.containsKey(key)) { newConfig.put(key, entry.getValue()); } else if(!entry.getValue().equalsIgnoreCase(xConfig.get(key))){ - if(key.equalsIgnoreCase("password") && entry + if("password".equalsIgnoreCase(key) && entry .getValue().equalsIgnoreCase(hiddenPasswordString)){ continue; } @@ -349,7 +349,7 @@ public class XAssetService extends XAssetServiceBase<XXAsset, VXAsset> { Entry<String, String> passwordEntry = getPasswordEntry(configMap); Entry<String, String> isEncryptedEntry = getIsEncryptedEntry(configMap); if (passwordEntry != null){ - if(isEncryptedEntry==null || !isEncryptedEntry.getValue().equalsIgnoreCase("true")||isForced==true){ + if(isEncryptedEntry==null || !"true".equalsIgnoreCase(isEncryptedEntry.getValue())||isForced==true){ String password=passwordEntry.getValue(); String encryptPassword=PasswordUtils.encryptPassword(password); String decryptPassword=PasswordUtils.decryptPassword(encryptPassword); @@ -378,8 +378,7 @@ public class XAssetService extends XAssetServiceBase<XXAsset, VXAsset> { Entry<String, String> isEncryptedEntry = getIsEncryptedEntry(configMap); if (isEncryptedEntry!=null && passwordEntry != null){ if (!stringUtil.isEmpty(isEncryptedEntry.getValue()) - && isEncryptedEntry.getValue().equalsIgnoreCase( - "true")) { + && "true".equalsIgnoreCase(isEncryptedEntry.getValue())) { String encryptPassword = passwordEntry.getValue(); String decryptPassword = PasswordUtils .decryptPassword(encryptPassword); http://git-wip-us.apache.org/repos/asf/ranger/blob/1d18e76d/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 1dfe19f..e090391 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 @@ -89,7 +89,7 @@ public class XAuditMapService extends } public List<XXTrxLog> getTransactionLog(VXAuditMap vObj, VXAuditMap mObj, String action){ - if(vObj == null || action == null || (action.equalsIgnoreCase("update") && mObj == null)){ + if(vObj == null || action == null || ("update".equalsIgnoreCase(action) && mObj == null)){ return null; } @@ -121,11 +121,11 @@ public class XAuditMapService extends value = xUser.getName(); } - if(action.equalsIgnoreCase("create")){ + if("create".equalsIgnoreCase(action)){ xTrxLog.setNewValue(value); - } else if(action.equalsIgnoreCase("delete")){ + } else if("delete".equalsIgnoreCase(action)){ xTrxLog.setPreviousValue(value); - } else if(action.equalsIgnoreCase("update")){ + } else if("update".equalsIgnoreCase(action)){ // Not Changed. xTrxLog.setNewValue(value); xTrxLog.setPreviousValue(value); http://git-wip-us.apache.org/repos/asf/ranger/blob/1d18e76d/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 c478dbc..1253eec 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 @@ -153,7 +153,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") && mObj == null)){ + if(vObj == null || action == null || ("update".equalsIgnoreCase(action) && mObj == null)){ return null; } @@ -187,14 +187,14 @@ public class XGroupService extends XGroupServiceBase<XXGroup, VXGroup> { value = ""+field.get(vObj); } - if(action.equalsIgnoreCase("create")){ + if("create".equalsIgnoreCase(action)){ if(stringUtil.isEmpty(value)){ continue; } xTrxLog.setNewValue(value); - } else if(action.equalsIgnoreCase("delete")){ + } else if("delete".equalsIgnoreCase(action)){ xTrxLog.setPreviousValue(value); - } else if(action.equalsIgnoreCase("update")){ + } else if("update".equalsIgnoreCase(action)){ String oldValue = null; Field[] mFields = mObj.getClass().getDeclaredFields(); for(Field mField : mFields){ http://git-wip-us.apache.org/repos/asf/ranger/blob/1d18e76d/security-admin/src/main/java/org/apache/ranger/service/XGroupUserService.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/service/XGroupUserService.java b/security-admin/src/main/java/org/apache/ranger/service/XGroupUserService.java index 0d735da..52f8b1a 100644 --- a/security-admin/src/main/java/org/apache/ranger/service/XGroupUserService.java +++ b/security-admin/src/main/java/org/apache/ranger/service/XGroupUserService.java @@ -155,11 +155,11 @@ public class XGroupUserService extends value = xXGroup.getName(); } - if(action.equalsIgnoreCase("create")){ + if("create".equalsIgnoreCase(action)){ xTrxLog.setNewValue(value); - } else if(action.equalsIgnoreCase("delete")){ + } else if("delete".equalsIgnoreCase(action)){ xTrxLog.setPreviousValue(value); - } else if(action.equalsIgnoreCase("update")){ + } else if("update".equalsIgnoreCase(action)){ // No Change. xTrxLog.setNewValue(value); xTrxLog.setPreviousValue(value); http://git-wip-us.apache.org/repos/asf/ranger/blob/1d18e76d/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 bc335cc..1a59975 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 @@ -138,7 +138,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") && mObj == null)){ + if(vObj == null || action == null || ("update".equalsIgnoreCase(action) && mObj == null)){ return null; } @@ -192,7 +192,7 @@ public class XPermMapService extends XPermMapServiceBase<XXPermMap, VXPermMap> { Long assetId = rangerDaoManager.getXXResource().getById(vObj.getResourceId()).getAssetId(); int policyType = rangerDaoManager.getXXAsset().getById(assetId).getAssetType(); if(policyType != AppConstants.ASSET_KNOX){ - if(fieldName.equals("ipAddress")) + if("ipAddress".equals(fieldName)) continue; } @@ -211,24 +211,24 @@ public class XPermMapService extends XPermMapServiceBase<XXPermMap, VXPermMap> { value = ""+field.get(vObj); // XXUser xUser = rangerDaoManager.getXXUser().getById(Long.parseLong(value)); // value = xUser.getName(); - if(fieldName.equals("ipAddress") && action.equalsIgnoreCase("update")){ - prevValue = ""+field.get(mObj); - value = value.equalsIgnoreCase("null") ? "" : value; + if("ipAddress".equals(fieldName) && "update".equalsIgnoreCase(action)){ + prevValue = "" + field.get(mObj); + value = "null".equalsIgnoreCase(value) ? "" : value; } - else if(value == null || value.equalsIgnoreCase("null") || stringUtil.isEmpty(value)){ + else if(value == null || "null".equalsIgnoreCase(value) || stringUtil.isEmpty(value)){ continue; } } - if(action.equalsIgnoreCase("create")){ + if("create".equalsIgnoreCase(action)){ xTrxLog.setNewValue(value); - } else if(action.equalsIgnoreCase("delete")){ + } else if("delete".equalsIgnoreCase(action)){ xTrxLog.setPreviousValue(value); - } else if(action.equalsIgnoreCase("update")){ + } else if("update".equalsIgnoreCase(action)){ // Not Changed. xTrxLog.setNewValue(value); xTrxLog.setPreviousValue(value); - if(fieldName.equals("ipAddress")){ + if("ipAddress".equals(fieldName)){ xTrxLog.setPreviousValue(prevValue); } } http://git-wip-us.apache.org/repos/asf/ranger/blob/1d18e76d/security-admin/src/main/java/org/apache/ranger/service/XPortalUserService.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/service/XPortalUserService.java b/security-admin/src/main/java/org/apache/ranger/service/XPortalUserService.java index bb12e3e..c96878d 100644 --- a/security-admin/src/main/java/org/apache/ranger/service/XPortalUserService.java +++ b/security-admin/src/main/java/org/apache/ranger/service/XPortalUserService.java @@ -81,7 +81,7 @@ public class XPortalUserService extends public List<XXTrxLog> getTransactionLog(VXPortalUser vObj, XXPortalUser xObj, String action) { - if (vObj == null || action == null || (action.equalsIgnoreCase("update") && xObj == null)) { + if (vObj == null || action == null || ("update".equalsIgnoreCase(action) && xObj == null)) { return null; } @@ -117,14 +117,14 @@ public class XPortalUserService extends value = "" + field.get(vObj); } - if (action.equalsIgnoreCase("create")) { + if ("create".equalsIgnoreCase(action)) { if (stringUtil.isEmpty(value)) { continue; } xTrxLog.setNewValue(value); - } else if (action.equalsIgnoreCase("delete")) { + } else if ("delete".equalsIgnoreCase(action)) { xTrxLog.setPreviousValue(value); - } else if (action.equalsIgnoreCase("update")) { + } else if ("update".equalsIgnoreCase(action)) { String oldValue = null; Field[] xFields = xObj.getClass().getDeclaredFields(); @@ -147,7 +147,7 @@ public class XPortalUserService extends break; } } - if (fieldName.equalsIgnoreCase("emailAddress")) { + if ("emailAddress".equalsIgnoreCase(fieldName)) { if (!stringUtil.validateEmail(oldValue)) { oldValue = ""; } http://git-wip-us.apache.org/repos/asf/ranger/blob/1d18e76d/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 fee7101..004ded4 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 @@ -464,7 +464,7 @@ public class XResourceService extends } public List<XXTrxLog> getTransactionLog(VXResource vObj, XXResource mObj, String action){ - if(vObj == null || action == null || (action.equalsIgnoreCase("update") && mObj == null)) { + if(vObj == null || action == null || ("update".equalsIgnoreCase(action) && mObj == null)) { return null; } @@ -522,26 +522,26 @@ public class XResourceService extends boolean isEnum = vTrxLogAttr.isEnum(); if(isEnum){ String enumName = XXResource.getEnumName(fieldName); - if(enumName==null && fieldName.equals("assetType")){ + if(enumName==null && "assetType".equals(fieldName)){ enumName="CommonEnums.AssetType"; } int enumValue = field.get(vObj) == null ? 0 : Integer.parseInt(""+field.get(vObj)); value = xaEnumUtil.getLabel(enumName, enumValue); } else { value = ""+field.get(vObj); - if(value == null || value.equalsIgnoreCase("null")){ + if(value == null || "null".equalsIgnoreCase(value)){ continue; } } - if(action.equalsIgnoreCase("create")){ + if("create".equalsIgnoreCase(action)){ if(stringUtil.isEmpty(value)){ continue; } xTrxLog.setNewValue(value); - } else if(action.equalsIgnoreCase("delete")){ + } else if("delete".equalsIgnoreCase(action)){ xTrxLog.setPreviousValue(value); - } else if(action.equalsIgnoreCase("update")){ + } else if("update".equalsIgnoreCase(action)){ String oldValue = null; Field[] mFields = mObj.getClass().getDeclaredFields(); for(Field mField : mFields){ @@ -550,7 +550,7 @@ public class XResourceService extends if(fieldName.equalsIgnoreCase(mFieldName)){ if(isEnum){ String enumName = XXResource.getEnumName(mFieldName); - if(enumName==null && mFieldName.equals("assetType")){ + if(enumName==null && "assetType".equals(mFieldName)){ enumName="CommonEnums.AssetType"; } int enumValue = mField.get(mObj) == null ? 0 : Integer.parseInt(""+mField.get(mObj)); @@ -561,7 +561,7 @@ public class XResourceService extends break; } } - if(value.equalsIgnoreCase(oldValue) && !fieldName.equals("policyName")){ + if(value.equalsIgnoreCase(oldValue) && !"policyName".equals(fieldName)){ continue; } xTrxLog.setPreviousValue(oldValue); http://git-wip-us.apache.org/repos/asf/ranger/blob/1d18e76d/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 e8fef7a..de95138 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 @@ -268,7 +268,7 @@ 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)) { + if (vObj == null || action == null || ("update".equalsIgnoreCase(action) && mObj == null)) { return null; } @@ -300,38 +300,38 @@ public class XUserService extends XUserServiceBase<XXUser, VXUser> { value = xaEnumUtil.getLabel(enumName, enumValue); } else { value = "" + field.get(vObj); - if ((value == null || value.equalsIgnoreCase("null")) - && !action.equalsIgnoreCase("update")) { + if ((value == null || "null".equalsIgnoreCase(value)) + && !"update".equalsIgnoreCase(action)) { continue; } } - if (fieldName.equalsIgnoreCase("password")) { + if ("password".equalsIgnoreCase(fieldName)) { if (value.equalsIgnoreCase(hiddenPasswordString)) { continue; } } - if (action.equalsIgnoreCase("create")) { + if ("create".equalsIgnoreCase(action)) { if (stringUtil.isEmpty(value) - || (fieldName.equalsIgnoreCase("emailAddress") && !stringUtil + || ("emailAddress".equalsIgnoreCase(fieldName) && !stringUtil .validateEmail(value))) { continue; } xTrxLog.setNewValue(value); - } else if (action.equalsIgnoreCase("delete")) { - if (fieldName.equalsIgnoreCase("emailAddress") + } else if ("delete".equalsIgnoreCase(action)) { + if ("emailAddress".equalsIgnoreCase(fieldName) && !stringUtil.validateEmail(value)) { continue; } xTrxLog.setPreviousValue(value); - } else if (action.equalsIgnoreCase("update")) { + } else if ("update".equalsIgnoreCase(action)) { String oldValue = null; Field[] mFields = mObj.getClass().getDeclaredFields(); for (Field mField : mFields) { mField.setAccessible(true); String mFieldName = mField.getName(); - if (mFieldName.equalsIgnoreCase("loginId")) { + if ("loginId".equalsIgnoreCase(mFieldName)) { mFieldName = "name"; } if (fieldName.equalsIgnoreCase(mFieldName)) { @@ -342,7 +342,7 @@ public class XUserService extends XUserServiceBase<XXUser, VXUser> { if (oldValue == null || oldValue.equalsIgnoreCase(value)) { continue; } - if (fieldName.equalsIgnoreCase("emailAddress")) { + if ("emailAddress".equalsIgnoreCase(fieldName)) { if (stringUtil.validateEmail(oldValue)) { xTrxLog.setPreviousValue(oldValue); } http://git-wip-us.apache.org/repos/asf/ranger/blob/1d18e76d/security-admin/src/main/java/org/apache/ranger/service/filter/RangerRESTAPIFilter.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/service/filter/RangerRESTAPIFilter.java b/security-admin/src/main/java/org/apache/ranger/service/filter/RangerRESTAPIFilter.java index 5b78925..551f824 100644 --- a/security-admin/src/main/java/org/apache/ranger/service/filter/RangerRESTAPIFilter.java +++ b/security-admin/src/main/java/org/apache/ranger/service/filter/RangerRESTAPIFilter.java @@ -93,8 +93,8 @@ public class RangerRESTAPIFilter extends LoggingFilter { if (logStdOut) { String path = request.getRequestUri().getPath(); - if ((request.getMediaType() == null || !request.getMediaType() - .getType().equals("multipart")) + if ((request.getMediaType() == null || !"multipart".equals(request.getMediaType() + .getType())) && !path.endsWith("/service/general/logs")) { try { request = super.filter(request); @@ -124,7 +124,7 @@ public class RangerRESTAPIFilter extends LoggingFilter { logger.info("DELETE ME: Response= mediaType is null"); } if (response.getMediaType() == null - || !response.getMediaType().getType().equals("image")) { + || !"image".equals(response.getMediaType().getType())) { response = super.filter(request, response); } http://git-wip-us.apache.org/repos/asf/ranger/blob/1d18e76d/security-admin/src/main/java/org/apache/ranger/solr/SolrMgr.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/solr/SolrMgr.java b/security-admin/src/main/java/org/apache/ranger/solr/SolrMgr.java index 3f7935e..b1f0be4 100644 --- a/security-admin/src/main/java/org/apache/ranger/solr/SolrMgr.java +++ b/security-admin/src/main/java/org/apache/ranger/solr/SolrMgr.java @@ -68,7 +68,7 @@ public class SolrMgr { if (!initDone) { synchronized (lock) { if (!initDone) { - if (rangerBizUtil.getAuditDBType().equalsIgnoreCase("solr")) { + if ("solr".equalsIgnoreCase(rangerBizUtil.getAuditDBType())) { String zkHosts = PropertiesUtil .getProperty(SOLR_ZK_HOSTS); if (zkHosts == null) { @@ -94,13 +94,13 @@ public class SolrMgr { .getProperty("ranger.solr.url"); } - if (zkHosts != null && !zkHosts.trim().equals("") - && !zkHosts.trim().equalsIgnoreCase("none")) { + if (zkHosts != null && !"".equals(zkHosts.trim()) + && !"none".equalsIgnoreCase(zkHosts.trim())) { zkHosts = zkHosts.trim(); String collectionName = PropertiesUtil .getProperty(SOLR_COLLECTION_NAME); if (collectionName == null - || collectionName.equalsIgnoreCase("none")) { + || "none".equalsIgnoreCase(collectionName)) { collectionName = DEFAULT_COLLECTION_NAME; } @@ -124,7 +124,7 @@ public class SolrMgr { } else { if (solrURL == null || solrURL.isEmpty() - || solrURL.equalsIgnoreCase("none")) { + || "none".equalsIgnoreCase(solrURL)) { logger.fatal("Solr ZKHosts and URL for Audit are empty. Please set property " + SOLR_ZK_HOSTS + " or " http://git-wip-us.apache.org/repos/asf/ranger/blob/1d18e76d/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 85f420d..fcadf38 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 @@ -276,7 +276,7 @@ public class SolrUtil { // Add sort type String sortType = searchCriteria.getSortType(); ORDER order = ORDER.asc; - if (sortType != null && sortType.equalsIgnoreCase("desc")) { + if (sortType != null && "desc".equalsIgnoreCase(sortType)) { order = ORDER.desc; } http://git-wip-us.apache.org/repos/asf/ranger/blob/1d18e76d/security-admin/src/main/java/org/apache/ranger/util/RestUtil.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/util/RestUtil.java b/security-admin/src/main/java/org/apache/ranger/util/RestUtil.java index b50d161..4d7388f 100644 --- a/security-admin/src/main/java/org/apache/ranger/util/RestUtil.java +++ b/security-admin/src/main/java/org/apache/ranger/util/RestUtil.java @@ -39,7 +39,7 @@ public class RestUtil { if (cookies != null) { for (Cookie cookie : cookies) { try { - if (cookie.getName().equals(timeOffsetCookieName)) { + if (timeOffsetCookieName.equals(cookie.getName())) { timeOffset = cookie.getValue(); if (timeOffset != null) { cookieVal = Integer.parseInt(timeOffset);