|
|
@ -27,8 +27,6 @@ import org.apache.tuweni.toml.TomlParseResult; |
|
|
|
|
|
|
|
|
|
|
|
public class PermissioningConfigurationBuilder { |
|
|
|
public class PermissioningConfigurationBuilder { |
|
|
|
|
|
|
|
|
|
|
|
@Deprecated public static final String ACCOUNTS_WHITELIST_KEY = "accounts-whitelist"; |
|
|
|
|
|
|
|
@Deprecated public static final String NODES_WHITELIST_KEY = "nodes-whitelist"; |
|
|
|
|
|
|
|
public static final String ACCOUNTS_ALLOWLIST_KEY = "accounts-allowlist"; |
|
|
|
public static final String ACCOUNTS_ALLOWLIST_KEY = "accounts-allowlist"; |
|
|
|
public static final String NODES_ALLOWLIST_KEY = "nodes-allowlist"; |
|
|
|
public static final String NODES_ALLOWLIST_KEY = "nodes-allowlist"; |
|
|
|
|
|
|
|
|
|
|
@ -69,8 +67,7 @@ public class PermissioningConfigurationBuilder { |
|
|
|
|
|
|
|
|
|
|
|
if (localConfigNodePermissioningEnabled) { |
|
|
|
if (localConfigNodePermissioningEnabled) { |
|
|
|
final TomlParseResult nodePermissioningToml = readToml(nodePermissioningConfigFilepath); |
|
|
|
final TomlParseResult nodePermissioningToml = readToml(nodePermissioningConfigFilepath); |
|
|
|
final TomlArray nodeAllowlistTomlArray = |
|
|
|
final TomlArray nodeAllowlistTomlArray = getArray(nodePermissioningToml, NODES_ALLOWLIST_KEY); |
|
|
|
getAllowlistArray(nodePermissioningToml, NODES_ALLOWLIST_KEY, NODES_WHITELIST_KEY); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
permissioningConfiguration.setNodePermissioningConfigFilePath( |
|
|
|
permissioningConfiguration.setNodePermissioningConfigFilePath( |
|
|
|
nodePermissioningConfigFilepath); |
|
|
|
nodePermissioningConfigFilepath); |
|
|
@ -104,8 +101,7 @@ public class PermissioningConfigurationBuilder { |
|
|
|
if (localConfigAccountPermissioningEnabled) { |
|
|
|
if (localConfigAccountPermissioningEnabled) { |
|
|
|
final TomlParseResult accountPermissioningToml = readToml(accountPermissioningConfigFilepath); |
|
|
|
final TomlParseResult accountPermissioningToml = readToml(accountPermissioningConfigFilepath); |
|
|
|
final TomlArray accountAllowlistTomlArray = |
|
|
|
final TomlArray accountAllowlistTomlArray = |
|
|
|
getAllowlistArray( |
|
|
|
getArray(accountPermissioningToml, ACCOUNTS_ALLOWLIST_KEY); |
|
|
|
accountPermissioningToml, ACCOUNTS_ALLOWLIST_KEY, ACCOUNTS_WHITELIST_KEY); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
permissioningConfiguration.setAccountPermissioningConfigFilePath( |
|
|
|
permissioningConfiguration.setAccountPermissioningConfigFilePath( |
|
|
|
accountPermissioningConfigFilepath); |
|
|
|
accountPermissioningConfigFilepath); |
|
|
@ -137,23 +133,14 @@ public class PermissioningConfigurationBuilder { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* This method allows support for both keys for now. Whitelist TOML keys will be removed in future |
|
|
|
* This method retrieves an array from parsed toml, using the given key. |
|
|
|
* (breaking change) |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* @param tomlParseResult result of a prior toml parse |
|
|
|
* @param tomlParseResult result of a prior toml parse |
|
|
|
* @param primaryKey key to fetch |
|
|
|
* @param key key to fetch |
|
|
|
* @param alternateKey alternate key to fetch |
|
|
|
* @return The array matching the key if it exists, or null. |
|
|
|
* @return In order: the array of the primaryKey if it exists, or the array of the alternateKey if |
|
|
|
|
|
|
|
* it exists, or null. |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private static TomlArray getAllowlistArray( |
|
|
|
private static TomlArray getArray(final TomlParseResult tomlParseResult, final String key) { |
|
|
|
final TomlParseResult tomlParseResult, final String primaryKey, final String alternateKey) { |
|
|
|
return tomlParseResult.getArray(key); |
|
|
|
final TomlArray array = tomlParseResult.getArray(primaryKey); |
|
|
|
|
|
|
|
if (array == null) { |
|
|
|
|
|
|
|
return tomlParseResult.getArray(alternateKey); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return array; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static TomlParseResult readToml(final String filepath) throws Exception { |
|
|
|
private static TomlParseResult readToml(final String filepath) throws Exception { |
|
|
|