Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add interface for detection of encrypted messages
This includes some capabilities that are not currently used by K-9 Mail, e.g. the ability to supply additional data to be inserted into the database.
- Loading branch information
Showing
21 changed files
with
217 additions
and
84 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
app/core/src/main/java/com/fsck/k9/crypto/EncryptionExtractor.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,17 @@ | ||
package com.fsck.k9.crypto | ||
|
||
import android.content.ContentValues | ||
import com.fsck.k9.mail.Message | ||
import com.fsck.k9.message.extractors.PreviewResult | ||
|
||
interface EncryptionExtractor { | ||
fun extractEncryption(message: Message): EncryptionResult? | ||
} | ||
|
||
data class EncryptionResult( | ||
val encryptionType: String, | ||
val attachmentCount: Int, | ||
val previewResult: PreviewResult = PreviewResult.encrypted(), | ||
val textForSearchIndex: String? = null, | ||
val extraContentValues: ContentValues? = null | ||
) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'org.jetbrains.kotlin.android' | ||
|
||
apply from: "${rootProject.projectDir}/gradle/plugins/checkstyle-android.gradle" | ||
apply from: "${rootProject.projectDir}/gradle/plugins/findbugs-android.gradle" | ||
|
||
dependencies { | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}" | ||
|
||
implementation project(":app:core") | ||
|
||
testImplementation "junit:junit:${versions.junit}" | ||
testImplementation "org.mockito:mockito-core:${versions.mockito}" | ||
} | ||
|
||
android { | ||
compileSdkVersion buildConfig.compileSdk | ||
buildToolsVersion buildConfig.buildTools | ||
|
||
defaultConfig { | ||
minSdkVersion buildConfig.minSdk | ||
} | ||
|
||
lintOptions { | ||
abortOnError false | ||
lintConfig file("$rootProject.projectDir/config/lint/lint.xml") | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_7 | ||
targetCompatibility JavaVersion.VERSION_1_7 | ||
} | ||
} |
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,2 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="com.fsck.k9.crypto.openpgp" /> |
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
31 changes: 31 additions & 0 deletions
31
app/crypto-openpgp/src/main/java/com/fsck/k9/crypto/openpgp/OpenPgpEncryptionExtractor.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,31 @@ | ||
package com.fsck.k9.crypto.openpgp | ||
|
||
import com.fsck.k9.crypto.EncryptionExtractor | ||
import com.fsck.k9.crypto.EncryptionResult | ||
import com.fsck.k9.mail.Message | ||
import com.fsck.k9.message.extractors.TextPartFinder | ||
|
||
class OpenPgpEncryptionExtractor internal constructor( | ||
private val encryptionDetector: EncryptionDetector | ||
) : EncryptionExtractor { | ||
|
||
override fun extractEncryption(message: Message): EncryptionResult? { | ||
return if (encryptionDetector.isEncrypted(message)) { | ||
EncryptionResult(ENCRYPTION_TYPE, 0) | ||
} else { | ||
null | ||
} | ||
} | ||
|
||
|
||
companion object { | ||
const val ENCRYPTION_TYPE = "openpgp" | ||
|
||
@JvmStatic | ||
fun newInstance(): OpenPgpEncryptionExtractor { | ||
val textPartFinder = TextPartFinder() | ||
val encryptionDetector = EncryptionDetector(textPartFinder) | ||
return OpenPgpEncryptionExtractor(encryptionDetector) | ||
} | ||
} | ||
} |
Oops, something went wrong.