WT 1.1.14 SSL
This commit is contained in:
parent
e20ec5c222
commit
8048a74a50
@ -8,8 +8,7 @@
|
|||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<application
|
<application
|
||||||
android:name="io.flutter.app.FlutterApplication"
|
android:name="io.flutter.app.FlutterApplication"
|
||||||
android:label="WorkoutTest"
|
android:label="WorkoutTest"
|
||||||
android:usesCleartextTraffic="true"
|
|
||||||
android:icon="@mipmap/launcher_icon">
|
android:icon="@mipmap/launcher_icon">
|
||||||
<activity
|
<activity
|
||||||
android:name="com.aitrainer.aitrainer_app.MainActivity"
|
android:name="com.aitrainer.aitrainer_app.MainActivity"
|
||||||
|
BIN
asset/data/aitrainer_server.crt
Executable file
BIN
asset/data/aitrainer_server.crt
Executable file
Binary file not shown.
29
asset/data/aitrainer_server.crt.pem
Executable file
29
asset/data/aitrainer_server.crt.pem
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
Bag Attributes
|
||||||
|
friendlyName: aitrainer_server
|
||||||
|
localKeyID: 54 69 6D 65 20 31 36 32 30 36 36 31 32 32 39 36 33 32
|
||||||
|
subject=C = HU, ST = Budapest, L = Budapest, O = BossTech, OU = WorkoutTest, CN = Tibor Bossanyi
|
||||||
|
|
||||||
|
issuer=C = HU, ST = Budapest, L = Budapest, O = BossTech, OU = WorkoutTest, CN = Tibor Bossanyi
|
||||||
|
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIDjjCCAnagAwIBAgIJALlpTOV3rXy/MA0GCSqGSIb3DQEBCwUAMHUxCzAJBgNV
|
||||||
|
BAYTAkhVMREwDwYDVQQIEwhCdWRhcGVzdDERMA8GA1UEBxMIQnVkYXBlc3QxETAP
|
||||||
|
BgNVBAoTCEJvc3NUZWNoMRQwEgYDVQQLEwtXb3Jrb3V0VGVzdDEXMBUGA1UEAxMO
|
||||||
|
VGlib3IgQm9zc2FueWkwHhcNMjEwNTEwMTU0MDI5WhcNMzEwNTA4MTU0MDI5WjB1
|
||||||
|
MQswCQYDVQQGEwJIVTERMA8GA1UECBMIQnVkYXBlc3QxETAPBgNVBAcTCEJ1ZGFw
|
||||||
|
ZXN0MREwDwYDVQQKEwhCb3NzVGVjaDEUMBIGA1UECxMLV29ya291dFRlc3QxFzAV
|
||||||
|
BgNVBAMTDlRpYm9yIEJvc3NhbnlpMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
|
||||||
|
CgKCAQEAgeODijixJi3OLYqWArn2AEf+/S+G/MTxkF7wUCk2bEH+X93PFsXON/5L
|
||||||
|
LAmRa4e6kxayF2VREP98+XH6ptcnCzoYaKgPbOHlNelz7ti/1mzU4b26f+Fl/+aR
|
||||||
|
CTBic0Rc4tGB56D4+osU51oHKwiRjWxkYtKMDAuB7NCvpvXvNu4Yu9syShXIfE+l
|
||||||
|
Db38zCRcpRRxwuJSskz75aiot1xAae92aYZLylksPw30L31MygIMS0CV7bfAopvk
|
||||||
|
EkJ/0yCWjgss4X5uOqQ89EpHkkWsTa8L+GnGhSfq1+mM4ekk8hMGd73z6FIuJOAp
|
||||||
|
ecFK2gumwTUeuS8+nixqrqD+aROsqQIDAQABoyEwHzAdBgNVHQ4EFgQUjMmaF1hE
|
||||||
|
dDgFmi0D5/7fDqV/+DIwDQYJKoZIhvcNAQELBQADggEBAEiENU21912kZ//Dp070
|
||||||
|
0f6Z/S9kC5sDekbAEHfqBscBBusi4ALyZdQrc9YnHJmOP3aoPdsatoTiy8Bdvp2u
|
||||||
|
pkzMig9pMRZV6SoyOKjLKneIpkd+J9RoNjwGs/3ROqFTHKFIi1+Whas23VXREsXM
|
||||||
|
65PyRzmo8aPC0qyQPoXGf0I3JcxDsE1853ezruxqDpSNlRMcRaz7tOIgD2HWmnbo
|
||||||
|
Sq/B7QhUzTk8wTIFTXvIV3d5NRogdVPq40cHLZsZ159iDDpIIVgBomS+kREKwRh9
|
||||||
|
IKRqdGyfhnb0iu+54EJiAhnVeHqCkpiFKf7FP0s+dbo1/gN6s9fuXxviv3YRRFiy
|
||||||
|
3RI=
|
||||||
|
-----END CERTIFICATE-----
|
@ -135,9 +135,9 @@ PODS:
|
|||||||
- Flutter
|
- Flutter
|
||||||
- flutter_secure_storage (3.3.1):
|
- flutter_secure_storage (3.3.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
- flutter_uxcam (1.3.2):
|
- flutter_uxcam (2.0.0-beta.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
- UXCam (~> 3.3.3)
|
- UXCam (~> 3.3.4)
|
||||||
- FMDB (2.7.5):
|
- FMDB (2.7.5):
|
||||||
- FMDB/standard (= 2.7.5)
|
- FMDB/standard (= 2.7.5)
|
||||||
- FMDB/standard (2.7.5)
|
- FMDB/standard (2.7.5)
|
||||||
@ -367,7 +367,7 @@ SPEC CHECKSUMS:
|
|||||||
flutter_facebook_auth: 4b170c07b7fce791497093fcc3f134fb215f3f07
|
flutter_facebook_auth: 4b170c07b7fce791497093fcc3f134fb215f3f07
|
||||||
flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743
|
flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743
|
||||||
flutter_secure_storage: 7953c38a04c3fdbb00571bcd87d8e3b5ceb9daec
|
flutter_secure_storage: 7953c38a04c3fdbb00571bcd87d8e3b5ceb9daec
|
||||||
flutter_uxcam: 87dd981feb200bc81a2f062edb5ca2d16dae595a
|
flutter_uxcam: ab8e5d3954eb448febd581375e2622e9eecb1066
|
||||||
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
|
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
|
||||||
google_sign_in: 6bd214b9c154f881422f5fe27b66aaa7bbd580cc
|
google_sign_in: 6bd214b9c154f881422f5fe27b66aaa7bbd580cc
|
||||||
GoogleAppMeasurement: fd19169c3034975cb934e865e5667bfdce59df7f
|
GoogleAppMeasurement: fd19169c3034975cb934e865e5667bfdce59df7f
|
||||||
|
@ -104,7 +104,9 @@ class Cache with Logging {
|
|||||||
static final String activeExercisePlanDateKey = "active_exercise_plan_date";
|
static final String activeExercisePlanDateKey = "active_exercise_plan_date";
|
||||||
static final String activeExercisePlanDetailsKey = "active_exercise_details_plan";
|
static final String activeExercisePlanDetailsKey = "active_exercise_details_plan";
|
||||||
|
|
||||||
static String baseUrl = 'http://aitrainer.info:8888/api/';
|
static String baseUrlLive = 'https://aitrainer.info:8943/api/';
|
||||||
|
static String baseUrlTest = 'https://aitrainer.info:8843/api/';
|
||||||
|
late String baseUrl;
|
||||||
static final String mediaUrl = 'https://aitrainer.info:4343/media/';
|
static final String mediaUrl = 'https://aitrainer.info:4343/media/';
|
||||||
static final String username = 'bosi';
|
static final String username = 'bosi';
|
||||||
static final String password = 'andio2009';
|
static final String password = 'andio2009';
|
||||||
@ -171,7 +173,7 @@ class Cache with Logging {
|
|||||||
String testEnv = EnvironmentConfig.test_env;
|
String testEnv = EnvironmentConfig.test_env;
|
||||||
this.testEnvironment = testEnv;
|
this.testEnvironment = testEnv;
|
||||||
if (testEnv == "1") {
|
if (testEnv == "1") {
|
||||||
baseUrl = 'http://aitrainer.app:8899/api/';
|
baseUrl = baseUrlTest;
|
||||||
liveServer = false;
|
liveServer = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +183,7 @@ class Cache with Logging {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setTestBaseUrl() {
|
void setTestBaseUrl() {
|
||||||
baseUrl = 'http://aitrainer.app:8899/api/';
|
baseUrl = baseUrlTest;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getAuthToken() {
|
String getAuthToken() {
|
||||||
@ -288,22 +290,22 @@ class Cache with Logging {
|
|||||||
|
|
||||||
void setServerAddress(SharedPreferences prefs) {
|
void setServerAddress(SharedPreferences prefs) {
|
||||||
if (this.testEnvironment == "1") {
|
if (this.testEnvironment == "1") {
|
||||||
baseUrl = 'http://aitrainer.app:8899/api/';
|
baseUrl = baseUrlTest;
|
||||||
print("TestEnv $baseUrl");
|
print("TestEnv $baseUrl");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final bool? live = prefs.getBool(Cache.serverKey);
|
final bool? live = prefs.getBool(Cache.serverKey);
|
||||||
if (live == null) {
|
if (live == null) {
|
||||||
baseUrl = 'http://aitrainer.app:8888/api/';
|
baseUrl = baseUrlLive;
|
||||||
print("Live Env $baseUrl");
|
print("Live Env $baseUrl");
|
||||||
liveServer = true;
|
liveServer = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
liveServer = live;
|
liveServer = live;
|
||||||
if (live) {
|
if (live) {
|
||||||
baseUrl = 'http://aitrainer.info:8888/api/';
|
baseUrl = baseUrlLive;
|
||||||
} else {
|
} else {
|
||||||
baseUrl = 'http://aitrainer.app:8899/api/';
|
baseUrl = baseUrlTest;
|
||||||
}
|
}
|
||||||
|
|
||||||
print("Env $baseUrl");
|
print("Env $baseUrl");
|
||||||
@ -331,7 +333,7 @@ class Cache with Logging {
|
|||||||
return prefs.getString(authTokenKey);
|
return prefs.getString(authTokenKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getBaseUrl() {
|
String getBaseUrl() {
|
||||||
return baseUrl;
|
return baseUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,120 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:aitrainer_app/model/result.dart';
|
||||||
import 'package:aitrainer_app/service/logging.dart';
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
import 'package:aitrainer_app/util/common.dart';
|
import 'package:aitrainer_app/util/common.dart';
|
||||||
import 'package:aitrainer_app/util/not_found_exception.dart';
|
import 'package:aitrainer_app/util/not_found_exception.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:aitrainer_app/model/cache.dart';
|
import 'package:aitrainer_app/model/cache.dart';
|
||||||
|
|
||||||
class APIClient with Common, Logging {
|
class APIClient with Common, Logging {
|
||||||
|
Future<dynamic> sendRequestToServer(dynamic model, String reqType, bool isTokenHeader, String token) async {
|
||||||
|
HttpClient client = new HttpClient();
|
||||||
|
client.badCertificateCallback = ((X509Certificate cert, String host, int port) => true);
|
||||||
|
HttpClientRequest request = await client.postUrl(Uri.parse(Cache().getBaseUrl() + reqType));
|
||||||
|
request.headers.set('Content-Type', 'application/json');
|
||||||
|
if (isTokenHeader) {
|
||||||
|
request.headers.set('Authorization', 'Bearer $token');
|
||||||
|
}
|
||||||
|
request.add(utf8.encode(jsonEncode(model)));
|
||||||
|
HttpClientResponse result = await request.close();
|
||||||
|
if (result.statusCode == 200) {
|
||||||
|
return jsonDecode(await result.transform(utf8.decoder).join());
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dynamic authenticateUser(String email, String password) async {
|
||||||
|
var url = Cache().getBaseUrl() + "authenticate";
|
||||||
|
|
||||||
|
try {
|
||||||
|
ByteData data = await rootBundle.load('asset/data/aitrainer_server.crt.pem');
|
||||||
|
SecurityContext context = SecurityContext.defaultContext;
|
||||||
|
context.setTrustedCertificatesBytes(data.buffer.asUint8List(), password: "[xxxx]");
|
||||||
|
|
||||||
|
HttpClient client = new HttpClient(); //context: context Todo provide the right certificate
|
||||||
|
client.badCertificateCallback = ((X509Certificate cert, String host, int port) {
|
||||||
|
print("Host: $host Port: $port");
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
var uri = Uri.parse(url);
|
||||||
|
final HttpClientRequest request = await client.postUrl(uri);
|
||||||
|
request.headers.set('Content-Type', 'application/json');
|
||||||
|
request.headers.set('Authorization', '1');
|
||||||
|
|
||||||
|
final body = '{"username":"$email", "password":"$password"}';
|
||||||
|
request.write(body);
|
||||||
|
HttpClientResponse result = await request.close();
|
||||||
|
if (result.statusCode != 200) {
|
||||||
|
trace("authentication response: ${result.statusCode}");
|
||||||
|
throw Exception("Network error, try again later!");
|
||||||
|
}
|
||||||
|
return jsonDecode(await result.transform(utf8.decoder).join());
|
||||||
|
} catch (exception) {
|
||||||
|
print(exception.toString());
|
||||||
|
throw Exception("Network error, try again later!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> post(String endPoint, String body) async {
|
||||||
|
final url = Cache().getBaseUrl() + endPoint;
|
||||||
|
trace(" ------------ http/post body $body - url: $url ");
|
||||||
|
String authToken = Cache().getAuthToken();
|
||||||
|
if (authToken.length == 0) {
|
||||||
|
var responseJson = await this.authenticateUser(Cache.username, Cache.password);
|
||||||
|
authToken = responseJson['token'];
|
||||||
|
Cache().authToken = authToken;
|
||||||
|
}
|
||||||
|
var uri = Uri.parse(url);
|
||||||
|
HttpClient client = new HttpClient();
|
||||||
|
client.badCertificateCallback = ((X509Certificate cert, String host, int port) => true);
|
||||||
|
final HttpClientRequest request = await client.getUrl(uri);
|
||||||
|
request.headers.set('Content-Type', 'application/json');
|
||||||
|
request.headers.set('Authorization', 'Bearer $authToken');
|
||||||
|
request.write(body);
|
||||||
|
HttpClientResponse result = await request.close();
|
||||||
|
trace(" ------------post response code: " + result.statusCode.toString());
|
||||||
|
if (result.statusCode == 200) {
|
||||||
|
return await result.transform(utf8.decoder).join();
|
||||||
|
} else if (result.statusCode == 404) {
|
||||||
|
throw NotFoundException(message: "Not Found");
|
||||||
|
} else {
|
||||||
|
throw Exception("Network Error, please try again later");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<String> get(String endPoint, String param) async {
|
Future<String> get(String endPoint, String param) async {
|
||||||
final url = Cache.getBaseUrl() + endPoint + param;
|
final url = Cache().getBaseUrl() + endPoint + param;
|
||||||
|
|
||||||
|
trace("-------- API get " + url);
|
||||||
|
String authToken = Cache().getAuthToken();
|
||||||
|
if (authToken.length == 0) {
|
||||||
|
var responseJson = await this.authenticateUser(Cache.username, Cache.password);
|
||||||
|
authToken = responseJson['token'];
|
||||||
|
Cache().authToken = authToken;
|
||||||
|
}
|
||||||
|
var uri = Uri.parse(url);
|
||||||
|
|
||||||
|
HttpClient client = new HttpClient();
|
||||||
|
client.badCertificateCallback = ((X509Certificate cert, String host, int port) => true);
|
||||||
|
final HttpClientRequest request = await client.getUrl(uri);
|
||||||
|
request.headers.set('Content-Type', 'application/json');
|
||||||
|
request.headers.set('Authorization', 'Bearer $authToken');
|
||||||
|
HttpClientResponse result = await request.close();
|
||||||
|
trace(" ------------get response code: " + result.statusCode.toString());
|
||||||
|
if (result.statusCode == 200) {
|
||||||
|
return await result.transform(utf8.decoder).join();
|
||||||
|
} else if (result.statusCode == 404) {
|
||||||
|
throw NotFoundException(message: "Not Found");
|
||||||
|
} else {
|
||||||
|
throw Exception("Network Error, please try again later");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> get0(String endPoint, String param) async {
|
||||||
|
final url = Cache().getBaseUrl() + endPoint + param;
|
||||||
|
|
||||||
trace("-------- API get " + url);
|
trace("-------- API get " + url);
|
||||||
String authToken = Cache().getAuthToken();
|
String authToken = Cache().getAuthToken();
|
||||||
@ -28,8 +135,8 @@ class APIClient with Common, Logging {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> post(String endPoint, String body) async {
|
Future<String> post0(String endPoint, String body) async {
|
||||||
final url = Cache.getBaseUrl() + endPoint;
|
final url = Cache().getBaseUrl() + endPoint;
|
||||||
trace(" ------------ http/post body $body - url: $url ");
|
trace(" ------------ http/post body $body - url: $url ");
|
||||||
String authToken = Cache().getAuthToken();
|
String authToken = Cache().getAuthToken();
|
||||||
if (authToken.length == 0) {
|
if (authToken.length == 0) {
|
||||||
@ -48,8 +155,8 @@ class APIClient with Common, Logging {
|
|||||||
return decodedResponse;
|
return decodedResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamic authenticateUser(String email, String password) async {
|
dynamic authenticateUser0(String email, String password) async {
|
||||||
var url = Cache.getBaseUrl() + "authenticate";
|
var url = Cache().getBaseUrl() + "authenticate";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final body = '{"username":"$email", "password":"$password"}';
|
final body = '{"username":"$email", "password":"$password"}';
|
||||||
@ -74,7 +181,7 @@ class APIClient with Common, Logging {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<String?> fetch(var authToken, var endPoint) async {
|
Future<String?> fetch(var authToken, var endPoint) async {
|
||||||
var url = Cache.getBaseUrl() + endPoint;
|
var url = Cache().getBaseUrl() + endPoint;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var uri = Uri.parse(url);
|
var uri = Uri.parse(url);
|
||||||
|
@ -547,7 +547,7 @@ packages:
|
|||||||
name: flutter_uxcam
|
name: flutter_uxcam
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.2"
|
version: "2.0.0-beta.1"
|
||||||
flutter_web_plugins:
|
flutter_web_plugins:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@ -608,7 +608,7 @@ packages:
|
|||||||
name: http
|
name: http
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.13.1"
|
version: "0.13.3"
|
||||||
http_multi_server:
|
http_multi_server:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||||||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||||
# Read more about iOS versioning at
|
# Read more about iOS versioning at
|
||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
version: 1.1.14+74
|
version: 1.1.14+75
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.12.0 <3.0.0"
|
sdk: ">=2.12.0 <3.0.0"
|
||||||
@ -71,7 +71,7 @@ dependencies:
|
|||||||
|
|
||||||
#smartlook: ^1.0.7
|
#smartlook: ^1.0.7
|
||||||
flurry: ^0.0.4
|
flurry: ^0.0.4
|
||||||
flutter_uxcam: ^1.3.2
|
flutter_uxcam: ^2.0.0-beta.1
|
||||||
|
|
||||||
animated_widgets: ^1.0.6
|
animated_widgets: ^1.0.6
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ dev_dependencies:
|
|||||||
build_runner:
|
build_runner:
|
||||||
|
|
||||||
|
|
||||||
http: ^0.13.1
|
http: ^0.13.3
|
||||||
intl: ^0.17.0
|
intl: ^0.17.0
|
||||||
shared_preferences: ^2.0.5
|
shared_preferences: ^2.0.5
|
||||||
|
|
||||||
@ -122,6 +122,8 @@ flutter:
|
|||||||
|
|
||||||
# To add assets to your application, add an assets section, like this:
|
# To add assets to your application, add an assets section, like this:
|
||||||
assets:
|
assets:
|
||||||
|
- asset/data/aitrainer_server.crt.pem
|
||||||
|
|
||||||
- asset/icon/gomb_kek_a-2.png
|
- asset/icon/gomb_kek_a-2.png
|
||||||
- asset/icon/gomb_kek_b.png
|
- asset/icon/gomb_kek_b.png
|
||||||
- asset/icon/gomb_lila_b.png
|
- asset/icon/gomb_lila_b.png
|
||||||
|
Loading…
Reference in New Issue
Block a user