Skip to content

Commit 69ed608

Browse files
author
Hubert Marteau
committed
Grant value modified to int (to be able to manage more rights), byte
usage is noticed "Deprecated"
1 parent 9e7711b commit 69ed608

File tree

3 files changed

+45
-17
lines changed

3 files changed

+45
-17
lines changed

src/multichain/command/GrantCommand.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
*/
2222
public class GrantCommand extends QueryBuilderGrant {
2323

24-
public static byte CONNECT = QueryBuilderGrant.CONNECT;
25-
public static byte SEND = QueryBuilderGrant.SEND;
26-
public static byte RECEIVE = QueryBuilderGrant.RECEIVE;
27-
public static byte ISSUE = QueryBuilderGrant.ISSUE;
28-
public static byte MINE = QueryBuilderGrant.MINE;
29-
public static byte ACTIVATE = QueryBuilderGrant.ACTIVATE;
30-
public static byte ADMIN = QueryBuilderGrant.ADMIN;
31-
public static byte CREATE = QueryBuilderGrant.CREATE;
24+
public static int CONNECT = QueryBuilderGrant.CONNECT;
25+
public static int SEND = QueryBuilderGrant.SEND;
26+
public static int RECEIVE = QueryBuilderGrant.RECEIVE;
27+
public static int ISSUE = QueryBuilderGrant.ISSUE;
28+
public static int MINE = QueryBuilderGrant.MINE;
29+
public static int ACTIVATE = QueryBuilderGrant.ACTIVATE;
30+
public static int ADMIN = QueryBuilderGrant.ADMIN;
31+
public static int CREATE = QueryBuilderGrant.CREATE;
3232

3333
public static int WALLET = QueryBuilderGrant.WALLET;
3434
public static int WALLET_ISSUE = QueryBuilderGrant.WALLET_ISSUE;
@@ -69,6 +69,7 @@ public GrantCommand(String ip, String port, String login, String password) {
6969
* with | )
7070
* @return transactionId of grant action
7171
* @throws MultichainException
72+
* @Deprecated
7273
*/
7374
public String grant(Address address, byte permissions) throws MultichainException {
7475
Byte b = new Byte(permissions);
@@ -100,6 +101,7 @@ public String grant(Address address, int permissions) throws MultichainException
100101
* with | )
101102
* @return transactionId of grant action
102103
* @throws MultichainException
104+
* @Deprecated
103105
*/
104106
public String grant(String address, byte permissions) throws MultichainException {
105107
Byte b = new Byte(permissions);
@@ -164,6 +166,7 @@ public String grant(String address, int permissions) throws MultichainException
164166
* with | )
165167
* @return transactionId of grantFrom action
166168
* @throws MultichainException
169+
* @Deprecated
167170
*/
168171
public String grantFrom(Address addressFrom, Address address, byte permissions) throws MultichainException {
169172
Byte b = new Byte(permissions);
@@ -199,6 +202,7 @@ public String grantFrom(Address addressFrom, Address address, int permissions) t
199202
* with | )
200203
* @return transactionId of grantFrom action
201204
* @throws MultichainException
205+
* @Deprecated
202206
*/
203207
public String grantFrom(String addressFrom, String address, byte permissions) throws MultichainException {
204208
Byte b = new Byte(permissions);

src/multichain/command/builders/QueryBuilderGrant.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
*/
1717
public class QueryBuilderGrant extends QueryBuilderCommon {
1818

19-
protected static byte CREATE = (byte) 0b00000000;
20-
protected static byte CONNECT = (byte) 0b00000001;
21-
protected static byte SEND = (byte) 0b00000010;
22-
protected static byte RECEIVE = (byte) 0b00000100;
23-
protected static byte ISSUE = (byte) 0b00001000;
24-
protected static byte MINE = (byte) 0b00010000;
25-
protected static byte ACTIVATE = (byte) 0b00100000;
26-
protected static byte ADMIN = (byte) 0b01000000;
19+
protected static int CONNECT = 1;
20+
protected static int SEND = 2;
21+
protected static int RECEIVE = 4;
22+
protected static int ISSUE = 8;
23+
protected static int MINE = 16;
24+
protected static int ACTIVATE = 32;
25+
protected static int ADMIN = 64;
26+
protected static int CREATE = 128;
2727

2828
protected static int WALLET = CONNECT | SEND | RECEIVE;
2929
protected static int WALLET_ISSUE = WALLET | ISSUE;

src/multichain/test/command/GrantCommandTest.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,31 @@ public static void main(String[] args) {
5656
// BlockChain TestCommand has to be created and started before
5757
multiChainCommand = new MultiChainCommand("localhost", "6824", "multichainrpc",
5858
"73oYQWzx45hossFPPWUgicpLvHhsD8PempYxnSF6bnY9");
59-
59+
60+
int value1 = multiChainCommand.getGrantCommand().CREATE;
61+
int value2 = multiChainCommand.getGrantCommand().CONNECT;
62+
int value3 = multiChainCommand.getGrantCommand().ADMIN;
63+
64+
System.out.println("---");
65+
int value = value1;
66+
System.out.println(value);
67+
System.out.println(value & value1);
68+
System.out.println(value & value2);
69+
System.out.println(value & value3);
70+
value = value | value2;
71+
System.out.println("---");
72+
System.out.println(value);
73+
System.out.println(value & value1);
74+
System.out.println(value & value2);
75+
System.out.println(value & value3);
76+
value = value | value3;
77+
System.out.println("---");
78+
System.out.println(value);
79+
System.out.println(value & value1);
80+
System.out.println(value & value2);
81+
System.out.println(value & value3);
82+
System.out.println("---");
83+
6084
testlistPermissions();
6185

6286
System.out.println("--- End of AddressCommandTest ---");

0 commit comments

Comments
 (0)