private boolean doesUserHasAdminOption(List<String> roleNames) throws HiveAuthzPluginException { List<HiveRoleGrant> currentRoles; currentRoles = getCurrentRoles(); for (String roleName : roleNames) { boolean roleFound = false; for (HiveRoleGrant currentRole : currentRoles) { if (roleName.equalsIgnoreCase(currentRole.getRoleName())) { roleFound = true; if (!currentRole.isGrantOption()) { return false; } else { break; } } } if (!roleFound) { return false; } } return true; }
private boolean doesUserHasAdminOption(List<String> roleNames) throws HiveAuthzPluginException { List<HiveRoleGrant> currentRoles; currentRoles = getCurrentRoles(); for (String roleName : roleNames) { boolean roleFound = false; for (HiveRoleGrant currentRole : currentRoles) { if (roleName.equalsIgnoreCase(currentRole.getRoleName())) { roleFound = true; if (!currentRole.isGrantOption()) { return false; } else { break; } } } if (!roleFound) { return false; } } return true; }
static String writeRolesGrantedInfo(List<HiveRoleGrant> roles, boolean testMode) { if (roles == null || roles.isEmpty()) { return ""; } StringBuilder builder = new StringBuilder(); //sort the list to get sorted (deterministic) output (for ease of testing) Collections.sort(roles); for (HiveRoleGrant role : roles) { appendNonNull(builder, role.getRoleName(), true); appendNonNull(builder, role.isGrantOption()); appendNonNull(builder, testMode ? -1 : role.getGrantTime() * 1000L); appendNonNull(builder, role.getGrantor()); } return builder.toString(); }
static String writeRolesGrantedInfo(List<HiveRoleGrant> roles, boolean testMode) { if (roles == null || roles.isEmpty()) { return ""; } StringBuilder builder = new StringBuilder(); //sort the list to get sorted (deterministic) output (for ease of testing) Collections.sort(roles); for (HiveRoleGrant role : roles) { appendNonNull(builder, role.getRoleName(), true); appendNonNull(builder, role.isGrantOption()); appendNonNull(builder, testMode ? -1 : role.getGrantTime() * 1000L); appendNonNull(builder, role.getGrantor()); } return builder.toString(); }
private String writeHiveRoleGrantInfo(List<HiveRoleGrant> roleGrants, boolean testMode) { if (roleGrants == null || roleGrants.isEmpty()) { return ""; } StringBuilder builder = new StringBuilder(); // sort the list to get sorted (deterministic) output (for ease of testing) Collections.sort(roleGrants); for (HiveRoleGrant roleGrant : roleGrants) { // schema: // principal_name,principal_type,grant_option,grantor,grantor_type,grant_time appendNonNull(builder, roleGrant.getPrincipalName(), true); appendNonNull(builder, roleGrant.getPrincipalType()); appendNonNull(builder, roleGrant.isGrantOption()); appendNonNull(builder, roleGrant.getGrantor()); appendNonNull(builder, roleGrant.getGrantorType()); appendNonNull(builder, testMode ? -1 : roleGrant.getGrantTime() * 1000L); } return builder.toString(); }
private String writeHiveRoleGrantInfo(List<HiveRoleGrant> roleGrants, boolean testMode) { if (roleGrants == null || roleGrants.isEmpty()) { return ""; } StringBuilder builder = new StringBuilder(); // sort the list to get sorted (deterministic) output (for ease of testing) Collections.sort(roleGrants); for (HiveRoleGrant roleGrant : roleGrants) { // schema: // principal_name,principal_type,grant_option,grantor,grantor_type,grant_time appendNonNull(builder, roleGrant.getPrincipalName(), true); appendNonNull(builder, roleGrant.getPrincipalType()); appendNonNull(builder, roleGrant.isGrantOption()); appendNonNull(builder, roleGrant.getGrantor()); appendNonNull(builder, roleGrant.getGrantorType()); appendNonNull(builder, testMode ? -1 : roleGrant.getGrantTime() * 1000L); } return builder.toString(); }
private boolean doesUserHasAdminOption(List<String> roleNames) throws HiveAuthzPluginException { List<HiveRoleGrant> currentRoles; currentRoles = getCurrentRoles(); for (String roleName : roleNames) { boolean roleFound = false; for (HiveRoleGrant currentRole : currentRoles) { if (roleName.equalsIgnoreCase(currentRole.getRoleName())) { roleFound = true; if (!currentRole.isGrantOption()) { return false; } else { break; } } } if (!roleFound) { return false; } } return true; }
static String writeRolesGrantedInfo(List<HiveRoleGrant> roles, boolean testMode) { if (roles == null || roles.isEmpty()) { return ""; } StringBuilder builder = new StringBuilder(); //sort the list to get sorted (deterministic) output (for ease of testing) Collections.sort(roles); for (HiveRoleGrant role : roles) { appendNonNull(builder, role.getRoleName(), true); appendNonNull(builder, role.isGrantOption()); appendNonNull(builder, testMode ? -1 : role.getGrantTime() * 1000L); appendNonNull(builder, role.getGrantor()); } return builder.toString(); }
private String writeHiveRoleGrantInfo(List<HiveRoleGrant> roleGrants, boolean testMode) { if (roleGrants == null || roleGrants.isEmpty()) { return ""; } StringBuilder builder = new StringBuilder(); // sort the list to get sorted (deterministic) output (for ease of testing) Collections.sort(roleGrants); for (HiveRoleGrant roleGrant : roleGrants) { // schema: // principal_name,principal_type,grant_option,grantor,grantor_type,grant_time appendNonNull(builder, roleGrant.getPrincipalName(), true); appendNonNull(builder, roleGrant.getPrincipalType()); appendNonNull(builder, roleGrant.isGrantOption()); appendNonNull(builder, roleGrant.getGrantor()); appendNonNull(builder, roleGrant.getGrantorType()); appendNonNull(builder, testMode ? -1 : roleGrant.getGrantTime() * 1000L); } return builder.toString(); }