Skip to content

Commit 9cf1e51

Browse files
committed
E2E sender verification over more than one hub is buggy. Working on it.
1 parent 1976c58 commit 9cf1e51

29 files changed

Lines changed: 332 additions & 92 deletions

libs/ASAPJava.jar

1.15 KB
Binary file not shown.

libs/SharkPKI.jar

1.99 KB
Binary file not shown.

libs/SharkPeer.jar

968 Bytes
Binary file not shown.

src/net/sharksystem/cmdline/sharkmessengerUI/ProductionUI.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
import java.io.PrintStream;
77

88
import net.sharksystem.SharkException;
9-
import net.sharksystem.cmdline.sharkmessengerUI.commands.basics.UICommandDestroyPeer;
9+
import net.sharksystem.cmdline.sharkmessengerUI.commands.basics.*;
1010
import net.sharksystem.cmdline.sharkmessengerUI.commands.encounter.UICommandShowEncounter;
11-
import net.sharksystem.cmdline.sharkmessengerUI.commands.extendedMessenger.*;
12-
import net.sharksystem.cmdline.sharkmessengerUI.commands.basics.UICommandExit;
11+
import net.sharksystem.cmdline.sharkmessengerUI.commands.messenger.*;
1312
import net.sharksystem.cmdline.sharkmessengerUI.commands.hubaccess.*;
1413
import net.sharksystem.cmdline.sharkmessengerUI.commands.hubmanagement.UICommandListHub;
1514
import net.sharksystem.cmdline.sharkmessengerUI.commands.hubmanagement.UICommandStartHub;
@@ -113,10 +112,16 @@ public static void main(String[] args) throws SharkException, IOException {
113112
new SharkMessengerApp(peerName, syncWithOthersInSeconds, System.out, System.err);
114113

115114
// basics
115+
smUI.addCommand(new UICommandWait(sharkMessengerApp, smUI, "wait", false));
116+
smUI.addCommand(new UICommandEcho(sharkMessengerApp, smUI, "echo", false));
117+
smUI.addCommand(new UICommandMarkStep(sharkMessengerApp, smUI, "markstep", false));
116118
smUI.addCommand(new UICommandExit(sharkMessengerApp, smUI, "exit", false));
117119
smUI.addCommand(new UICommandDestroyPeer(sharkMessengerApp, smUI, "destroyPeer", false));
118120

119121
// simple messenger
122+
smUI.addCommand(new UICommandListChannels(sharkMessengerApp, smUI, "lsChannel", true));
123+
smUI.addCommand(new UICommandCreateChannel(sharkMessengerApp, smUI, "mkChannel", true));
124+
smUI.addCommand(new UICommandRemoveChannelByIndex(sharkMessengerApp, smUI, "rmChannel", true));
120125
smUI.addCommand(new UICommandSendMessageExtended(sharkMessengerApp, smUI, "sendMessage", true));
121126
smUI.addCommand(new UICommandListMessages(sharkMessengerApp, smUI, "lsMessages", true));
122127

@@ -133,8 +138,7 @@ public static void main(String[] args) throws SharkException, IOException {
133138
smUI.addCommand(new UICommandListPersons(sharkMessengerApp, smUI, "lsPersons", true));
134139

135140
// PKI
136-
smUI.addCommand(new UICommandListCertificateIssuer(sharkMessengerApp, smUI, "lsCertIssuer", true));
137-
smUI.addCommand(new UICommandListCertificateIssuer(sharkMessengerApp, smUI, "lsCertSubjects", true));
141+
smUI.addCommand(new UICommandListCertificates(sharkMessengerApp, smUI, "lsCerts", true));
138142
smUI.addCommand(new UICommandShowCertificatesByIssuer(sharkMessengerApp, smUI, "certByIssuer", true));
139143
smUI.addCommand(new UICommandShowCertificatesBySubject(sharkMessengerApp, smUI, "certBySubject", true));
140144
smUI.addCommand(new UICommandShowPendingCredentials(sharkMessengerApp, smUI, "lsCredentials", true));
@@ -160,12 +164,6 @@ public static void main(String[] args) throws SharkException, IOException {
160164
smUI.addCommand(new UICommandStopHub(sharkMessengerApp, smUI, "stopHub", true));
161165
smUI.addCommand(new UICommandListHub(sharkMessengerApp, smUI, "lsHubs", true));
162166

163-
// extended messenger
164-
//smUI.addCommand(new UICommandSendMessageExtended(sharkMessengerApp, smUI, "sendMessageX", true));
165-
smUI.addCommand(new UICommandListChannels(sharkMessengerApp, smUI, "lsChannel", true));
166-
smUI.addCommand(new UICommandCreateChannel(sharkMessengerApp, smUI, "mkChannel", true));
167-
//smUI.addCommand(new UICommandSetChannelAge(sharkMessengerApp, smUI, "setChannelAge", true));
168-
smUI.addCommand(new UICommandRemoveChannelByIndex(sharkMessengerApp, smUI, "rmChannel", true));
169167

170168
smUI.printUsage();
171169
smUI.runCommandLoop();

src/net/sharksystem/cmdline/sharkmessengerUI/SharkMessengerApp.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,8 @@ public SharkMessengerApp(String peerName, int syncWithOthersInSeconds, PrintStre
7979
}
8080

8181
// set up shark components
82-
83-
// produce KeyStore
84-
InMemoASAPKeyStore keyStore = new InMemoASAPKeyStore(this.peerID);
85-
keyStore.setMementoTarget(this.appSettings, KEYSTORE_MEMENTO_KEY);
86-
try {
87-
keyStore.restoreFromMemento(this.appSettings.getExtra(KEYSTORE_MEMENTO_KEY));
88-
this.tellUI("restored keystore from memento");
89-
}
90-
catch(SharkException se) {
91-
// no memento for key store - must be new
92-
this.tellUI("no keystore memento - must be new");
93-
}
94-
9582
// get PKI factory
96-
SharkPKIComponentFactory pkiComponentFactory = new SharkPKIComponentFactory(keyStore);
83+
SharkPKIComponentFactory pkiComponentFactory = new SharkPKIComponentFactory();
9784

9885
// tell peer
9986
this.sharkPeerFS.addComponent(pkiComponentFactory, SharkPKIComponent.class);

src/net/sharksystem/cmdline/sharkmessengerUI/SharkMessengerUI.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,28 @@ public void printUsage() {
285285
*/
286286
public void runCommandLoop() {
287287
boolean running = true;
288+
String commandsBuffer = null;
288289
while (running) {
289290
try {
290-
this.outStream.println();
291-
this.outStream.print("Run a command by entering its name from the list above:");
291+
String userInputString;
292+
if(commandsBuffer == null) {
293+
this.outStream.println();
294+
this.outStream.print("Enter a (comma separated) command (list) and press ENTER > ");
295+
296+
userInputString = this.bufferedReader.readLine();
297+
} else {
298+
userInputString = commandsBuffer;
299+
}
300+
301+
int indexComma = userInputString.indexOf(",");
302+
if(indexComma != -1) {
303+
commandsBuffer = userInputString.substring(indexComma+1).trim();
304+
if(commandsBuffer.length() == 0) commandsBuffer = null;
305+
userInputString = userInputString.substring(0, indexComma);
306+
} else {
307+
commandsBuffer = null;
308+
}
292309

293-
String userInputString = this.bufferedReader.readLine();
294-
this.outStream.println("> " + userInputString);
295310

296311
if (userInputString != null) {
297312
this.handleUserInput(userInputString);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package net.sharksystem.cmdline.sharkmessengerUI.commands.basics;
2+
3+
import net.sharksystem.cmdline.sharkmessengerUI.SharkMessengerApp;
4+
import net.sharksystem.cmdline.sharkmessengerUI.SharkMessengerUI;
5+
import net.sharksystem.cmdline.sharkmessengerUI.UICommand;
6+
import net.sharksystem.cmdline.sharkmessengerUI.commands.helper.AbstractCommandWithSingleString;
7+
8+
public class UICommandEcho extends AbstractCommandWithSingleString {
9+
public UICommandEcho(SharkMessengerApp sharkMessengerApp, SharkMessengerUI smUI, String echo, boolean b) {
10+
super(sharkMessengerApp, smUI, echo, b);
11+
}
12+
13+
@Override
14+
protected void execute() throws Exception {
15+
this.getSharkMessengerApp().tellUI(this.getStringArgument());
16+
}
17+
18+
@Override
19+
public String getDescription() {
20+
return "echo command";
21+
}
22+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package net.sharksystem.cmdline.sharkmessengerUI.commands.basics;
2+
3+
import net.sharksystem.cmdline.sharkmessengerUI.SharkMessengerApp;
4+
import net.sharksystem.cmdline.sharkmessengerUI.SharkMessengerUI;
5+
import net.sharksystem.cmdline.sharkmessengerUI.commands.helper.AbstractCommandWithSingleString;
6+
7+
public class UICommandMarkStep extends AbstractCommandWithSingleString {
8+
public UICommandMarkStep(SharkMessengerApp sharkMessengerApp, SharkMessengerUI smUI, String echo, boolean b) {
9+
super(sharkMessengerApp, smUI, echo, b);
10+
}
11+
12+
@Override
13+
protected void execute() throws Exception {
14+
StringBuilder sb = new StringBuilder();
15+
sb.append("***********************************************************************\n");
16+
sb.append(" step: ");
17+
sb.append(this.getStringArgument());
18+
sb.append("\n");
19+
sb.append("***********************************************************************\n");
20+
this.getSharkMessengerApp().tellUI(sb.toString());
21+
int millis = 500;
22+
this.getSharkMessengerApp().tellUI("wait " + millis);
23+
Thread.sleep(millis);
24+
}
25+
26+
@Override
27+
public String getDescription() {
28+
return "echo command";
29+
}
30+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package net.sharksystem.cmdline.sharkmessengerUI.commands.basics;
2+
3+
import net.sharksystem.cmdline.sharkmessengerUI.SharkMessengerApp;
4+
import net.sharksystem.cmdline.sharkmessengerUI.SharkMessengerUI;
5+
import net.sharksystem.cmdline.sharkmessengerUI.UICommand;
6+
import net.sharksystem.cmdline.sharkmessengerUI.commands.helper.AbstractCommandWithSingleInteger;
7+
8+
public class UICommandWait extends AbstractCommandWithSingleInteger {
9+
public UICommandWait(SharkMessengerApp sharkMessengerApp, SharkMessengerUI smUI, String wait, boolean b) {
10+
super(sharkMessengerApp, smUI, wait, b);
11+
}
12+
13+
@Override
14+
protected void execute() throws Exception {
15+
this.getSharkMessengerApp().tellUI("wait " + this.getIntegerArgument() + " ms ...");
16+
Thread.sleep(this.getIntegerArgument());
17+
this.getSharkMessengerApp().tellUI("resume");
18+
}
19+
20+
@Override
21+
public String getDescription() {
22+
return "waits a milliseconds";
23+
}
24+
}

src/net/sharksystem/cmdline/sharkmessengerUI/commands/helper/AbstractCommandWithSingleString.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,16 @@ protected boolean handleArguments(List<String> arguments) {
3535
if (arguments.size() < 1) {
3636
if(this.optional) return true;
3737
else this.getSharkMessengerApp().tellUI("string argument required");
38-
} else {
39-
boolean isParsable = this.stringArgument.tryParse(arguments.get(0));
40-
if (!isParsable) {
41-
if(this.optional) return true;
42-
System.err.println("failed to parse string value" + arguments.get(0));
43-
}
38+
return false;
4439
}
45-
return false;
40+
41+
boolean isParsable = this.stringArgument.tryParse(arguments.get(0));
42+
if (!isParsable) {
43+
System.err.println("failed to parse string value" + arguments.get(0));
44+
return false;
45+
}
46+
47+
return true;
4648
}
4749

4850
protected String getStringArgument() {

0 commit comments

Comments
 (0)