Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Nc 1942 Add account whitelisting and refactor into permissioning package #460

Merged
merged 40 commits into from
Dec 20, 2018
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
334ced0
WS sync subscription delay added
Shinabyss Dec 4, 2018
7b52fd4
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss Dec 4, 2018
4acf4cf
WS sync subscription delay added with unit testing
Shinabyss Dec 9, 2018
0d517ba
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss Dec 9, 2018
1db0792
WS sync subscription delay added with unit testing
Shinabyss Dec 9, 2018
189b25a
Merge branch 'master' into NC-1361
Shinabyss Dec 10, 2018
462536b
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss Dec 10, 2018
3295b21
changed number to a constant in constructor
Shinabyss Dec 10, 2018
609cf0c
Merge remote-tracking branch 'origin/NC-1361' into NC-1361
Shinabyss Dec 10, 2018
ae5e2ce
Use default from websocket class instead of making new one
Shinabyss Dec 10, 2018
7b90fea
Merge branch 'master' into NC-1361
Shinabyss Dec 10, 2018
931af28
Merge branch 'master' into NC-1361
Shinabyss Dec 10, 2018
113ba99
Removed magic numbers
Shinabyss Dec 10, 2018
f8dcba8
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss Dec 10, 2018
35d3e7d
Merge remote-tracking branch 'origin/NC-1361' into NC-1361
Shinabyss Dec 10, 2018
00497f2
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss Dec 11, 2018
d7e5519
Added Controller
Shinabyss Dec 11, 2018
011b93d
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss Dec 12, 2018
3971892
Refactor permissioning config and account whitelist into permissionin…
Shinabyss Dec 18, 2018
677f511
Refactor permissioning config and account whitelist into permissionin…
Shinabyss Dec 18, 2018
5ac5f04
Refactor permissioning config and account whitelist into permissionin…
Shinabyss Dec 18, 2018
a0fa0d2
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss Dec 18, 2018
9afbde7
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss Dec 18, 2018
8d6d97d
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss Dec 18, 2018
e270cf9
Iron out merge conflict introduced bugs
Shinabyss Dec 18, 2018
d94d186
Iron out merge conflict introduced bugs
Shinabyss Dec 19, 2018
6d65170
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss Dec 19, 2018
54e5235
Iron out merge conflict introduced bugs
Shinabyss Dec 19, 2018
2cbd358
PR Change request actioned
Shinabyss Dec 19, 2018
f388b41
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss Dec 19, 2018
8e5b91e
PR Change request actioned
Shinabyss Dec 19, 2018
1690f21
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss Dec 20, 2018
1cf498e
PR Change request actioned
Shinabyss Dec 20, 2018
0715b2d
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss Dec 20, 2018
1e57049
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss Dec 20, 2018
2e9804d
PR Change request actioned
Shinabyss Dec 20, 2018
3b6f92b
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss Dec 20, 2018
26f83ed
updated node whitelist acceptance test to conform to refactored permi…
Shinabyss Dec 20, 2018
bc1f782
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss Dec 20, 2018
bacf2cb
text change
Shinabyss Dec 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ethereum/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies {
implementation project(':crypto')
implementation project(':ethereum:rlp')
implementation project(':ethereum:trie')
implementation project(':ethereum:permissioning')
implementation project(':metrics')
implementation project(':services:kvstore')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
import tech.pegasys.pantheon.ethereum.mainnet.TransactionValidator;
import tech.pegasys.pantheon.ethereum.mainnet.TransactionValidator.TransactionInvalidReason;
import tech.pegasys.pantheon.ethereum.mainnet.ValidationResult;
import tech.pegasys.pantheon.ethereum.permissioning.AccountWhitelistController;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;

import org.apache.logging.log4j.Logger;
Expand All @@ -47,6 +49,7 @@ public class TransactionPool implements BlockAddedObserver {
private final ProtocolSchedule<?> protocolSchedule;
private final ProtocolContext<?> protocolContext;
private final TransactionBatchAddedListener transactionBatchAddedListener;
private Optional<AccountWhitelistController> accountWhitelistController = Optional.empty();

public TransactionPool(
final PendingTransactions pendingTransactions,
Expand Down Expand Up @@ -131,6 +134,16 @@ private ValidationResult<TransactionInvalidReason> validateTransaction(
return basicValidationResult;
}

if (accountWhitelistController.isPresent()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to have this whole logic inside a private method with a meaningful name like checkIfAccountIsWhitelisted or something similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actioned

&& accountWhitelistController.get().isAccountWhiteListSet()) {
String sender = transaction.getSender().toString();
if (!accountWhitelistController.get().contains(sender)) {
return ValidationResult.invalid(
TransactionInvalidReason.TX_SENDER_NOT_AUTHORIZED,
String.format("Sender %s is not on the Account Whitelist", sender));
}
}

final BlockHeader chainHeadBlockHeader = getChainHeadBlockHeader();
if (transaction.getGasLimit() > chainHeadBlockHeader.getGasLimit()) {
return ValidationResult.invalid(
Expand Down Expand Up @@ -163,4 +176,8 @@ public interface TransactionBatchAddedListener {

void onTransactionsAdded(Iterable<Transaction> transactions);
}

public void setAccountWhitelist(AccountWhitelistController accountWhitelist) {
accountWhitelistController = Optional.of(accountWhitelist);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ enum TransactionInvalidReason {
NONCE_TOO_LOW,
INCORRECT_NONCE,
INTRINSIC_GAS_EXCEEDS_GAS_LIMIT,
EXCEEDS_BLOCK_GAS_LIMIT
EXCEEDS_BLOCK_GAS_LIMIT,
TX_SENDER_NOT_AUTHORIZED
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import static org.mockito.Mockito.when;
import static tech.pegasys.pantheon.ethereum.mainnet.TransactionValidator.TransactionInvalidReason.EXCEEDS_BLOCK_GAS_LIMIT;
import static tech.pegasys.pantheon.ethereum.mainnet.TransactionValidator.TransactionInvalidReason.NONCE_TOO_LOW;
import static tech.pegasys.pantheon.ethereum.mainnet.TransactionValidator.TransactionInvalidReason.TX_SENDER_NOT_AUTHORIZED;
import static tech.pegasys.pantheon.ethereum.mainnet.ValidationResult.valid;

import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair;
Expand All @@ -40,6 +41,7 @@
import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSpec;
import tech.pegasys.pantheon.ethereum.mainnet.TransactionValidator;
import tech.pegasys.pantheon.ethereum.mainnet.ValidationResult;
import tech.pegasys.pantheon.ethereum.permissioning.AccountWhitelistController;
import tech.pegasys.pantheon.util.uint.UInt256;

import java.util.List;
Expand Down Expand Up @@ -70,6 +72,8 @@ public class TransactionPoolTest {
private final Transaction transaction2 = createTransaction(2);
private TransactionPool transactionPool;
private long genesisBlockGasLimit;
private final AccountWhitelistController accountWhitelistController =
mock(AccountWhitelistController.class);

@Before
public void setUp() {
Expand Down Expand Up @@ -355,6 +359,35 @@ public void shouldNotNotifyBatchListenerIfNoTransactionsAreAdded() {
verifyZeroInteractions(batchAddedListener);
}

@Test
public void shouldAllowWhitelistedTransactionWhenWhitelistEnabled() {
transactionPool.setAccountWhitelist(accountWhitelistController);
givenTransactionIsValid(transaction1);

when(accountWhitelistController.isAccountWhiteListSet()).thenReturn(true);
when(accountWhitelistController.contains(transaction1.getSender().toString())).thenReturn(true);

assertThat(transactionPool.addLocalTransaction(transaction1)).isEqualTo(valid());

assertTransactionPending(transaction1);
}

@Test
public void shouldRejectNonWhitelistedTransactionWhenWhitelistEnabled() {
transactionPool.setAccountWhitelist(accountWhitelistController);
givenTransactionIsValid(transaction1);

when(accountWhitelistController.isAccountWhiteListSet()).thenReturn(true);
when(accountWhitelistController.contains(transaction1.getSender().toString()))
.thenReturn(false);

assertThat(transactionPool.addLocalTransaction(transaction1))
.isEqualTo(ValidationResult.invalid(TX_SENDER_NOT_AUTHORIZED));

assertTransactionNotPending(transaction1);
verifyZeroInteractions(batchAddedListener);
}

lucassaldanha marked this conversation as resolved.
Show resolved Hide resolved
private void assertTransactionPending(final Transaction t) {
assertThat(transactions.getTransactionByHash(t.hash())).contains(t);
}
Expand Down
1 change: 1 addition & 0 deletions ethereum/eth/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies {
implementation project(':ethereum:core')
implementation project(':ethereum:p2p')
implementation project(':ethereum:rlp')
implementation project(':ethereum:permissioning')
implementation project(':metrics')
implementation project(':services:kvstore')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import tech.pegasys.pantheon.ethereum.p2p.api.PeerConnection;
import tech.pegasys.pantheon.ethereum.p2p.config.DiscoveryConfiguration;
import tech.pegasys.pantheon.ethereum.p2p.config.NetworkingConfiguration;
import tech.pegasys.pantheon.ethereum.p2p.config.PermissioningConfiguration;
import tech.pegasys.pantheon.ethereum.p2p.config.RlpxConfiguration;
import tech.pegasys.pantheon.ethereum.p2p.netty.NettyP2PNetwork;
import tech.pegasys.pantheon.ethereum.p2p.peers.DefaultPeer;
Expand All @@ -46,6 +45,7 @@
import tech.pegasys.pantheon.ethereum.p2p.peers.PeerBlacklist;
import tech.pegasys.pantheon.ethereum.p2p.permissioning.NodeWhitelistController;
import tech.pegasys.pantheon.ethereum.p2p.wire.messages.DisconnectMessage.DisconnectReason;
import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration;
import tech.pegasys.pantheon.metrics.noop.NoOpMetricsSystem;
import tech.pegasys.pantheon.util.bytes.BytesValue;

Expand Down
1 change: 1 addition & 0 deletions ethereum/p2p/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jar {
dependencies {
implementation project(':crypto')
implementation project(':ethereum:core')
implementation project(':ethereum:permissioning')
implementation project(':ethereum:rlp')
implementation project(':metrics')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
*/
package tech.pegasys.pantheon.ethereum.p2p.permissioning;

import tech.pegasys.pantheon.ethereum.p2p.config.PermissioningConfiguration;
import tech.pegasys.pantheon.ethereum.p2p.peers.DefaultPeer;
import tech.pegasys.pantheon.ethereum.p2p.peers.Peer;
import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration;

import java.net.URI;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import tech.pegasys.pantheon.ethereum.p2p.api.PeerConnection;
import tech.pegasys.pantheon.ethereum.p2p.config.DiscoveryConfiguration;
import tech.pegasys.pantheon.ethereum.p2p.config.NetworkingConfiguration;
import tech.pegasys.pantheon.ethereum.p2p.config.PermissioningConfiguration;
import tech.pegasys.pantheon.ethereum.p2p.config.RlpxConfiguration;
import tech.pegasys.pantheon.ethereum.p2p.netty.NettyP2PNetwork;
import tech.pegasys.pantheon.ethereum.p2p.netty.exceptions.IncompatiblePeerException;
Expand All @@ -38,6 +37,7 @@
import tech.pegasys.pantheon.ethereum.p2p.wire.PeerInfo;
import tech.pegasys.pantheon.ethereum.p2p.wire.SubProtocol;
import tech.pegasys.pantheon.ethereum.p2p.wire.messages.DisconnectMessage.DisconnectReason;
import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration;
import tech.pegasys.pantheon.metrics.noop.NoOpMetricsSystem;
import tech.pegasys.pantheon.util.bytes.BytesValue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
import tech.pegasys.pantheon.ethereum.p2p.api.P2PNetwork;
import tech.pegasys.pantheon.ethereum.p2p.config.DiscoveryConfiguration;
import tech.pegasys.pantheon.ethereum.p2p.config.NetworkingConfiguration;
import tech.pegasys.pantheon.ethereum.p2p.config.PermissioningConfiguration;
import tech.pegasys.pantheon.ethereum.p2p.discovery.PeerDiscoveryServiceException;
import tech.pegasys.pantheon.ethereum.p2p.netty.NettyP2PNetwork;
import tech.pegasys.pantheon.ethereum.p2p.peers.PeerBlacklist;
import tech.pegasys.pantheon.ethereum.p2p.permissioning.NodeWhitelistController;
import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration;
import tech.pegasys.pantheon.metrics.noop.NoOpMetricsSystem;
import tech.pegasys.pantheon.util.NetworkUtility;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

import tech.pegasys.pantheon.crypto.SECP256K1;
import tech.pegasys.pantheon.ethereum.p2p.config.DiscoveryConfiguration;
import tech.pegasys.pantheon.ethereum.p2p.config.PermissioningConfiguration;
import tech.pegasys.pantheon.ethereum.p2p.discovery.internal.Packet;
import tech.pegasys.pantheon.ethereum.p2p.discovery.internal.PacketType;
import tech.pegasys.pantheon.ethereum.p2p.discovery.internal.PingPacketData;
import tech.pegasys.pantheon.ethereum.p2p.peers.Endpoint;
import tech.pegasys.pantheon.ethereum.p2p.peers.PeerBlacklist;
import tech.pegasys.pantheon.ethereum.p2p.permissioning.NodeWhitelistController;
import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration;
import tech.pegasys.pantheon.util.bytes.BytesValue;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import tech.pegasys.pantheon.ethereum.p2p.api.MessageData;
import tech.pegasys.pantheon.ethereum.p2p.api.PeerConnection;
import tech.pegasys.pantheon.ethereum.p2p.config.DiscoveryConfiguration;
import tech.pegasys.pantheon.ethereum.p2p.config.PermissioningConfiguration;
import tech.pegasys.pantheon.ethereum.p2p.discovery.internal.FindNeighborsPacketData;
import tech.pegasys.pantheon.ethereum.p2p.discovery.internal.NeighborsPacketData;
import tech.pegasys.pantheon.ethereum.p2p.discovery.internal.Packet;
Expand All @@ -31,6 +30,7 @@
import tech.pegasys.pantheon.ethereum.p2p.wire.Capability;
import tech.pegasys.pantheon.ethereum.p2p.wire.PeerInfo;
import tech.pegasys.pantheon.ethereum.p2p.wire.messages.DisconnectMessage.DisconnectReason;
import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration;
import tech.pegasys.pantheon.util.bytes.BytesValue;

import java.net.SocketAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
import static tech.pegasys.pantheon.ethereum.p2p.NetworkingTestHelper.configWithRandomPorts;

import tech.pegasys.pantheon.crypto.SECP256K1;
import tech.pegasys.pantheon.ethereum.p2p.config.PermissioningConfiguration;
import tech.pegasys.pantheon.ethereum.p2p.discovery.PeerDiscoveryEvent.PeerBondedEvent;
import tech.pegasys.pantheon.ethereum.p2p.peers.Peer;
import tech.pegasys.pantheon.ethereum.p2p.peers.PeerBlacklist;
import tech.pegasys.pantheon.ethereum.p2p.permissioning.NodeWhitelistController;
import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration;

import java.util.ArrayList;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
import static org.mockito.Mockito.when;

import tech.pegasys.pantheon.crypto.SECP256K1;
import tech.pegasys.pantheon.ethereum.p2p.config.PermissioningConfiguration;
import tech.pegasys.pantheon.ethereum.p2p.discovery.internal.Packet;
import tech.pegasys.pantheon.ethereum.p2p.discovery.internal.PacketType;
import tech.pegasys.pantheon.ethereum.p2p.discovery.internal.PeerDiscoveryController;
import tech.pegasys.pantheon.ethereum.p2p.discovery.internal.PeerTable;
import tech.pegasys.pantheon.ethereum.p2p.discovery.internal.PingPacketData;
import tech.pegasys.pantheon.ethereum.p2p.peers.PeerBlacklist;
import tech.pegasys.pantheon.ethereum.p2p.permissioning.NodeWhitelistController;
import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration;

import java.util.Collections;
import java.util.concurrent.TimeUnit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import static org.mockito.Mockito.when;

import tech.pegasys.pantheon.crypto.SECP256K1;
import tech.pegasys.pantheon.ethereum.p2p.config.PermissioningConfiguration;
import tech.pegasys.pantheon.ethereum.p2p.discovery.DiscoveryPeer;
import tech.pegasys.pantheon.ethereum.p2p.discovery.PeerDiscoveryAgent;
import tech.pegasys.pantheon.ethereum.p2p.discovery.PeerDiscoveryStatus;
Expand All @@ -37,6 +36,7 @@
import tech.pegasys.pantheon.ethereum.p2p.peers.Peer;
import tech.pegasys.pantheon.ethereum.p2p.peers.PeerBlacklist;
import tech.pegasys.pantheon.ethereum.p2p.permissioning.NodeWhitelistController;
import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration;
import tech.pegasys.pantheon.util.bytes.Bytes32;
import tech.pegasys.pantheon.util.bytes.BytesValue;
import tech.pegasys.pantheon.util.bytes.MutableBytesValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
import static org.mockito.Mockito.when;

import tech.pegasys.pantheon.crypto.SECP256K1;
import tech.pegasys.pantheon.ethereum.p2p.config.PermissioningConfiguration;
import tech.pegasys.pantheon.ethereum.p2p.discovery.DiscoveryPeer;
import tech.pegasys.pantheon.ethereum.p2p.discovery.PeerDiscoveryAgent;
import tech.pegasys.pantheon.ethereum.p2p.discovery.PeerDiscoveryTestHelper;
import tech.pegasys.pantheon.ethereum.p2p.peers.PeerBlacklist;
import tech.pegasys.pantheon.ethereum.p2p.permissioning.NodeWhitelistController;
import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration;
import tech.pegasys.pantheon.util.bytes.BytesValue;

import java.util.ArrayList;
Expand Down
33 changes: 33 additions & 0 deletions ethereum/permissioning/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2018 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/

apply plugin: 'java-library'

jar {
baseName 'pantheon-permissioning'
manifest {
attributes(
'Specification-Title': baseName,
'Specification-Version': project.version,
'Implementation-Title': baseName,
'Implementation-Version': calculateVersion()
)
}
}

dependencies {

testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.mockito:mockito-core'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2018 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package tech.pegasys.pantheon.ethereum.permissioning;

import java.util.ArrayList;
import java.util.List;

public class AccountWhitelistController {

private final List<String> accountWhitelist;
private boolean accountWhitelistSet = false;

public AccountWhitelistController(final PermissioningConfiguration configuration) {
accountWhitelist = new ArrayList<>();
if (configuration != null && configuration.getAccountWhitelist() != null) {
for (String hexString : configuration.getAccountWhitelist()) {
accountWhitelist.add(hexString);
}
if (configuration.isNodeWhitelistSet()) {
accountWhitelistSet = true;
}
}
}

public boolean addAccount(final String account) {
accountWhitelistSet = true;
return accountWhitelist.add(account);
}

public boolean removeAccount(final String account) {
return accountWhitelist.remove(account);
}

public boolean contains(final String account) {
return (!accountWhitelistSet || (accountWhitelistSet && accountWhitelist.contains(account)));
}

public boolean isAccountWhiteListSet() {
return accountWhitelistSet;
}
}
Loading