Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Felix Foertsch
Luca Android
Commits
e207f075
Commit
e207f075
authored
Dec 11, 2021
by
Lukas Gehrke
Browse files
Add first version of custom Post.
parent
e14cfdf6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Luca/app/src/main/java/de/culture4life/luca/fake/FakeManager.java
View file @
e207f075
...
...
@@ -4,7 +4,9 @@ import android.content.Context;
import
android.util.Pair
;
import
androidx.annotation.NonNull
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonParser
;
import
com.nexenio.rxkeystore.util.ByteLoggingUtil
;
import
de.culture4life.luca.BuildConfig
;
import
de.culture4life.luca.Manager
;
import
de.culture4life.luca.checkin.CheckInManager
;
import
de.culture4life.luca.crypto.AsymmetricCipherProvider
;
...
...
@@ -19,8 +21,11 @@ import de.culture4life.luca.registration.RegistrationManager;
import
de.culture4life.luca.util.SerializationUtil
;
import
io.reactivex.rxjava3.core.Completable
;
import
io.reactivex.rxjava3.core.Single
;
import
okhttp3.*
;
import
okhttp3.logging.HttpLoggingInterceptor
;
import
javax.crypto.SecretKey
;
import
java.io.IOException
;
import
java.nio.ByteBuffer
;
import
java.security.*
;
import
java.security.interfaces.ECPublicKey
;
...
...
@@ -50,6 +55,9 @@ public class FakeManager extends Manager {
this
.
checkInManager
=
checkInManager
;
}
public
static
final
MediaType
JSON
=
MediaType
.
parse
(
"application/json; charset=utf-8"
);
@Override
protected
Completable
doInitialize
(
@NonNull
Context
context
)
{
return
Completable
.
mergeArray
(
...
...
@@ -113,7 +121,8 @@ public class FakeManager extends Manager {
public
void
doFakeCheckin
()
{
// TODO: Scanner ID aus QR-Code einlesen
UUID
scannerId
=
UUID
.
fromString
(
"707a6fb6-56ba-407a-884f-5990a083214f"
);
UUID
scannerId
=
UUID
.
fromString
(
"1fe5f46d-2025-4d82-a10c-569f6fe0127e"
);
//https://localhost/webapp/1fe5f46d-2025-4d82-a10c-569f6fe0127e#e30
DeviceData
deviceData
=
new
DeviceData
();
VenueData
venueData
=
new
VenueData
(
cryptoManager
,
checkInManager
,
scannerId
,
deviceData
);
...
...
@@ -121,7 +130,12 @@ public class FakeManager extends Manager {
CheckInRequestData
checkInRequestData
=
CheckinData
.
map
(
checkinData
);
String
json
=
serializeToJson
(
checkInRequestData
).
blockingGet
();
networkManager
.
getLucaEndpointsV3
().
blockingGet
().
checkIn
(
checkInRequestData
);
JsonObject
obj
=
new
JsonParser
().
parse
(
json
).
getAsJsonObject
();
//networkManager.getLucaEndpointsV3().blockingGet().checkIn(checkInRequestData);
// OkHttpClient client = createOkHttpClient();
postCheckIn
(
json
);
}
public
static
byte
[]
generateRandomData
(
Integer
length
)
{
...
...
@@ -146,6 +160,26 @@ public class FakeManager extends Manager {
return
registrationData
;
}
private
void
postCheckIn
(
String
json
)
{
OkHttpClient
client
=
new
OkHttpClient
();
RequestBody
body
=
RequestBody
.
create
(
json
,
JSON
);
Request
request
=
new
Request
.
Builder
()
.
url
(
"https://10.0.2.2/api/v3/traces/checkin"
)
.
post
(
body
)
.
build
();
try
{
Call
call
=
client
.
newCall
(
request
);
Response
response
=
call
.
execute
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
class
CheckinData
{
...
...
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