Skip to content
This repository was archived by the owner on Apr 26, 2025. It is now read-only.

Commit be9a957

Browse files
committed
Version 1.2.0
* Update to v2 android plugin APIs * Kotlin version is out of date * Swift code version not provided Related : #4 #5 #6
1 parent b41dd3a commit be9a957

File tree

18 files changed

+161
-113
lines changed

18 files changed

+161
-113
lines changed

.packages

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Generated by pub on 2019-07-29 14:31:16.126970.
1+
# Generated by pub on 2020-03-06 11:33:51.073306.
22
collection:file:///Users/kevin.valette/Tools/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.14.11/lib/
33
flutter:file:///Users/kevin.valette/Tools/flutter/packages/flutter/lib/
4-
meta:file:///Users/kevin.valette/Tools/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.1.6/lib/
4+
meta:file:///Users/kevin.valette/Tools/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.1.8/lib/
55
sky_engine:file:///Users/kevin.valette/Tools/flutter/bin/cache/pkg/sky_engine/lib/
66
typed_data:file:///Users/kevin.valette/Tools/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6/lib/
77
vector_math:file:///Users/kevin.valette/Tools/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib/

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [1.2.0] - 06/03/2020
2+
3+
* Update to v2 android plugin APIs
4+
* Kotlin version is out of date
5+
* swift code version not provided
6+
17
## [1.1.0] - 29/07/2019
28

39
* Add compatibility with Dart2

android/build.gradle

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ group 'com.example.sslpinningplugin'
22
version '1.0-SNAPSHOT'
33

44
buildscript {
5-
ext.kotlin_version = '1.2.71'
5+
ext.kotlin_version = '1.3.21'
6+
67
repositories {
78
google()
89
jcenter()
910
}
1011

1112
dependencies {
12-
classpath 'com.android.tools.build:gradle:3.2.1'
13+
classpath 'com.android.tools.build:gradle:3.6.1'
1314
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1415
}
1516
}
@@ -32,13 +33,27 @@ android {
3233
}
3334
defaultConfig {
3435
minSdkVersion 16
35-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
36+
testInstrumentationRunner "androidx.support.test.runner.AndroidJUnitRunner"
3637
}
3738
lintOptions {
3839
disable 'InvalidPackage'
3940
}
4041
}
4142

43+
subprojects {
44+
afterEvaluate {project ->
45+
if (project.hasProperty("android")) {
46+
android {
47+
compileSdkVersion 28
48+
buildToolsVersion '29.0.2'
49+
}
50+
}
51+
}
52+
}
53+
4254
dependencies {
4355
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
56+
androidTestImplementation 'androidx.test:runner:1.2.0'
57+
androidTestImplementation 'androidx.test:rules:1.2.0'
58+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
4459
}

android/gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
org.gradle.jvmargs=-Xmx1536M
2+
android.useAndroidX=true
3+
android.enableJetifier=true

android/src/main/kotlin/com/macif/plugin/sslpinningplugin/SslPinningPlugin.kt

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.macif.plugin.sslpinningplugin
22

3-
import io.flutter.plugin.common.MethodChannel
4-
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
5-
import io.flutter.plugin.common.MethodChannel.Result
6-
import io.flutter.plugin.common.MethodCall
7-
import io.flutter.plugin.common.PluginRegistry.Registrar
3+
import android.os.Build
4+
import io.flutter.embedding.engine.plugins.FlutterPlugin;
5+
import io.flutter.plugin.common.MethodCall;
6+
import io.flutter.plugin.common.MethodChannel;
7+
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
8+
import io.flutter.plugin.common.MethodChannel.Result;
9+
import io.flutter.plugin.common.PluginRegistry.Registrar;
810

911
import javax.net.ssl.HttpsURLConnection
1012
import javax.security.cert.CertificateException
@@ -18,21 +20,24 @@ import java.security.cert.Certificate
1820
import java.security.cert.CertificateEncodingException
1921

2022
import android.os.StrictMode
23+
import androidx.annotation.RequiresApi
2124

