@Test public void testMatchHdfsPolicy_NoResourceName(){ boolean bnlChk = rangerBizUtil.matchHbasePolicy(null, null, null, id, AppConstants.XA_PERM_TYPE_UNKNOWN); Assert.assertFalse(bnlChk); }
public boolean matchHbasePolicy(String resourceName, List<XXResource> xResourceList, VXResponse vXResponse, Long xUserId, int permission) { if (stringUtil.isEmpty(resourceName) || xResourceList == null || xUserId == null) { return false; } String[] splittedResources = stringUtil.split(resourceName, fileSeparator); if (splittedResources.length < 1 || splittedResources.length > 3) { logger.debug("Invalid resourceName name : " + resourceName); return false; } String tblName = splittedResources.length > 0 ? splittedResources[0] : StringUtil.WILDCARD_ASTERISK; String colFamName = splittedResources.length > 1 ? splittedResources[1] : StringUtil.WILDCARD_ASTERISK; String colName = splittedResources.length > 2 ? splittedResources[2] : StringUtil.WILDCARD_ASTERISK; boolean policyMatched = false; for (XXResource xResource : xResourceList) { if (xResource.getResourceStatus() != AppConstants.STATUS_ENABLED) { continue; } Long resourceId = xResource.getId(); boolean hasPermission = checkUsrPermForPolicy(xUserId, permission, resourceId); if (!hasPermission) { continue; } String[] xTables = stringUtil.isEmpty(xResource.getTables()) ? null : stringUtil.split(xResource.getTables(), ","); boolean matchFound = (xTables == null || xTables.length == 0) || matchPath(tblName, xTables); if (matchFound) { String[] xColumnFamilies = stringUtil.isEmpty(xResource .getColumnFamilies()) ? null : stringUtil.split( xResource.getColumnFamilies(), ","); matchFound = (xColumnFamilies == null || xColumnFamilies.length == 0) || matchPath(colFamName, xColumnFamilies); if (matchFound) { String[] xColumns = stringUtil.isEmpty(xResource .getColumns()) ? null : stringUtil.split( xResource.getColumns(), ","); matchFound = (xColumns == null || xColumns.length == 0) || matchPath(colName, xColumns); } } if (matchFound) { policyMatched = true; break; } } return policyMatched; }
RangerBizUtil { public boolean matchHbasePolicy(String resourceName, List<XXResource> xResourceList, VXResponse vXResponse, Long xUserId, int permission) { if (stringUtil.isEmpty(resourceName) || xResourceList == null || xUserId == null) { return false; } String[] splittedResources = stringUtil.split(resourceName, fileSeparator); if (splittedResources.length < 1 || splittedResources.length > 3) { logger.debug("Invalid resourceName name : " + resourceName); return false; } String tblName = splittedResources.length > 0 ? splittedResources[0] : StringUtil.WILDCARD_ASTERISK; String colFamName = splittedResources.length > 1 ? splittedResources[1] : StringUtil.WILDCARD_ASTERISK; String colName = splittedResources.length > 2 ? splittedResources[2] : StringUtil.WILDCARD_ASTERISK; boolean policyMatched = false; for (XXResource xResource : xResourceList) { if (xResource.getResourceStatus() != AppConstants.STATUS_ENABLED) { continue; } Long resourceId = xResource.getId(); boolean hasPermission = checkUsrPermForPolicy(xUserId, permission, resourceId); if (!hasPermission) { continue; } String[] xTables = stringUtil.isEmpty(xResource.getTables()) ? null : stringUtil.split(xResource.getTables(), ","); boolean matchFound = (xTables == null || xTables.length == 0) || matchPath(tblName, xTables); if (matchFound) { String[] xColumnFamilies = stringUtil.isEmpty(xResource .getColumnFamilies()) ? null : stringUtil.split( xResource.getColumnFamilies(), ","); matchFound = (xColumnFamilies == null || xColumnFamilies.length == 0) || matchPath(colFamName, xColumnFamilies); if (matchFound) { String[] xColumns = stringUtil.isEmpty(xResource .getColumns()) ? null : stringUtil.split( xResource.getColumns(), ","); matchFound = (xColumns == null || xColumns.length == 0) || matchPath(colName, xColumns); } } if (matchFound) { policyMatched = true; break; } } return policyMatched; } }
RangerBizUtil { public boolean matchHbasePolicy(String resourceName, List<XXResource> xResourceList, VXResponse vXResponse, Long xUserId, int permission) { if (stringUtil.isEmpty(resourceName) || xResourceList == null || xUserId == null) { return false; } String[] splittedResources = stringUtil.split(resourceName, fileSeparator); if (splittedResources.length < 1 || splittedResources.length > 3) { logger.debug("Invalid resourceName name : " + resourceName); return false; } String tblName = splittedResources.length > 0 ? splittedResources[0] : StringUtil.WILDCARD_ASTERISK; String colFamName = splittedResources.length > 1 ? splittedResources[1] : StringUtil.WILDCARD_ASTERISK; String colName = splittedResources.length > 2 ? splittedResources[2] : StringUtil.WILDCARD_ASTERISK; boolean policyMatched = false; for (XXResource xResource : xResourceList) { if (xResource.getResourceStatus() != AppConstants.STATUS_ENABLED) { continue; } Long resourceId = xResource.getId(); boolean hasPermission = checkUsrPermForPolicy(xUserId, permission, resourceId); if (!hasPermission) { continue; } String[] xTables = stringUtil.isEmpty(xResource.getTables()) ? null : stringUtil.split(xResource.getTables(), ","); boolean matchFound = (xTables == null || xTables.length == 0) || matchPath(tblName, xTables); if (matchFound) { String[] xColumnFamilies = stringUtil.isEmpty(xResource .getColumnFamilies()) ? null : stringUtil.split( xResource.getColumnFamilies(), ","); matchFound = (xColumnFamilies == null || xColumnFamilies.length == 0) || matchPath(colFamName, xColumnFamilies); if (matchFound) { String[] xColumns = stringUtil.isEmpty(xResource .getColumns()) ? null : stringUtil.split( xResource.getColumns(), ","); matchFound = (xColumns == null || xColumns.length == 0) || matchPath(colName, xColumns); } } if (matchFound) { policyMatched = true; break; } } return policyMatched; } RangerBizUtil(); }
RangerBizUtil { public boolean matchHbasePolicy(String resourceName, List<XXResource> xResourceList, VXResponse vXResponse, Long xUserId, int permission) { if (stringUtil.isEmpty(resourceName) || xResourceList == null || xUserId == null) { return false; } String[] splittedResources = stringUtil.split(resourceName, fileSeparator); if (splittedResources.length < 1 || splittedResources.length > 3) { logger.debug("Invalid resourceName name : " + resourceName); return false; } String tblName = splittedResources.length > 0 ? splittedResources[0] : StringUtil.WILDCARD_ASTERISK; String colFamName = splittedResources.length > 1 ? splittedResources[1] : StringUtil.WILDCARD_ASTERISK; String colName = splittedResources.length > 2 ? splittedResources[2] : StringUtil.WILDCARD_ASTERISK; boolean policyMatched = false; for (XXResource xResource : xResourceList) { if (xResource.getResourceStatus() != AppConstants.STATUS_ENABLED) { continue; } Long resourceId = xResource.getId(); boolean hasPermission = checkUsrPermForPolicy(xUserId, permission, resourceId); if (!hasPermission) { continue; } String[] xTables = stringUtil.isEmpty(xResource.getTables()) ? null : stringUtil.split(xResource.getTables(), ","); boolean matchFound = (xTables == null || xTables.length == 0) || matchPath(tblName, xTables); if (matchFound) { String[] xColumnFamilies = stringUtil.isEmpty(xResource .getColumnFamilies()) ? null : stringUtil.split( xResource.getColumnFamilies(), ","); matchFound = (xColumnFamilies == null || xColumnFamilies.length == 0) || matchPath(colFamName, xColumnFamilies); if (matchFound) { String[] xColumns = stringUtil.isEmpty(xResource .getColumns()) ? null : stringUtil.split( xResource.getColumns(), ","); matchFound = (xColumns == null || xColumns.length == 0) || matchPath(colName, xColumns); } } if (matchFound) { policyMatched = true; break; } } return policyMatched; } RangerBizUtil(); void checkSystemAdminAccess(); String generatePublicName(VXPortalUser userProfile,
			XXPortalUser gjUser); String generatePublicName(String firstName, String lastName); VXStringList mapStringListToVStringList(List<String> stringList); VXResponse hasPermission(VXResource vXResource, int permission); boolean isAdmin(); boolean isAuditAdmin(); String getCurrentUserLoginId(); Long getXUserId(); void failUnauthenticatedIfNotAllowed(); boolean matchHbasePolicy(String resourceName,
			List<XXResource> xResourceList, VXResponse vXResponse,
			Long xUserId, int permission); boolean matchHivePolicy(String resourceName,
			List<XXResource> xResourceList, Long xUserId, int permission); boolean matchHivePolicy(String resourceName,
			List<XXResource> xResourceList, Long xUserId, int permission,
			int reqTableType, int reqColumnType, boolean isUdfPolicy); String replaceMetaChars(String path); Long getPublicGroupId(); boolean isGroupInList(Long groupId, List<XXGroup> xGroupList); boolean isRecursiveWildCardMatch(String pathToCheck,
			String wildcardPath); List<Integer> getResorceTypeParentHirearchy(int resourceType,
			int assetType); boolean comparePathsForExactMatch(String path1, String path2); boolean nonRecursiveWildCardMatch(String pathToCheck,
			String wildcardPath); static boolean areAllEqual(int checkValue, int... otherValues); void createTrxLog(List<XXTrxLog> trxLogList); static int getDBFlavor(); String getDBVersion(); String getAuditDBType(); void setAuditDBType(String auditDBType); boolean isKeyAdmin(); boolean isAuditKeyAdmin(); Boolean hasAccess(XXDBBase xxDbBase, RangerBaseModelObject baseModel); void hasAdminPermissions(String objType); void hasKMSPermissions(String objType, String implClassName); boolean checkUserAccessible(VXUser vXUser); boolean isSSOEnabled(); boolean isUserAllowed(RangerService rangerService, String cfgNameAllowedUsers); boolean isUserAllowedForGrantRevoke(RangerService rangerService, String userName); boolean isUserRangerAdmin(String username); boolean isUserServiceAdmin(RangerService rangerService, String userName); boolean isUserInConfigParameter(RangerService rangerService, String configParamName, String userName); void blockAuditorRoleUser(); boolean hasModuleAccess(String moduleName); void removeEmptyStrings(List<String> list); void trimAll(List<String> list); static boolean isBulkMode(); static boolean setBulkMode(boolean val); void bulkModeOnlyFlushAndClear(); boolean checkAdminAccess(); }
