Skip to content

Commit

Permalink
first simple Shark Net Channel test works
Browse files Browse the repository at this point in the history
  • Loading branch information
thsc42 committed Sep 24, 2020
1 parent ab2b3b2 commit 28b08d7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,23 @@ public static SharkNetMessage parseMessage(byte[] message, String sender, String
recipients2View = sb.toString();
}

CharSequence encrypted2View = "E2E encrypted: no";
CharSequence encrypted2View = "not E2E encrypted";
if(snMessage.encrypted()) {
encrypted2View = "E2E encrypted: yes";
encrypted2View = "is E2E encrypted";
}

// assume defaults at first
CharSequence sender2View = "from: unknown";
CharSequence content2View = "decrypted message";
CharSequence verified2View = "verified: no";
CharSequence content2View = "cannot decrypt message";
CharSequence verified2View = "not verified";
CharSequence timestamp2View = "time: unknown";
CharSequence iA2View = "iA: unknown";


// do we have an decrypted message?
if(snMessage.couldBeDecrypted()) {
byte[] snContent = snMessage.getContent();
content2View = String.valueOf(snContent);
content2View = new String(snContent);

Timestamp creationTime = snMessage.getCreationTime();
timestamp2View = DateTimeHelper.long2DateString(creationTime.getTime());
Expand All @@ -164,12 +164,12 @@ public static SharkNetMessage parseMessage(byte[] message, String sender, String
sender2View = "from: " + senderName;

if(snMessage.verified()) {
verified2View = "verified";
verified2View = "is verified";

int identityAssurance = SNChannelsComponent.getSharkNetChannelComponent().
getAsapPKI().getIdentityAssurance(snMessage.getSender());

iA2View = "iA (" + senderName + "): " + identityAssurance;
iA2View = "iA of " + senderName + " is " + identityAssurance;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.sharksystem.asap.android.apps.ASAPApplicationComponentHelper;
import net.sharksystem.asap.android.apps.ASAPComponentNotYetInitializedException;
import net.sharksystem.asap.android.apps.ASAPMessageReceivedListener;
import net.sharksystem.asap.sharknet.SNMessage;
import net.sharksystem.crypto.BasicKeyStore;
import net.sharksystem.persons.ASAPPKI;
import net.sharksystem.sharknet.android.PersonsStorage;
Expand Down Expand Up @@ -174,6 +175,13 @@ private String getLogStart() {

@Override
public CharSequence getPersonName(CharSequence peerID) throws ASAPException {
return this.personsStorage.getPersonName(peerID);
String personName = this.personsStorage.getPersonName(peerID).toString();
// replace special SN symbols
switch(personName) {
case SNMessage.ANONYMOUS: return "unknown";
case SNMessage.ANY_RECIPIENT: return "anybody";
}

return personName;
}
}

0 comments on commit 28b08d7

Please sign in to comment.