-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Emotional-Wellbeing/master
Align master and dev branches
- Loading branch information
Showing
103 changed files
with
17,221 additions
and
1,978 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
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
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
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
5 changes: 0 additions & 5 deletions
5
app/src/main/java/es/upm/bienestaremocional/data/AppConstants.kt
This file was deleted.
Oops, something went wrong.
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
10 changes: 10 additions & 0 deletions
10
app/src/main/java/es/upm/bienestaremocional/data/RemoteConstants.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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package es.upm.bienestaremocional.data | ||
|
||
import androidx.work.BackoffPolicy | ||
import androidx.work.WorkRequest | ||
|
||
object RemoteConstants { | ||
const val SERVER_URL = "http://nispero.etsisi.upm.es:5000" | ||
val BACKOFF_CRITERIA = BackoffPolicy.EXPONENTIAL | ||
const val BACKOFF_INITIAL_DELAY = WorkRequest.DEFAULT_BACKOFF_DELAY_MILLIS | ||
} |
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
36 changes: 36 additions & 0 deletions
36
app/src/main/java/es/upm/bienestaremocional/data/crypto/SecretKey.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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package es.upm.bienestaremocional.data.crypto | ||
|
||
import android.security.keystore.KeyGenParameterSpec | ||
import android.security.keystore.KeyProperties | ||
import java.security.KeyStore | ||
import javax.crypto.KeyGenerator | ||
import javax.crypto.SecretKey | ||
|
||
object SecretKey { | ||
private const val secretKeyAlias = "database_key" | ||
private const val provider = "AndroidKeyStore" | ||
private const val algorithm = KeyProperties.KEY_ALGORITHM_AES | ||
private const val cipherMode = KeyProperties.BLOCK_MODE_GCM | ||
|
||
private fun generateSecretKey(): SecretKey { | ||
val keyGenerator = KeyGenerator.getInstance(algorithm, provider) | ||
val spec = KeyGenParameterSpec | ||
.Builder(secretKeyAlias, KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT) | ||
.setBlockModes(cipherMode) | ||
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE) | ||
.build() | ||
|
||
keyGenerator.init(spec) | ||
return keyGenerator.generateKey() | ||
} | ||
|
||
fun getSecretKey(): SecretKey { | ||
// Get keyStore instance, no parameters at load stage are needed | ||
val keyStore = KeyStore.getInstance(provider).apply { load(null) } | ||
// Get key entry | ||
val secretKeyEntry = keyStore.getEntry(secretKeyAlias, null) as KeyStore.SecretKeyEntry? | ||
// Get the key itself or if is null generate it | ||
return secretKeyEntry?.secretKey ?: generateSecretKey() | ||
} | ||
} | ||
|
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
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
Oops, something went wrong.