22-
class SslPinningPlugin() : MethodCallHandler {
25+
class SslPinningPlugin() : MethodCallHandler, FlutterPlugin {
2326

2427
companion object {
2528
@JvmStatic
2629
fun registerWith(registrar: Registrar): Unit {
2730

31+
val instance = SslPinningPlugin()
2832
val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
2933
StrictMode.setThreadPolicy(policy)
3034

3135
val channel = MethodChannel(registrar.messenger(), "ssl_pinning_plugin")
32-
channel.setMethodCallHandler(SslPinningPlugin())
36+
channel.setMethodCallHandler(instance)
3337
}
3438
}
3539

40+
@RequiresApi(Build.VERSION_CODES.N)
3641
override fun onMethodCall(call: MethodCall, result: Result): Unit {
3742
try {
3843
when (call.method) {
@@ -45,6 +50,7 @@ class SslPinningPlugin() : MethodCallHandler {
4550

4651
}
4752

53+
@RequiresApi(Build.VERSION_CODES.N)
4854
@Throws(ParseException::class)
4955
private fun handleCheckEvent(call: MethodCall, result: Result) {
5056

@@ -63,11 +69,13 @@ class SslPinningPlugin() : MethodCallHandler {
6369

6470
}
6571

72+
@RequiresApi(Build.VERSION_CODES.N)
6673
fun checkConnexion(serverURL: String, allowedFingerprints: List<String>, httpHeaderArgs: Map<String, String>, timeout: Int, type: String): Boolean {
6774
val sha: String = this.getFingerprint(serverURL, timeout, httpHeaderArgs, type)
6875
return allowedFingerprints.map { fp -> fp.toUpperCase().replace("\\s".toRegex(), "") }.contains(sha)
6976
}
7077

78+
@RequiresApi(Build.VERSION_CODES.N)
7179
@Throws(IOException::class, NoSuchAlgorithmException::class, CertificateException::class, CertificateEncodingException::class)
7280
private fun getFingerprint(httpsURL: String, connectTimeout: Int, httpHeaderArgs: Map<String, String>, type: String): String {
7381

@@ -89,4 +97,8 @@ class SslPinningPlugin() : MethodCallHandler {
8997
.digest(input)
9098
.map { String.format("%02X", it) }
9199
.joinToString(separator = "")
100+
101+
override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {}
102+
103+
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {}
92104
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"ssl_pinning_plugin","dependencies":[]}]}

example/android/app/build.gradle

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
2626
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2727

2828
android {
29-
compileSdkVersion 27
29+
compileSdkVersion 28
3030

3131
sourceSets {
3232
main.java.srcDirs += 'src/main/kotlin'
@@ -40,15 +40,14 @@ android {
4040
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
4141
applicationId "com.example.sslpinningpluginexample"
4242
minSdkVersion 16
43-
targetSdkVersion 27
43+
targetSdkVersion 28
4444
versionCode flutterVersionCode.toInteger()
4545
versionName flutterVersionName
46-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
46+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
4747
}
4848

4949
buildTypes {
5050
release {
51-
// TODO: Add your own signing config for the release build.
5251
// Signing with the debug keys for now, so `flutter run --release` works.
5352
signingConfig signingConfigs.debug
5453
}
@@ -59,9 +58,20 @@ flutter {
5958
source '../..'
6059
}
6160

61+
subprojects {
62+
afterEvaluate {project ->
63+
if (project.hasProperty("android")) {
64+
android {
65+
compileSdkVersion 28
66+
buildToolsVersion '29.0.2'
67+
}
68+
}
69+
}
70+
}
71+
6272
dependencies {
6373
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
6474
testImplementation 'junit:junit:4.12'
65-
androidTestImplementation 'com.android.support.test:runner:1.0.2'
66-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
75+
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
76+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
6777
}

example/android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
buildscript {
2-
ext.kotlin_version = '1.2.71'
2+
ext.kotlin_version = '1.3.21'
33
repositories {
44
google()
55
jcenter()
66
}
77

88
dependencies {
9-
classpath 'com.android.tools.build:gradle:3.2.1'
9+
classpath 'com.android.tools.build:gradle:3.6.1'
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1111
}
1212
}

example/android/gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
org.gradle.jvmargs=-Xmx1536M
2+
android.useAndroidX=true
3+
android.enableJetifier=true
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Fri Jun 23 08:50:38 CEST 2017
1+
#Fri Mar 06 11:48:34 CET 2020
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

0 commit comments

Comments
 (0)