1+ package multichain .command ;
2+
3+ import multichain .command .builders .QueryBuilderMessaging ;
4+ import multichain .object .Address ;
5+
6+ public class MessagingCommand extends QueryBuilderMessaging {
7+
8+ public MessagingCommand (String ip , String port , String login , String password ) {
9+ initialize (ip , port , login , password );
10+ }
11+
12+ /**
13+ * Verifies that message was approved by the owner of address by checking the
14+ * base64-encoded digital signature provided.
15+ *
16+ * @param address
17+ * (Address, required) The owner address
18+ * @param signature
19+ * (String, required) The base64-encoded digital signature to check
20+ * @param message
21+ * (String, required) The message
22+ * @return (Boolean) True if the message is approved, else false
23+ * @throws MultichainException
24+ */
25+ public final boolean verifyMessage (Address address , String signature , String message ) throws MultichainException {
26+ return verifyMessage (address .getAddress (), signature , message );
27+ }
28+
29+ /**
30+ * {@link #verifyMessage(Address, String, String)} with address in format string
31+ *
32+ * @param address
33+ * (String, required) The owner address
34+ * @param signature
35+ * (String, required) The base64-encoded digital signature to check
36+ * @param message
37+ * (String, required) The message
38+ * @return (Boolean) True if the message is approved, else false
39+ * @throws MultichainException
40+ */
41+ public final boolean verifyMessage (String address , String signature , String message ) throws MultichainException {
42+ Object objectBool = executeVerifyMessage (address , signature , message );
43+ return (boolean ) objectBool ;
44+ }
45+
46+ /**
47+ * Returns a base64-encoded digital signature which proves that message was
48+ * approved by the owner of the address or any other private key given in
49+ * addressORPrivateKey.
50+ *
51+ * @param addressORPrivateKey
52+ * (Address, required) The address or the private key (which must
53+ * belong to this wallet)
54+ * @param message
55+ * (String, required) The message to approved
56+ * @return (String) The base64-encoded digital signature
57+ * @throws MultichainException
58+ */
59+
60+ public final String signMessage (Address addressORPrivateKey , String message ) throws MultichainException {
61+ return signMessage (addressORPrivateKey .getAddress (), message );
62+ }
63+
64+ /**
65+ * {@link #signMessage(Address, String)} with addressORPrivateKey in format
66+ * string
67+ *
68+ * @param addressORPrivateKey
69+ * (String, required) The address or the private key (which must
70+ * belong to this wallet)
71+ * @param message
72+ * (String, required) The message to approved
73+ * @return (String) The base64-encoded digital signature
74+ * @throws MultichainException
75+ */
76+ public final String signMessage (String addressORPrivateKey , String message ) throws MultichainException {
77+ Object objectSign = executeSignMessage (addressORPrivateKey , message );
78+ return (String ) objectSign ;
79+ }
80+ }
0 commit comments