public Role apply(UntypedResultSet.Row row) { try { return new Role(row.getString("role"), row.getBoolean("is_superuser"), row.getBoolean("can_login"), row.has("member_of") ? row.getSet("member_of", UTF8Type.instance) : Collections.<String>emptySet()); } // Failing to deserialize a boolean in is_superuser or can_login will throw an NPE catch (NullPointerException e) { logger.warn("An invalid value has been detected in the {} table for role {}. If you are " + "unable to login, you may need to disable authentication and confirm " + "that values in that table are accurate", AuthKeyspace.ROLES, row.getString("role")); throw new RuntimeException(String.format("Invalid metadata has been detected for role %s", row.getString("role")), e); } } };
public Set<RoleResource> getRoles(RoleResource grantee, boolean includeInherited) throws RequestValidationException, RequestExecutionException { Set<RoleResource> roles = new HashSet<>(); Role role = getRole(grantee.getRoleName()); if (!role.equals(NULL_ROLE)) { roles.add(RoleResource.role(role.name)); collectRoles(role, roles, includeInherited); } return roles; }
public Role apply(UntypedResultSet.Row row) { try { return new Role(row.getString("role"), row.getBoolean("is_superuser"), row.getBoolean("can_login"), row.has("member_of") ? row.getSet("member_of", UTF8Type.instance) : Collections.<String>emptySet()); } // Failing to deserialize a boolean in is_superuser or can_login will throw an NPE catch (NullPointerException e) { logger.warn("An invalid value has been detected in the {} table for role {}. If you are " + "unable to login, you may need to disable authentication and confirm " + "that values in that table are accurate", AuthKeyspace.ROLES, row.getString("role")); throw new RuntimeException(String.format("Invalid metadata has been detected for role %s", row.getString("role")), e); } } };
public Role apply(UntypedResultSet.Row row) { try { return new Role(row.getString("role"), row.getBoolean("is_superuser"), row.getBoolean("can_login"), row.has("member_of") ? row.getSet("member_of", UTF8Type.instance) : Collections.<String>emptySet()); } // Failing to deserialize a boolean in is_superuser or can_login will throw an NPE catch (NullPointerException e) { logger.warn("An invalid value has been detected in the {} table for role {}. If you are " + "unable to login, you may need to disable authentication and confirm " + "that values in that table are accurate", AuthKeyspace.ROLES, row.getString("role")); throw new RuntimeException(String.format("Invalid metadata has been detected for role %s", row.getString("role")), e); } } };
public Role apply(UntypedResultSet.Row row) { return new Role(row.getString("name"), row.getBoolean("super"), true, Collections.<String>emptySet()); } };
private void collectRoles(Role role, Set<RoleResource> collected, boolean includeInherited) throws RequestValidationException, RequestExecutionException { for (String memberOf : role.memberOf) { Role granted = getRole(memberOf); if (granted.equals(NULL_ROLE)) continue; collected.add(RoleResource.role(granted.name)); if (includeInherited) collectRoles(granted, collected, true); } }
private void collectRoles(Role role, Set<RoleResource> collected, boolean includeInherited) throws RequestValidationException, RequestExecutionException { for (String memberOf : role.memberOf) { Role granted = getRole(memberOf); if (granted.equals(NULL_ROLE)) continue; collected.add(RoleResource.role(granted.name)); if (includeInherited) collectRoles(granted, collected, true); } }
private void collectRoles(Role role, Set<RoleResource> collected, boolean includeInherited) throws RequestValidationException, RequestExecutionException { for (String memberOf : role.memberOf) { Role granted = getRole(memberOf); if (granted.equals(NULL_ROLE)) continue; collected.add(RoleResource.role(granted.name)); if (includeInherited) collectRoles(granted, collected, true); } }
public Role apply(UntypedResultSet.Row row) { return new Role(row.getString("name"), row.getBoolean("super"), true, Collections.<String>emptySet()); } };
public Role apply(UntypedResultSet.Row row) { return new Role(row.getString("name"), row.getBoolean("super"), true, Collections.<String>emptySet()); } };
public Set<RoleResource> getRoles(RoleResource grantee, boolean includeInherited) throws RequestValidationException, RequestExecutionException { Set<RoleResource> roles = new HashSet<>(); Role role = getRole(grantee.getRoleName()); if (!role.equals(NULL_ROLE)) { roles.add(RoleResource.role(role.name)); collectRoles(role, roles, includeInherited); } return roles; }
public Set<RoleResource> getRoles(RoleResource grantee, boolean includeInherited) throws RequestValidationException, RequestExecutionException { Set<RoleResource> roles = new HashSet<>(); Role role = getRole(grantee.getRoleName()); if (!role.equals(NULL_ROLE)) { roles.add(RoleResource.role(role.name)); collectRoles(role, roles, includeInherited); } return roles; }