RangerBizUtil { public boolean matchHbasePolicy(String resourceName, List<XXResource> xResourceList, VXResponse vXResponse, Long xUserId, int permission) { if (stringUtil.isEmpty(resourceName) || xResourceList == null || xUserId == null) { return false; } String[] splittedResources = stringUtil.split(resourceName, fileSeparator); if (splittedResources.length < 1 || splittedResources.length > 3) { logger.debug("Invalid resourceName name : " + resourceName); return false; } String tblName = splittedResources.length > 0 ? splittedResources[0] : StringUtil.WILDCARD_ASTERISK; String colFamName = splittedResources.length > 1 ? splittedResources[1] : StringUtil.WILDCARD_ASTERISK; String colName = splittedResources.length > 2 ? splittedResources[2] : StringUtil.WILDCARD_ASTERISK; boolean policyMatched = false; for (XXResource xResource : xResourceList) { if (xResource.getResourceStatus() != AppConstants.STATUS_ENABLED) { continue; } Long resourceId = xResource.getId(); boolean hasPermission = checkUsrPermForPolicy(xUserId, permission, resourceId); if (!hasPermission) { continue; } String[] xTables = stringUtil.isEmpty(xResource.getTables()) ? null : stringUtil.split(xResource.getTables(), ","); boolean matchFound = (xTables == null || xTables.length == 0) || matchPath(tblName, xTables); if (matchFound) { String[] xColumnFamilies = stringUtil.isEmpty(xResource .getColumnFamilies()) ? null : stringUtil.split( xResource.getColumnFamilies(), ","); matchFound = (xColumnFamilies == null || xColumnFamilies.length == 0) || matchPath(colFamName, xColumnFamilies); if (matchFound) { String[] xColumns = stringUtil.isEmpty(xResource .getColumns()) ? null : stringUtil.split( xResource.getColumns(), ","); matchFound = (xColumns == null || xColumns.length == 0) || matchPath(colName, xColumns); } } if (matchFound) { policyMatched = true; break; } } return policyMatched; } RangerBizUtil(); void checkSystemAdminAccess(); String generatePublicName(VXPortalUser userProfile,
			XXPortalUser gjUser); String generatePublicName(String firstName, String lastName); VXStringList mapStringListToVStringList(List<String> stringList); VXResponse hasPermission(VXResource vXResource, int permission); boolean isAdmin(); boolean isAuditAdmin(); String getCurrentUserLoginId(); Long getXUserId(); void failUnauthenticatedIfNotAllowed(); boolean matchHbasePolicy(String resourceName,
			List<XXResource> xResourceList, VXResponse vXResponse,
			Long xUserId, int permission); boolean matchHivePolicy(String resourceName,
			List<XXResource> xResourceList, Long xUserId, int permission); boolean matchHivePolicy(String resourceName,
			List<XXResource> xResourceList, Long xUserId, int permission,
			int reqTableType, int reqColumnType, boolean isUdfPolicy); String replaceMetaChars(String path); Long getPublicGroupId(); boolean isGroupInList(Long groupId, List<XXGroup> xGroupList); boolean isRecursiveWildCardMatch(String pathToCheck,
			String wildcardPath); List<Integer> getResorceTypeParentHirearchy(int resourceType,
			int assetType); boolean comparePathsForExactMatch(String path1, String path2); boolean nonRecursiveWildCardMatch(String pathToCheck,
			String wildcardPath); static boolean areAllEqual(int checkValue, int... otherValues); void createTrxLog(List<XXTrxLog> trxLogList); static int getDBFlavor(); String getDBVersion(); String getAuditDBType(); void setAuditDBType(String auditDBType); boolean isKeyAdmin(); boolean isAuditKeyAdmin(); Boolean hasAccess(XXDBBase xxDbBase, RangerBaseModelObject baseModel); void hasAdminPermissions(String objType); void hasKMSPermissions(String objType, String implClassName); boolean checkUserAccessible(VXUser vXUser); boolean isSSOEnabled(); boolean isUserAllowed(RangerService rangerService, String cfgNameAllowedUsers); boolean isUserAllowedForGrantRevoke(RangerService rangerService, String userName); boolean isUserRangerAdmin(String username); boolean isUserServiceAdmin(RangerService rangerService, String userName); boolean isUserInConfigParameter(RangerService rangerService, String configParamName, String userName); void blockAuditorRoleUser(); boolean hasModuleAccess(String moduleName); void removeEmptyStrings(List<String> list); void trimAll(List<String> list); static boolean isBulkMode(); static boolean setBulkMode(boolean val); void bulkModeOnlyFlushAndClear(); boolean checkAdminAccess(); final String EMPTY_CONTENT_DISPLAY_NAME; static final String AUDIT_STORE_RDBMS; static final String AUDIT_STORE_SOLR; static final String AUDIT_STORE_ElasticSearch; static final boolean batchClearEnabled; static final int policyBatchSize; static final int batchPersistSize; }