This repository has been archived by the owner on Sep 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 130
Nc 1942 Add account whitelisting and refactor into permissioning package #460
Merged
Merged
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 7b52fd4
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss 4acf4cf
WS sync subscription delay added with unit testing
Shinabyss 0d517ba
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss 1db0792
WS sync subscription delay added with unit testing
Shinabyss 189b25a
Merge branch 'master' into NC-1361
Shinabyss 462536b
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss 3295b21
changed number to a constant in constructor
Shinabyss 609cf0c
Merge remote-tracking branch 'origin/NC-1361' into NC-1361
Shinabyss ae5e2ce
Use default from websocket class instead of making new one
Shinabyss 7b90fea
Merge branch 'master' into NC-1361
Shinabyss 931af28
Merge branch 'master' into NC-1361
Shinabyss 113ba99
Removed magic numbers
Shinabyss f8dcba8
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss 35d3e7d
Merge remote-tracking branch 'origin/NC-1361' into NC-1361
Shinabyss 00497f2
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss d7e5519
Added Controller
Shinabyss 011b93d
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss 3971892
Refactor permissioning config and account whitelist into permissionin…
Shinabyss 677f511
Refactor permissioning config and account whitelist into permissionin…
Shinabyss 5ac5f04
Refactor permissioning config and account whitelist into permissionin…
Shinabyss a0fa0d2
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss 9afbde7
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss 8d6d97d
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss e270cf9
Iron out merge conflict introduced bugs
Shinabyss d94d186
Iron out merge conflict introduced bugs
Shinabyss 6d65170
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss 54e5235
Iron out merge conflict introduced bugs
Shinabyss 2cbd358
PR Change request actioned
Shinabyss f388b41
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss 8e5b91e
PR Change request actioned
Shinabyss 1690f21
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss 1cf498e
PR Change request actioned
Shinabyss 0715b2d
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss 1e57049
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss 2e9804d
PR Change request actioned
Shinabyss 3b6f92b
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss 26f83ed
updated node whitelist acceptance test to conform to refactored permi…
Shinabyss bc1f782
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss bacf2cb
text change
Shinabyss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} |
51 changes: 51 additions & 0 deletions
51
...rc/main/java/tech/pegasys/pantheon/ethereum/permissioning/AccountWhitelistController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actioned