This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store cnPublicKey for created trace locations
- Loading branch information
1 parent
7df0494
commit a8cce8f
Showing
4 changed files
with
30 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 20 additions & 3 deletions
23
...n-App/src/main/java/de/rki/coronawarnapp/eventregistration/events/TraceLocationCreator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,36 @@ | ||
package de.rki.coronawarnapp.eventregistration.events | ||
|
||
import de.rki.coronawarnapp.environment.EnvironmentSetup | ||
import de.rki.coronawarnapp.eventregistration.checkins.qrcode.TraceLocation | ||
import de.rki.coronawarnapp.eventregistration.checkins.qrcode.toTraceLocation | ||
import de.rki.coronawarnapp.eventregistration.storage.repo.TraceLocationRepository | ||
import okio.ByteString.Companion.toByteString | ||
import java.security.SecureRandom | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class TraceLocationCreator @Inject constructor( | ||
private val repository: TraceLocationRepository, | ||
private val secureRandom: SecureRandom | ||
private val secureRandom: SecureRandom, | ||
private val environmentSetup: EnvironmentSetup | ||
) { | ||
|
||
suspend fun createTraceLocation(traceLocationUserInput: TraceLocationUserInput): TraceLocation { | ||
return repository.addTraceLocation(traceLocationUserInput.toTraceLocation(secureRandom)) | ||
val cnPublicKey = environmentSetup.crowdNotifierPublicKey | ||
val traceLocation = traceLocationUserInput.toTraceLocation(secureRandom, cnPublicKey) | ||
return repository.addTraceLocation(traceLocation) | ||
} | ||
} | ||
|
||
fun TraceLocationUserInput.toTraceLocation(secureRandom: SecureRandom, cnPublicKey: String) = TraceLocation( | ||
type = type, | ||
description = description, | ||
address = address, | ||
startDate = startDate, | ||
endDate = endDate, | ||
defaultCheckInLengthInMinutes = defaultCheckInLengthInMinutes, | ||
// cryptographic seed is a sequence of 16 random bytes | ||
cryptographicSeed = ByteArray(16).apply { secureRandom.nextBytes(this) }.toByteString(), | ||
cnPublicKey = cnPublicKey | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters