Skip to content
Snippets Groups Projects
Commit 76937cb0 authored by Kamal Bramwell's avatar Kamal Bramwell
Browse files

Updated class factory methods

parent 720ec237
Branches
No related tags found
No related merge requests found
package io.elixxir.dapp.session.data
import android.content.Context
import androidx.annotation.RawRes
import bindings.Bindings
import io.elixxir.dapp.DappSdk.Companion.context
import io.elixxir.dapp.DappSdk.Companion.defaultDispatcher
import io.elixxir.dapp.DappSdk.Companion.logger
import io.elixxir.dapp.logger.data.Logger
import io.elixxir.dapp.model.CommonProperties
import io.elixxir.dapp.model.RetryStrategy
import io.elixxir.dapp.session.model.NdfSettings
import kotlinx.coroutines.*
......@@ -16,13 +12,11 @@ internal interface NdfDataSource {
suspend fun fetchNdf(): Ndf
}
internal class RemoteNdfDataSource constructor(
logger: Logger,
private val context: () -> Context,
private val dispatcher: CoroutineDispatcher,
internal class RemoteNdfDataSource private constructor(
properties: CommonProperties,
private val settings: NdfSettings
) : NdfDataSource,
Logger by logger,
CommonProperties by properties,
RetryStrategy by settings.retryStrategy
{
......@@ -57,15 +51,9 @@ internal class RemoteNdfDataSource constructor(
}
companion object {
internal fun newInstance(settings: NdfSettings): NdfDataSource {
return with(settings) {
RemoteNdfDataSource(
logger = logger,
context = context,
dispatcher = defaultDispatcher,
settings = this
)
}
}
internal fun newInstance(
properties: CommonProperties,
settings: NdfSettings
) = RemoteNdfDataSource(properties, settings)
}
}
\ No newline at end of file
......@@ -5,15 +5,12 @@ import android.security.keystore.KeyGenParameterSpec
import android.security.keystore.KeyInfo
import android.security.keystore.KeyProperties
import bindings.Bindings
import io.elixxir.dapp.DappSdk.Companion.defaultDispatcher
import io.elixxir.dapp.DappSdk.Companion.logger
import io.elixxir.dapp.logger.data.Logger
import io.elixxir.dapp.model.CommonProperties
import io.elixxir.dapp.preferences.KeyStorePreferences
import io.elixxir.dapp.session.model.SecureHardwareException
import io.elixxir.dapp.session.model.SessionPassword
import io.elixxir.dapp.util.fromBase64toByteArray
import io.elixxir.dapp.util.toBase64String
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.withContext
import java.security.*
import java.security.spec.MGF1ParameterSpec
......@@ -32,10 +29,9 @@ internal interface SessionKeyStore {
}
internal class DappSessionKeystore private constructor(
logger: Logger,
properties: CommonProperties,
private val preferences: KeyStorePreferences,
private val dispatcher: CoroutineDispatcher
) : SessionKeyStore, Logger by logger {
) : SessionKeyStore, CommonProperties by properties {
override suspend fun createSessionPassword(requireSecureHardware: Boolean): Result<Unit> =
withContext(dispatcher) {
......@@ -232,12 +228,7 @@ internal class DappSessionKeystore private constructor(
)
private const val PASSWORD_LENGTH = 64L
internal fun newInstance(preferences: KeyStorePreferences): DappSessionKeystore {
return DappSessionKeystore(
logger = logger,
preferences = preferences,
dispatcher = defaultDispatcher
)
}
internal fun newInstance(properties: CommonProperties, preferences: KeyStorePreferences) =
DappSessionKeystore(properties, preferences)
}
}
\ No newline at end of file
......@@ -61,8 +61,6 @@ internal class DappSessionManager private constructor(
}
companion object {
internal fun newInstance(properties: CommonProperties): SessionManager {
return DappSessionManager(properties)
}
internal fun newInstance(properties: CommonProperties) = DappSessionManager(properties)
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment