private Role getRole(String name) { try { // If it exists, try the legacy users table in case the cluster // is in the process of being upgraded and so is running with mixed // versions of the authn schema. if (Schema.instance.getCFMetaData(SchemaConstants.AUTH_KEYSPACE_NAME, "users") == null) return getRoleFromTable(name, loadRoleStatement, ROW_TO_ROLE); else { if (legacySelectUserStatement == null) legacySelectUserStatement = prepareLegacySelectUserStatement(); return getRoleFromTable(name, legacySelectUserStatement, LEGACY_ROW_TO_ROLE); } } catch (RequestExecutionException | RequestValidationException e) { throw new RuntimeException(e); } }
private Role getRole(String name) { try { // If it exists, try the legacy users table in case the cluster // is in the process of being upgraded and so is running with mixed // versions of the authn schema. if (Schema.instance.getCFMetaData(SchemaConstants.AUTH_KEYSPACE_NAME, "users") == null) return getRoleFromTable(name, loadRoleStatement, ROW_TO_ROLE); else { if (legacySelectUserStatement == null) legacySelectUserStatement = prepareLegacySelectUserStatement(); return getRoleFromTable(name, legacySelectUserStatement, LEGACY_ROW_TO_ROLE); } } catch (RequestExecutionException | RequestValidationException e) { throw new RuntimeException(e); } }
private Role getRole(String name) { try { // If it exists, try the legacy users table in case the cluster // is in the process of being upgraded and so is running with mixed // versions of the authn schema. if (Schema.instance.getCFMetaData(SchemaConstants.AUTH_KEYSPACE_NAME, "users") == null) return getRoleFromTable(name, loadRoleStatement, ROW_TO_ROLE); else { if (legacySelectUserStatement == null) legacySelectUserStatement = prepareLegacySelectUserStatement(); return getRoleFromTable(name, legacySelectUserStatement, LEGACY_ROW_TO_ROLE); } } catch (RequestExecutionException | RequestValidationException e) { throw new RuntimeException(e); } }
public void setup() { loadRoleStatement = (SelectStatement) prepare("SELECT * from %s.%s WHERE role = ?", SchemaConstants.AUTH_KEYSPACE_NAME, AuthKeyspace.ROLES); // If the old users table exists, we may need to migrate the legacy authn // data to the new table. We also need to prepare a statement to read from // it, so we can continue to use the old tables while the cluster is upgraded. // Otherwise, we may need to create a default superuser role to enable others // to be added. if (Schema.instance.getCFMetaData(SchemaConstants.AUTH_KEYSPACE_NAME, "users") != null) { legacySelectUserStatement = prepareLegacySelectUserStatement(); scheduleSetupTask(() -> { convertLegacyData(); return null; }); } else { scheduleSetupTask(() -> { setupDefaultRole(); return null; }); } }
public void setup() { loadRoleStatement = (SelectStatement) prepare("SELECT * from %s.%s WHERE role = ?", SchemaConstants.AUTH_KEYSPACE_NAME, AuthKeyspace.ROLES); // If the old users table exists, we may need to migrate the legacy authn // data to the new table. We also need to prepare a statement to read from // it, so we can continue to use the old tables while the cluster is upgraded. // Otherwise, we may need to create a default superuser role to enable others // to be added. if (Schema.instance.getCFMetaData(SchemaConstants.AUTH_KEYSPACE_NAME, "users") != null) { legacySelectUserStatement = prepareLegacySelectUserStatement(); scheduleSetupTask(() -> { convertLegacyData(); return null; }); } else { scheduleSetupTask(() -> { setupDefaultRole(); return null; }); } }
public void setup() { loadRoleStatement = (SelectStatement) prepare("SELECT * from %s.%s WHERE role = ?", SchemaConstants.AUTH_KEYSPACE_NAME, AuthKeyspace.ROLES); // If the old users table exists, we may need to migrate the legacy authn // data to the new table. We also need to prepare a statement to read from // it, so we can continue to use the old tables while the cluster is upgraded. // Otherwise, we may need to create a default superuser role to enable others // to be added. if (Schema.instance.getCFMetaData(SchemaConstants.AUTH_KEYSPACE_NAME, "users") != null) { legacySelectUserStatement = prepareLegacySelectUserStatement(); scheduleSetupTask(() -> { convertLegacyData(); return null; }); } else { scheduleSetupTask(() -> { setupDefaultRole(); return null; }); } }