aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/DatabaseController.kt
diff options
context:
space:
mode:
authorMarvin Borner2019-06-20 22:26:23 +0200
committerMarvin Borner2019-06-20 22:26:23 +0200
commit5fce9f53c4c2cfb41926d273b86313478aed0664 (patch)
tree53173c84e2a126d2bc655ecd11090ee80d5a840f /src/main/kotlin/DatabaseController.kt
parent8cd0aeb5af65d771d1952a37a6cf7fd457796bf2 (diff)
Fixed decrypting encoding bugs
Co-authored-by: LarsVomMars <lars@kroenner.eu>
Diffstat (limited to 'src/main/kotlin/DatabaseController.kt')
-rw-r--r--src/main/kotlin/DatabaseController.kt19
1 files changed, 2 insertions, 17 deletions
diff --git a/src/main/kotlin/DatabaseController.kt b/src/main/kotlin/DatabaseController.kt
index d60f278..5316bb0 100644
--- a/src/main/kotlin/DatabaseController.kt
+++ b/src/main/kotlin/DatabaseController.kt
@@ -25,7 +25,6 @@ class DatabaseController {
val userId = integer("userId").references(UserData.id)
val accessId = varchar("accessId", 64).uniqueIndex()
val isShared = bool("isShared").default(false)
- val encryptIV = binary("iv", 16) // empty if directory
}
/**
@@ -317,7 +316,7 @@ class DatabaseController {
/**
* Adds the uploaded file to the database
*/
- fun addFile(fileLocation: String, usersId: Int, isDirectoryBool: Boolean = false, iv: ByteArray = ByteArray(16)): Boolean {
+ fun addFile(fileLocation: String, usersId: Int, isDirectoryBool: Boolean = false): Boolean {
return transaction {
try {
if (FileLocation.select { (FileLocation.path eq fileLocation) and (FileLocation.userId eq usersId) }.empty()) {
@@ -326,7 +325,6 @@ class DatabaseController {
it[userId] = usersId
it[accessId] = generateRandomString()
it[isDirectory] = isDirectoryBool
- it[encryptIV] = iv
}
true
} else {
@@ -355,19 +353,6 @@ class DatabaseController {
}
/**
- * Returns IV of given file
- */
- fun getFileIV(fileLocation: String, userId: Int): ByteArray {
- return transaction {
- try {
- FileLocation.select { (FileLocation.path eq fileLocation) and (FileLocation.userId eq userId) }.map { it[FileLocation.encryptIV] }[0]
- } catch (err: Exception) {
- ByteArray(16)
- }
- }
- }
-
- /**
* Returns the accessId of the given file
*/
fun getAccessId(fileLocation: String, userId: Int): String {
@@ -519,7 +504,7 @@ class DatabaseController {
}
}
-data class ReturnFileData (
+data class ReturnFileData(
val userId: Int,
val fileLocation: String,
val isDirectory: Boolean