Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
EncounterBasedCommunication
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
encounters
EncounterBasedCommunication
Commits
d510f0a3
Commit
d510f0a3
authored
Jul 05, 2018
by
LIly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
1be9caac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
13 deletions
+26
-13
testapp/src/main/java/org/mpisws/testapp/simulator/SimulationClientBT.java
...java/org/mpisws/testapp/simulator/SimulationClientBT.java
+12
-6
testapp/src/main/java/org/mpisws/testapp/simulator/SimulationServerBT.java
...java/org/mpisws/testapp/simulator/SimulationServerBT.java
+14
-7
No files found.
testapp/src/main/java/org/mpisws/testapp/simulator/SimulationClientBT.java
View file @
d510f0a3
...
...
@@ -14,6 +14,7 @@ import org.mpisws.helpers.Identifier;
import
java.io.BufferedReader
;
import
java.io.ByteArrayOutputStream
;
import
java.io.DataOutputStream
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.ObjectOutputStream
;
...
...
@@ -132,17 +133,22 @@ public class SimulationClientBT {
return
;
}
PrintWriter
pw
=
new
PrintWriter
(
os
,
true
);
pw
.
println
(
serializedSecrets
+
serializedNonces
+
serializedPubKeys
+
"\r\n"
);
Log
.
d
(
TAG
,
"Lengths: "
+
serializedSecrets
.
length
()
+
", "
+
serializedNonces
.
length
()
+
","
+
serializedPubKeys
.
length
());
Log
.
d
(
TAG
,
"Sent data over socket!"
);
DataOutputStream
out
=
new
DataOutputStream
(
os
);
out
.
writeInt
(
serializedSecrets
.
length
());
out
.
writeInt
(
serializedNonces
.
length
());
out
.
writeInt
(
serializedPubKeys
.
length
());
String
toWrite
=
serializedSecrets
+
serializedNonces
+
serializedPubKeys
;
out
.
writeChars
(
toWrite
);
out
.
flush
();
Log
.
d
(
TAG
,
"Lengths: "
+
toWrite
.
length
()
+
", "
+
serializedSecrets
.
length
()
+
", "
+
serializedNonces
.
length
()
+
","
+
serializedPubKeys
.
length
());
Log
.
d
(
TAG
,
"Sent data over socket! "
+
toWrite
);
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
sock
.
getInputStream
()));
String
line
=
in
.
readLine
();
Log
.
d
(
TAG
,
"Got response: "
+
line
);
in
.
close
();
pw
.
close
();
os
.
close
();
sock
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
...
...
@@ -155,7 +161,7 @@ public class SimulationClientBT {
private
String
serializeList
(
List
<
Identifier
>
list
)
throws
IOException
{
ByteArrayOutputStream
bo
=
new
ByteArrayOutputStream
();
ObjectOutputStream
so
=
new
ObjectOutputStream
(
bo
);
so
.
writeObject
(
mSharedSecrets
);
so
.
writeObject
(
list
);
so
.
flush
();
Log
.
d
(
TAG
,
"Serialized string to "
+
bo
.
toString
());
return
bo
.
toString
();
...
...
testapp/src/main/java/org/mpisws/testapp/simulator/SimulationServerBT.java
View file @
d510f0a3
...
...
@@ -20,6 +20,7 @@ import java.io.BufferedReader;
import
java.io.ByteArrayInputStream
;
import
java.io.DataInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.ObjectInputStream
;
import
java.io.PrintStream
;
...
...
@@ -76,23 +77,28 @@ public class SimulationServerBT {
// If a connection was accepted
if
(
socket
!=
null
)
{
DataInputStream
in
=
new
DataInputStream
(
socket
.
getInputStream
());
byte
[]
messageByte
=
new
byte
[
1000
];
boolean
end
=
false
;
byte
[]
messageByte
=
new
byte
[
3000
];
String
dataString
=
""
;
int
ssLen
=
in
.
readInt
();
int
nonceLen
=
in
.
readInt
();
int
pubKeyLen
=
in
.
readInt
();
Log
.
d
(
TAG
,
ssLen
+
", "
+
nonceLen
+
", "
+
pubKeyLen
);
while
(
true
)
{
int
bytesRead
=
in
.
read
(
messageByte
);
dataString
+=
new
String
(
messageByte
,
0
,
bytesRead
);
Log
.
d
(
TAG
,
dataString
);
if
(
dataString
.
contains
(
java
.
util
.
regex
.
Pattern
.
quote
(
"\r\n"
))
)
{
if
(
dataString
.
length
()
>=
ssLen
+
nonceLen
+
pubKeyLen
)
{
break
;
}
Log
.
d
(
TAG
,
"dataString length: "
+
dataString
.
length
());
}
dataString
.
substring
(
0
,
dataString
.
indexOf
(
java
.
util
.
regex
.
Pattern
.
quote
(
"\r\n"
)
));
sharedSecrets
=
deserializeIDList
(
dataString
.
substring
(
0
,
dataString
.
length
()/
3
));
nonces
=
deserializeIDList
(
dataString
.
substring
(
dataString
.
length
()/
3
,
2
*
dataString
.
length
()/
3
));
pubKeys
=
deserializeIDList
(
dataString
.
substring
(
2
*
dataString
.
length
()/
3
));
Log
.
d
(
TAG
,
"dataString length: "
+
dataString
.
length
(
));
sharedSecrets
=
deserializeIDList
(
dataString
.
substring
(
0
,
ssLen
));
nonces
=
deserializeIDList
(
dataString
.
substring
(
ssLen
,
ssLen
+
nonceLen
));
pubKeys
=
deserializeIDList
(
dataString
.
substring
(
ssLen
+
nonceLen
,
ssLen
+
nonceLen
+
pubKeyLen
));
if
(
sharedSecrets
==
null
||
nonces
==
null
||
pubKeys
==
null
)
{
return
;
}
...
...
@@ -117,6 +123,7 @@ public class SimulationServerBT {
ByteArrayInputStream
bi
=
new
ByteArrayInputStream
(
b
);
ObjectInputStream
si
=
new
ObjectInputStream
(
bi
);
List
<
Identifier
>
obj
=
(
List
<
Identifier
>)
si
.
readObject
();
Log
.
d
(
TAG
,
"Deserialized! "
+
obj
.
size
());
return
obj
;
}
private
void
processData
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment