@regulaforensics/cordova-plugin-document-reader-api 8.1.129-nightly → 8.1.132-nightly
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/config.xml +1 -1
- package/example/package.json +2 -2
- package/package.json +1 -1
- package/plugin.xml +11 -8
- package/src/android/BluetoothUtil.kt +7 -16
- package/src/android/Config.kt +154 -120
- package/src/android/DocumentReader.kt +20 -487
- package/src/android/JSONConstructor.kt +1270 -1719
- package/src/android/Main.kt +553 -0
- package/src/android/Utils.kt +73 -160
- package/src/android/build.gradle +1 -1
- package/src/ios/RGLWConfig.h +0 -8
- package/src/ios/RGLWConfig.m +44 -52
- package/src/ios/RGLWDocumentReader.h +3 -27
- package/src/ios/RGLWDocumentReader.m +11 -716
- package/src/ios/RGLWJSONConstructor.h +1 -8
- package/src/ios/RGLWJSONConstructor.m +12 -10
- package/src/ios/RGLWMain.h +36 -0
- package/src/ios/RGLWMain.m +591 -0
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
//
|
|
2
|
-
// JSONConstructor.kt
|
|
3
|
-
// DocumentReader
|
|
4
|
-
//
|
|
5
|
-
// Created by Pavel Masiuk on 21.09.2023.
|
|
6
|
-
// Copyright © 2023 Regula. All rights reserved.
|
|
7
|
-
//
|
|
8
1
|
@file:SuppressLint("MissingPermission")
|
|
2
|
+
@file:Suppress("unused")
|
|
9
3
|
|
|
10
|
-
package
|
|
4
|
+
package com.regula.plugin.documentreader
|
|
11
5
|
|
|
12
6
|
import android.annotation.SuppressLint
|
|
13
|
-
import android.content.Context
|
|
14
7
|
import android.graphics.Bitmap
|
|
8
|
+
import android.graphics.Matrix
|
|
15
9
|
import android.graphics.Rect
|
|
16
10
|
import android.graphics.Typeface
|
|
17
11
|
import android.util.Pair
|
|
@@ -100,34 +94,22 @@ import com.regula.documentreader.api.results.rfid.SecurityObjectCertificates
|
|
|
100
94
|
import com.regula.documentreader.api.results.rfid.SignerInfo
|
|
101
95
|
import com.regula.documentreader.api.results.rfid.Validity
|
|
102
96
|
import com.regula.documentreader.api.results.rfid.Value
|
|
103
|
-
import cordova.plugin.documentreader.Convert.bitmapFromBase64
|
|
104
|
-
import cordova.plugin.documentreader.Convert.bitmapToBase64
|
|
105
|
-
import cordova.plugin.documentreader.Convert.byteArrayFromBase64
|
|
106
|
-
import cordova.plugin.documentreader.Convert.generateByteArray
|
|
107
97
|
import org.json.JSONArray
|
|
108
98
|
import org.json.JSONObject
|
|
99
|
+
import com.regula.plugin.documentreader.Convert.toBase64
|
|
100
|
+
import com.regula.plugin.documentreader.Convert.toBitmap
|
|
101
|
+
import com.regula.plugin.documentreader.Convert.toByteArray
|
|
102
|
+
|
|
103
|
+
fun generateCompletion(action: Int, results: DocumentReaderResults?, error: RegulaException?) = mapOf(
|
|
104
|
+
"action" to action,
|
|
105
|
+
"results" to if (listOf(DocReaderAction.COMPLETE, DocReaderAction.MORE_PAGES_AVAILABLE, DocReaderAction.CANCEL, DocReaderAction.ERROR, DocReaderAction.TIMEOUT).contains(action)) generateDocumentReaderResults(results) else null,
|
|
106
|
+
"error" to generateRegulaException(error)
|
|
107
|
+
).toJson()
|
|
109
108
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (listOf(
|
|
115
|
-
DocReaderAction.COMPLETE,
|
|
116
|
-
DocReaderAction.MORE_PAGES_AVAILABLE,
|
|
117
|
-
DocReaderAction.CANCEL,
|
|
118
|
-
DocReaderAction.ERROR,
|
|
119
|
-
DocReaderAction.TIMEOUT
|
|
120
|
-
).contains(action)
|
|
121
|
-
) put("results", generateDocumentReaderResults(results, context))
|
|
122
|
-
put("error", generateRegulaException(error))
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
fun generateSuccessCompletion(success: Boolean, error: RegulaException?) = object : JSONObject() { init {
|
|
127
|
-
put("success", success)
|
|
128
|
-
put("error", generateRegulaException(error))
|
|
129
|
-
}
|
|
130
|
-
}
|
|
109
|
+
fun generateSuccessCompletion(success: Boolean, error: RegulaException?) = mapOf(
|
|
110
|
+
"success" to success,
|
|
111
|
+
"error" to generateRegulaException(error)
|
|
112
|
+
).toJson()
|
|
131
113
|
|
|
132
114
|
fun prepareProgressFromJSON(it: JSONObject) = PrepareProgress(
|
|
133
115
|
it.getInt("downloadedBytes"),
|
|
@@ -140,342 +122,280 @@ fun generatePrepareProgress(it: PrepareProgress) = mapOf(
|
|
|
140
122
|
"progress" to it.progress
|
|
141
123
|
).toJson()
|
|
142
124
|
|
|
143
|
-
fun generatePACertificateCompletion(serialNumber: ByteArray?, issuer: PAResourcesIssuer?) =
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
fun generateFinalizePackageCompletion(action: Int, info: TransactionInfo?, error: RegulaException?) = object : JSONObject() { init {
|
|
150
|
-
put("action", action)
|
|
151
|
-
put("info", generateTransactionInfo(info))
|
|
152
|
-
put("error", generateRegulaException(error))
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
fun regulaExceptionFromJSON(temp: JSONObject?) = temp?.let {
|
|
157
|
-
val input: JSONObject = temp
|
|
125
|
+
fun generatePACertificateCompletion(serialNumber: ByteArray?, issuer: PAResourcesIssuer?) = mapOf(
|
|
126
|
+
"serialNumber" to serialNumber.toBase64(),
|
|
127
|
+
"issuer" to generatePAResourcesIssuer(issuer)
|
|
128
|
+
).toJson()
|
|
158
129
|
|
|
159
|
-
|
|
160
|
-
|
|
130
|
+
fun generateFinalizePackageCompletion(action: Int, info: TransactionInfo?, error: RegulaException?) = mapOf(
|
|
131
|
+
"action" to action,
|
|
132
|
+
"info" to generateTransactionInfo(info),
|
|
133
|
+
"error" to generateRegulaException(error)
|
|
134
|
+
).toJson()
|
|
161
135
|
|
|
162
|
-
|
|
136
|
+
fun regulaExceptionFromJSON(input: JSONObject?) = input?.let {
|
|
137
|
+
RegulaException(
|
|
138
|
+
it.optInt("code"),
|
|
139
|
+
it.optString("message")
|
|
140
|
+
)
|
|
163
141
|
}
|
|
164
142
|
|
|
165
|
-
fun generateRegulaException(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
}
|
|
143
|
+
fun generateRegulaException(input: RegulaException?) = input?.let {
|
|
144
|
+
mapOf(
|
|
145
|
+
"code" to it.errorCode,
|
|
146
|
+
"message" to it.message
|
|
147
|
+
).toJson()
|
|
172
148
|
}
|
|
173
149
|
|
|
174
|
-
fun transactionInfoFromJSON(
|
|
175
|
-
temp ?: return null
|
|
176
|
-
val input: JSONObject = temp
|
|
150
|
+
fun transactionInfoFromJSON(input: JSONObject?) = input?.let {
|
|
177
151
|
val result = TransactionInfo()
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
return result
|
|
152
|
+
result.transactionId = it.getStringOrNull("transactionId")
|
|
153
|
+
result.tag = it.getStringOrNull("tag")
|
|
154
|
+
result.sessionLogFolder = it.getStringOrNull("sessionLogFolder")
|
|
155
|
+
result
|
|
184
156
|
}
|
|
185
157
|
|
|
186
|
-
fun generateTransactionInfo(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
result.put("tag", input.tag)
|
|
193
|
-
result.put("sessionLogFolder", input.sessionLogFolder)
|
|
194
|
-
|
|
195
|
-
return result
|
|
158
|
+
fun generateTransactionInfo(input: TransactionInfo?) = input?.let {
|
|
159
|
+
mapOf(
|
|
160
|
+
"transactionId" to it.transactionId,
|
|
161
|
+
"tag" to it.tag,
|
|
162
|
+
"sessionLogFolder" to it.sessionLogFolder
|
|
163
|
+
).toJson()
|
|
196
164
|
}
|
|
197
165
|
|
|
198
|
-
fun tccParamsFromJSON(input: JSONObject)
|
|
166
|
+
fun tccParamsFromJSON(input: JSONObject) = input.let {
|
|
199
167
|
val result = TccParams()
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
result.put("license", generateByteArray(input.license))
|
|
243
|
-
result.put("customDb", generateByteArray(input.customDb))
|
|
244
|
-
result.put("databasePath", input.customDbPath)
|
|
245
|
-
result.put("licenseUpdate", input.isLicenseUpdate)
|
|
246
|
-
result.put("delayedNNLoad", input.isDelayedNNLoad)
|
|
247
|
-
result.put("blackList", input.blackList)
|
|
248
|
-
|
|
249
|
-
return result
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
fun bleDeviceConfigFromJSON(input: JSONObject): BleDeviceConfig {
|
|
168
|
+
result.serviceUrlTA = it.getStringOrNull("serviceUrlTA")
|
|
169
|
+
result.serviceUrlPA = it.getStringOrNull("serviceUrlPA")
|
|
170
|
+
result.pfxCertUrl = it.getStringOrNull("pfxCertUrl")
|
|
171
|
+
result.pfxPassPhrase = it.getStringOrNull("pfxPassPhrase")
|
|
172
|
+
result.pfxCert = it.getStringOrNull("pfxCert").toByteArray()
|
|
173
|
+
result
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
fun generateTccParams(input: TccParams?) = input?.let {
|
|
177
|
+
mapOf(
|
|
178
|
+
"serviceUrlTA" to it.serviceUrlTA,
|
|
179
|
+
"serviceUrlPA" to it.serviceUrlPA,
|
|
180
|
+
"pfxCertUrl" to it.pfxCertUrl,
|
|
181
|
+
"pfxPassPhrase" to it.pfxPassPhrase,
|
|
182
|
+
"pfxCert" to it.pfxCert.toBase64()
|
|
183
|
+
).toJson()
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
fun initConfigFromJSON(input: JSONObject) = input.let {
|
|
187
|
+
val license = it.getString("license").toByteArray()!!
|
|
188
|
+
var result = DocReaderConfig(license)
|
|
189
|
+
if (it.has("customDb")) result = DocReaderConfig(license, it.getString("customDb").toByteArray()!!)
|
|
190
|
+
if (it.has("databasePath")) result = DocReaderConfig(license, it.getString("databasePath"))
|
|
191
|
+
|
|
192
|
+
if (it.has("licenseUpdate")) result.setLicenseUpdate(it.getBoolean("licenseUpdate"))
|
|
193
|
+
if (it.has("delayedNNLoad")) result.isDelayedNNLoad = it.getBoolean("delayedNNLoad")
|
|
194
|
+
result.blackList = it.getJSONObjectOrNull("blackList")
|
|
195
|
+
result
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
fun generateInitConfig(input: DocReaderConfig?) = input?.let {
|
|
199
|
+
mapOf(
|
|
200
|
+
"license" to it.license.toBase64(),
|
|
201
|
+
"customDb" to it.customDb.toBase64(),
|
|
202
|
+
"databasePath" to it.customDbPath,
|
|
203
|
+
"licenseUpdate" to it.isLicenseUpdate,
|
|
204
|
+
"delayedNNLoad" to it.isDelayedNNLoad,
|
|
205
|
+
"blackList" to it.blackList
|
|
206
|
+
).toJson()
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
fun initBleDeviceConfigFromJSON(input: JSONObject) = input.let {
|
|
253
210
|
var result = BleDeviceConfig(bluetooth!!)
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if (
|
|
257
|
-
if (
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
if (
|
|
268
|
-
if (
|
|
269
|
-
if (
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
if (
|
|
294
|
-
|
|
295
|
-
if (input.has("livePortrait")) builder.setLivePortrait(bitmapFromBase64(input.getString("livePortrait"))!!)
|
|
296
|
-
if (input.has("extPortrait")) builder.setExtPortrait(bitmapFromBase64(input.getString("extPortrait"))!!)
|
|
297
|
-
if (input.has("image")) builder.setBitmap(bitmapFromBase64(input.getString("image"))!!)
|
|
298
|
-
if (input.has("data")) builder.setData(byteArrayFromBase64(input.getString("data"))!!)
|
|
299
|
-
if (input.has("images")) {
|
|
300
|
-
val base64Images = input.getJSONArray("images")
|
|
211
|
+
if (it.has("customDb")) result = BleDeviceConfig(bluetooth!!, it.getString("customDb").toByteArray())
|
|
212
|
+
|
|
213
|
+
if (it.has("licenseUpdate")) result.setLicenseUpdate(it.getBoolean("licenseUpdate"))
|
|
214
|
+
if (it.has("delayedNNLoad")) result.isDelayedNNLoad = it.getBoolean("delayedNNLoad")
|
|
215
|
+
result.blackList = it.getJSONObjectOrNull("blackList")
|
|
216
|
+
result
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
fun scannerConfigFromJSON(input: JSONObject) = input.let {
|
|
220
|
+
val builder = if (it.has("scenario")) ScannerConfig.Builder(it.getString("scenario"))
|
|
221
|
+
else ScannerConfig.Builder(onlineProcessingConfigFromJSON(it.getJSONObject("onlineProcessingConfig"))!!)
|
|
222
|
+
|
|
223
|
+
if (it.has("onlineProcessingConfig")) builder.setOnlineProcessingConfig(onlineProcessingConfigFromJSON(it.getJSONObject("onlineProcessingConfig")))
|
|
224
|
+
if (it.has("livePortrait")) builder.setLivePortrait(it.getString("livePortrait").toBitmap()!!)
|
|
225
|
+
if (it.has("extPortrait")) builder.setExtPortrait(it.getString("extPortrait").toBitmap()!!)
|
|
226
|
+
if (it.has("cameraId")) builder.setCameraId(it.getInt("cameraId"))
|
|
227
|
+
builder.build()
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
fun generateScannerConfig(input: ScannerConfig?) = input?.let {
|
|
231
|
+
mapOf(
|
|
232
|
+
"scenario" to it.scenario,
|
|
233
|
+
"onlineProcessingConfig" to generateOnlineProcessingConfig(it.onlineProcessingConfig),
|
|
234
|
+
"livePortrait" to it.livePortrait.toBase64(),
|
|
235
|
+
"extPortrait" to it.extPortrait.toBase64(),
|
|
236
|
+
"cameraId" to it.cameraId
|
|
237
|
+
).toJson()
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
fun recognizeConfigFromJSON(input: JSONObject) = input.let {
|
|
241
|
+
val builder = if (it.has("scenario")) RecognizeConfig.Builder(it.getString("scenario"))
|
|
242
|
+
else RecognizeConfig.Builder(onlineProcessingConfigFromJSON(it.getJSONObject("onlineProcessingConfig"))!!)
|
|
243
|
+
|
|
244
|
+
if (it.has("oneShotIdentification")) builder.setOneShotIdentification(it.getBoolean("oneShotIdentification"))
|
|
245
|
+
if (it.has("dtc")) builder.setDTC(it.getString("dtc").toByteArray()!!)
|
|
246
|
+
if (it.has("livePortrait")) builder.setLivePortrait(it.getString("livePortrait").toBitmap()!!)
|
|
247
|
+
if (it.has("extPortrait")) builder.setExtPortrait(it.getString("extPortrait").toBitmap()!!)
|
|
248
|
+
if (it.has("image")) builder.setBitmap(it.getString("image").toBitmap()!!)
|
|
249
|
+
if (it.has("data")) builder.setData(it.getString("data").toByteArray()!!)
|
|
250
|
+
if (it.has("images")) {
|
|
251
|
+
val base64Images = it.getJSONArray("images")
|
|
301
252
|
val images = arrayOfNulls<Bitmap>(base64Images.length())
|
|
302
|
-
for (i in images.indices) images[i] =
|
|
253
|
+
for (i in images.indices) images[i] = base64Images.getString(i).toBitmap()
|
|
303
254
|
builder.setBitmaps(images)
|
|
304
255
|
}
|
|
305
|
-
if (
|
|
306
|
-
val base64InputData =
|
|
256
|
+
if (it.has("imageInputData")) {
|
|
257
|
+
val base64InputData = it.getJSONArray("imageInputData")
|
|
307
258
|
val inputData = arrayOfNulls<ImageInputData>(base64InputData.length())
|
|
308
259
|
for (i in inputData.indices) inputData[i] = imageInputDataFromJSON(base64InputData.getJSONObject(i))
|
|
309
260
|
builder.setImageInputData(inputData)
|
|
310
261
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
262
|
+
builder.build()
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
fun generateRecognizeConfig(input: RecognizeConfig?) = input?.let {
|
|
266
|
+
mapOf(
|
|
267
|
+
"scenario" to it.scenario,
|
|
268
|
+
"onlineProcessingConfig" to generateOnlineProcessingConfig(it.onlineProcessingConfig),
|
|
269
|
+
"oneShotIdentification" to it.oneShotIdentification,
|
|
270
|
+
"dtc" to it.dtc.toBase64(),
|
|
271
|
+
"livePortrait" to it.livePortrait.toBase64(),
|
|
272
|
+
"extPortrait" to it.extPortrait.toBase64(),
|
|
273
|
+
"image" to it.bitmap.toBase64(),
|
|
274
|
+
"data" to it.data.toBase64(),
|
|
275
|
+
"images" to
|
|
276
|
+
if (it.bitmaps == null) null
|
|
277
|
+
else {
|
|
278
|
+
val array = JSONArray()
|
|
279
|
+
for (bitmap in it.bitmaps!!) array.put(bitmap.toBase64())
|
|
280
|
+
array
|
|
281
|
+
},
|
|
282
|
+
"imageInputData" to it.imageInputData.toJson(::generateImageInputData)
|
|
283
|
+
).toJson()
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
fun backendProcessingConfigFromJSON(input: JSONObject?) = input?.let {
|
|
287
|
+
val result = BackendProcessingConfig(it.getString("url"))
|
|
288
|
+
if (it.has("httpHeaders")) {
|
|
289
|
+
val httpHeaders: MutableMap<String, String> = HashMap()
|
|
290
|
+
it.getJSONObject("httpHeaders").forEach { key, value -> httpHeaders[key] = value as String }
|
|
291
|
+
result.httpHeaders = httpHeaders
|
|
334
292
|
}
|
|
335
|
-
result.
|
|
336
|
-
|
|
337
|
-
|
|
293
|
+
result.rfidServerSideChipVerification = it.getBooleanOrNull("rfidServerSideChipVerification")
|
|
294
|
+
result.timeoutConnection = it.getDoubleOrNull("timeoutConnection")
|
|
295
|
+
result
|
|
338
296
|
}
|
|
339
297
|
|
|
340
|
-
fun
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
298
|
+
fun generateBackendProcessingConfig(input: BackendProcessingConfig?) = input?.let {
|
|
299
|
+
mapOf(
|
|
300
|
+
"url" to it.url,
|
|
301
|
+
"rfidServerSideChipVerification" to it.rfidServerSideChipVerification,
|
|
302
|
+
"timeoutConnection" to it.timeoutConnection,
|
|
303
|
+
"httpHeaders" to if (it.httpHeaders == null) null else {
|
|
304
|
+
val httpHeaders = JSONObject()
|
|
305
|
+
for ((key, value) in it.httpHeaders!!) httpHeaders.put(key, value)
|
|
306
|
+
httpHeaders
|
|
307
|
+
}
|
|
308
|
+
).toJson()
|
|
350
309
|
}
|
|
351
310
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
return result
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
fun onlineProcessingConfigFromJSON(temp: JSONObject?): OnlineProcessingConfig? {
|
|
366
|
-
if (temp == null || !temp.has("mode")) return null
|
|
367
|
-
val input: JSONObject = temp
|
|
368
|
-
val builder = OnlineProcessingConfig.Builder(input.getInt("mode"))
|
|
369
|
-
|
|
370
|
-
if (input.has("imageFormat")) builder.setImageFormat(input.getInt("imageFormat"))
|
|
371
|
-
if (input.has("url")) builder.setUrl(input.getString("url"))
|
|
372
|
-
if (input.has("imageCompressionQuality")) builder.setImageCompressionQuality(input.getDouble("imageCompressionQuality").toFloat())
|
|
373
|
-
if (input.has("processParams")) builder.setProcessParams(processParamFromJSON(input.getJSONObject("processParams")))
|
|
374
|
-
if (input.has("requestHeaders")) {
|
|
311
|
+
val weakReferencesHolder = mutableListOf<Any>()
|
|
312
|
+
fun onlineProcessingConfigFromJSON(input: JSONObject?) = input?.let {
|
|
313
|
+
val builder = OnlineProcessingConfig.Builder(it.getInt("mode"))
|
|
314
|
+
|
|
315
|
+
if (it.has("imageFormat")) builder.setImageFormat(it.getInt("imageFormat"))
|
|
316
|
+
if (it.has("url")) builder.setUrl(it.getString("url"))
|
|
317
|
+
if (it.has("imageCompressionQuality")) builder.setImageCompressionQuality(it.getDouble("imageCompressionQuality").toFloat())
|
|
318
|
+
if (it.has("processParams")) builder.setProcessParams(processParamFromJSON(it.getJSONObject("processParams")))
|
|
319
|
+
if (it.has("requestHeaders")) {
|
|
375
320
|
val listener = NetworkInterceptorListener { input.getJSONObject("requestHeaders").forEach { k, v -> it.setRequestProperty(k, v as String) } }
|
|
376
321
|
weakReferencesHolder.add(listener)
|
|
377
322
|
builder.setNetworkInterceptorListener(listener)
|
|
378
323
|
}
|
|
379
|
-
|
|
380
|
-
return builder.build()
|
|
324
|
+
builder.build()
|
|
381
325
|
}
|
|
382
326
|
|
|
383
|
-
fun generateOnlineProcessingConfig(
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
result.put("imageFormat", input.imageFormat)
|
|
392
|
-
result.put("imageCompressionQuality", input.imageCompressionQuality)
|
|
393
|
-
|
|
394
|
-
return result
|
|
327
|
+
fun generateOnlineProcessingConfig(input: OnlineProcessingConfig?) = input?.let {
|
|
328
|
+
mapOf(
|
|
329
|
+
"mode" to it.mode,
|
|
330
|
+
"url" to it.url,
|
|
331
|
+
"processParams" to getProcessParams(it.processParam),
|
|
332
|
+
"imageFormat" to it.imageFormat,
|
|
333
|
+
"imageCompressionQuality" to it.imageCompressionQuality
|
|
334
|
+
).toJson()
|
|
395
335
|
}
|
|
396
336
|
|
|
397
|
-
fun faceApiParamsFromJSON(
|
|
337
|
+
fun faceApiParamsFromJSON(input: JSONObject?) = input?.let {
|
|
398
338
|
val result = FaceApiParams()
|
|
399
|
-
temp ?: return null
|
|
400
|
-
val input: JSONObject = temp
|
|
401
|
-
|
|
402
|
-
if (input.has("url") && !input.isNull("url")) result.url = input.getString("url")
|
|
403
|
-
if (input.has("mode") && !input.isNull("mode")) result.mode = input.getString("mode")
|
|
404
|
-
if (input.has("searchParams") && !input.isNull("searchParams")) result.search = faceApiSearchParamsFromJSON(input.getJSONObject("searchParams"))
|
|
405
|
-
if (input.has("threshold") && !input.isNull("threshold")) result.threshold = input.getInt("threshold")
|
|
406
|
-
if (input.has("serviceTimeout") && !input.isNull("serviceTimeout")) result.serviceTimeout = input.getInt("serviceTimeout")
|
|
407
|
-
if (input.has("proxy") && !input.isNull("proxy")) result.proxy = input.getString("proxy")
|
|
408
|
-
if (input.has("proxyPassword") && !input.isNull("proxyPassword")) result.proxyUserPwd = input.getString("proxyPassword")
|
|
409
|
-
if (input.has("proxyType") && !input.isNull("proxyType")) result.proxyType = input.getInt("proxyType")
|
|
410
|
-
|
|
411
|
-
return result
|
|
412
|
-
}
|
|
413
339
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
340
|
+
if (it.has("url")) result.url = it.getString("url")
|
|
341
|
+
if (it.has("mode")) result.mode = it.getString("mode")
|
|
342
|
+
if (it.has("threshold") && !it.isNull("threshold")) result.threshold = it.getInt("threshold")
|
|
343
|
+
if (it.has("serviceTimeout") && !it.isNull("serviceTimeout")) result.serviceTimeout = it.getInt("serviceTimeout")
|
|
344
|
+
result.search = faceApiSearchParamsFromJSON(it.getJSONObjectOrNull("searchParams"))
|
|
345
|
+
result.proxy = it.getStringOrNull("proxy")
|
|
346
|
+
result.proxyUserPwd = it.getStringOrNull("proxyPassword")
|
|
347
|
+
result.proxyType = it.getIntOrNull("proxyType")
|
|
418
348
|
|
|
419
|
-
result
|
|
420
|
-
|
|
421
|
-
result.put("searchParams", generateFaceApiSearchParams(input.search))
|
|
422
|
-
result.put("threshold", input.threshold)
|
|
423
|
-
result.put("serviceTimeout", input.serviceTimeout)
|
|
424
|
-
result.put("proxy", input.proxy)
|
|
425
|
-
result.put("proxyPassword", input.proxyUserPwd)
|
|
426
|
-
result.put("proxyType", input.proxyType)
|
|
349
|
+
result
|
|
350
|
+
}
|
|
427
351
|
|
|
428
|
-
|
|
352
|
+
fun generateFaceApiParams(input: FaceApiParams?) = input?.let {
|
|
353
|
+
mapOf(
|
|
354
|
+
"url" to it.url,
|
|
355
|
+
"mode" to it.mode,
|
|
356
|
+
"searchParams" to generateFaceApiSearchParams(it.search),
|
|
357
|
+
"threshold" to it.threshold,
|
|
358
|
+
"serviceTimeout" to it.serviceTimeout,
|
|
359
|
+
"proxy" to it.proxy,
|
|
360
|
+
"proxyPassword" to it.proxyUserPwd,
|
|
361
|
+
"proxyType" to it.proxyType
|
|
362
|
+
).toJson()
|
|
429
363
|
}
|
|
430
364
|
|
|
431
|
-
fun faceApiSearchParamsFromJSON(
|
|
365
|
+
fun faceApiSearchParamsFromJSON(input: JSONObject?) = input?.let {
|
|
432
366
|
val result = FaceApiParams.Search()
|
|
433
|
-
temp ?: return null
|
|
434
|
-
val input: JSONObject = temp
|
|
435
367
|
|
|
436
|
-
if (
|
|
437
|
-
if (
|
|
438
|
-
if (
|
|
439
|
-
val jsonArrayGroupIds =
|
|
368
|
+
if (it.has("limit") && !it.isNull("limit")) result.limit = it.getInt("limit")
|
|
369
|
+
if (it.has("threshold") && !it.isNull("threshold")) result.threshold = it.getDouble("threshold").toFloat()
|
|
370
|
+
if (it.has("groupIds") && !it.isNull("groupIds")) {
|
|
371
|
+
val jsonArrayGroupIds = it.getJSONArray("groupIds")
|
|
440
372
|
val groupIds = IntArray(jsonArrayGroupIds.length())
|
|
441
373
|
for (i in 0 until jsonArrayGroupIds.length())
|
|
442
374
|
groupIds[i] = jsonArrayGroupIds.getInt(i)
|
|
443
375
|
result.groupIds = groupIds
|
|
444
376
|
}
|
|
445
377
|
|
|
446
|
-
|
|
378
|
+
result
|
|
447
379
|
}
|
|
448
380
|
|
|
449
|
-
fun generateFaceApiSearchParams(
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
result.put("threshold", input.threshold)
|
|
456
|
-
result.put("groupIds", input.groupIds.generate())
|
|
457
|
-
|
|
458
|
-
return result
|
|
381
|
+
fun generateFaceApiSearchParams(input: FaceApiParams.Search?) = input?.let {
|
|
382
|
+
mapOf(
|
|
383
|
+
"limit" to it.limit,
|
|
384
|
+
"threshold" to it.threshold,
|
|
385
|
+
"groupIds" to it.groupIds.toJson()
|
|
386
|
+
).toJson()
|
|
459
387
|
}
|
|
460
388
|
|
|
461
|
-
fun rfidParamsFromJSON(
|
|
389
|
+
fun rfidParamsFromJSON(input: JSONObject?) = input?.let {
|
|
462
390
|
val result = RFIDParams()
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
if (input.has("paIgnoreNotificationCodes")) result.paIgnoreNotificationCodes = input.getJSONArray("paIgnoreNotificationCodes").toIntArray()
|
|
467
|
-
|
|
468
|
-
return result
|
|
391
|
+
if (it.has("paIgnoreNotificationCodes")) result.paIgnoreNotificationCodes = it.getJSONArray("paIgnoreNotificationCodes").toIntArray()
|
|
392
|
+
result
|
|
469
393
|
}
|
|
470
394
|
|
|
471
|
-
fun generateRFIDParams(
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
result.put("paIgnoreNotificationCodes", input.paIgnoreNotificationCodes.generate())
|
|
477
|
-
|
|
478
|
-
return result
|
|
395
|
+
fun generateRFIDParams(input: RFIDParams?) = input?.let {
|
|
396
|
+
mapOf(
|
|
397
|
+
"paIgnoreNotificationCodes" to it.paIgnoreNotificationCodes.toJson()
|
|
398
|
+
).toJson()
|
|
479
399
|
}
|
|
480
400
|
|
|
481
401
|
fun processParamFromJSON(input: JSONObject): ProcessParam {
|
|
@@ -550,9 +470,9 @@ fun rfidScenarioFromJSON(input: JSONObject): RfidScenario {
|
|
|
550
470
|
|
|
551
471
|
fun generateRfidScenario(input: RfidScenario): JSONObject = getRfidScenario(input)
|
|
552
472
|
|
|
553
|
-
fun customizationFromJSON(input: JSONObject
|
|
473
|
+
fun customizationFromJSON(input: JSONObject): ParamsCustomization {
|
|
554
474
|
val result = ParamsCustomization()
|
|
555
|
-
setCustomization(result, input
|
|
475
|
+
setCustomization(result, input)
|
|
556
476
|
return result
|
|
557
477
|
}
|
|
558
478
|
|
|
@@ -566,1662 +486,1293 @@ fun functionalityFromJSON(input: JSONObject): Functionality {
|
|
|
566
486
|
|
|
567
487
|
fun generateFunctionality(input: Functionality): JSONObject = getFunctionality(input)
|
|
568
488
|
|
|
569
|
-
fun glaresCheckParamsFromJSON(
|
|
570
|
-
temp ?: return null
|
|
571
|
-
val input: JSONObject = temp
|
|
489
|
+
fun glaresCheckParamsFromJSON(input: JSONObject?) = input?.let {
|
|
572
490
|
val result = GlaresCheckParams()
|
|
573
|
-
|
|
574
|
-
if (
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
return result
|
|
491
|
+
if (it.has("imgMarginPart")) result.imgMarginPart = it.getDouble("imgMarginPart")
|
|
492
|
+
if (it.has("maxGlaringPart")) result.maxGlaringPart = it.getDouble("maxGlaringPart")
|
|
493
|
+
result
|
|
578
494
|
}
|
|
579
495
|
|
|
580
|
-
fun generateGlaresCheckParams(
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
result.put("imgMarginPart", input.imgMarginPart)
|
|
586
|
-
result.put("maxGlaringPart", input.maxGlaringPart)
|
|
587
|
-
|
|
588
|
-
return result
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
fun typefaceFromJSON(input: JSONObject): Pair<Typeface, Int?> {
|
|
592
|
-
val name = input.getString("name")
|
|
593
|
-
val style = input.optInt("style", Typeface.NORMAL)
|
|
594
|
-
val size = if (input.has("size")) input.getInt("size") else null
|
|
595
|
-
return Pair(Typeface.create(name, style), size)
|
|
496
|
+
fun generateGlaresCheckParams(input: GlaresCheckParams?) = input?.let {
|
|
497
|
+
mapOf(
|
|
498
|
+
"imgMarginPart" to it.imgMarginPart,
|
|
499
|
+
"maxGlaringPart" to it.maxGlaringPart
|
|
500
|
+
).toJson()
|
|
596
501
|
}
|
|
597
502
|
|
|
598
|
-
fun
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
result.put("size", size)
|
|
503
|
+
fun typefaceFromJSON(it: JSONObject) = Pair(
|
|
504
|
+
Typeface.create(
|
|
505
|
+
it.getString("name"),
|
|
506
|
+
it.optInt("style", Typeface.NORMAL)
|
|
507
|
+
),
|
|
508
|
+
if (it.has("size")) it.getInt("size") else null
|
|
509
|
+
)
|
|
606
510
|
|
|
607
|
-
|
|
511
|
+
fun generateTypeface(input: Typeface?, size: Int? = null) = input?.let {
|
|
512
|
+
mapOf(
|
|
513
|
+
"name" to "undefined",
|
|
514
|
+
"style" to it.style,
|
|
515
|
+
"size" to size
|
|
516
|
+
).toJson()
|
|
608
517
|
}
|
|
609
518
|
|
|
610
|
-
fun imageInputDataFromJSON(
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
val image = bitmapFromBase64(input.getString("image"))!!
|
|
617
|
-
if (input.has("light")) light = input.getInt("light")
|
|
618
|
-
if (input.has("pageIndex")) pageIndex = input.getInt("pageIndex")
|
|
619
|
-
|
|
620
|
-
return ImageInputData(image, light, pageIndex)
|
|
519
|
+
fun imageInputDataFromJSON(input: JSONObject?) = input?.let {
|
|
520
|
+
ImageInputData(
|
|
521
|
+
it.getString("image").toBitmap()!!,
|
|
522
|
+
it.getIntOrNull("light") ?: 6,
|
|
523
|
+
it.getIntOrNull("pageIndex") ?: 0
|
|
524
|
+
)
|
|
621
525
|
}
|
|
622
526
|
|
|
623
|
-
fun generateImageInputData(
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
result.put("light", input.light)
|
|
630
|
-
result.put("pageIndex", input.pageIndex)
|
|
631
|
-
|
|
632
|
-
return result
|
|
527
|
+
fun generateImageInputData(input: ImageInputData?) = input?.let {
|
|
528
|
+
mapOf(
|
|
529
|
+
"image" to it.bitmap.toBase64(),
|
|
530
|
+
"light" to it.light,
|
|
531
|
+
"pageIndex" to it.pageIndex
|
|
532
|
+
).toJson()
|
|
633
533
|
}
|
|
634
534
|
|
|
635
|
-
fun pkdCertificateFromJSON(
|
|
636
|
-
temp ?: return null
|
|
637
|
-
val input: JSONObject = temp
|
|
535
|
+
fun pkdCertificateFromJSON(input: JSONObject?) = input?.let {
|
|
638
536
|
var resourceType = 0
|
|
639
537
|
var binaryData = ByteArray(0)
|
|
640
538
|
|
|
641
|
-
if (
|
|
642
|
-
if (
|
|
643
|
-
if (
|
|
644
|
-
val privateKey =
|
|
539
|
+
if (it.has("resourceType")) resourceType = it.getInt("resourceType")
|
|
540
|
+
if (it.has("binaryData")) binaryData = it.getString("binaryData").toByteArray()!!
|
|
541
|
+
if (it.has("privateKey")) {
|
|
542
|
+
val privateKey = it.getString("privateKey").toByteArray()
|
|
645
543
|
return PKDCertificate(binaryData, resourceType, privateKey)
|
|
646
544
|
}
|
|
647
|
-
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
fun generatePKDCertificate(
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
result.put("frameOrientation", input.frameOrientation)
|
|
697
|
-
result.put("uvTorch", input.uvTorch)
|
|
698
|
-
result.put("faceExt", input.faceExt)
|
|
699
|
-
result.put("seriesProcessMode", input.seriesProcessMode)
|
|
700
|
-
result.put("manualCrop", input.manualCrop)
|
|
701
|
-
|
|
702
|
-
return result
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
fun rectFromJSON(temp: JSONObject?): Rect? {
|
|
706
|
-
temp ?: return null
|
|
707
|
-
val input: JSONObject = temp
|
|
545
|
+
PKDCertificate(binaryData, resourceType)
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
fun generatePKDCertificate(input: PKDCertificate?) = input?.let {
|
|
549
|
+
mapOf(
|
|
550
|
+
"resourceType" to it.resourceType,
|
|
551
|
+
"binaryData" to it.binaryData.toBase64(),
|
|
552
|
+
"privateKey" to it.privateKey.toBase64()
|
|
553
|
+
).toJson()
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
fun documentReaderScenarioFromJSON(input: JSONObject?) = input?.let {
|
|
557
|
+
DocumentReaderScenario(
|
|
558
|
+
it.optString("name"),
|
|
559
|
+
it.optString("caption"),
|
|
560
|
+
it.optString("description"),
|
|
561
|
+
if (it.optBoolean("multiPageOff")) 1 else 0,
|
|
562
|
+
it.optDouble("frameKWHLandscape"),
|
|
563
|
+
it.optDouble("frameKWHPortrait"),
|
|
564
|
+
it.optDouble("frameKWHDoublePageSpreadPortrait"),
|
|
565
|
+
it.optDouble("frameKWHDoublePageSpreadLandscape"),
|
|
566
|
+
it.optInt("frameOrientation"),
|
|
567
|
+
it.optBoolean("uvTorch"),
|
|
568
|
+
it.optBoolean("faceExt"),
|
|
569
|
+
it.optBoolean("seriesProcessMode"),
|
|
570
|
+
it.optBoolean("manualCrop"),
|
|
571
|
+
null
|
|
572
|
+
)
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
fun generateDocumentReaderScenario(input: DocumentReaderScenario?) = input?.let {
|
|
576
|
+
mapOf(
|
|
577
|
+
"name" to it.name,
|
|
578
|
+
"caption" to it.caption,
|
|
579
|
+
"description" to it.description,
|
|
580
|
+
"multiPageOff" to it.multiPageOff,
|
|
581
|
+
"frameKWHLandscape" to it.frameKWHLandscape,
|
|
582
|
+
"frameKWHPortrait" to it.frameKWHPortrait,
|
|
583
|
+
"frameKWHDoublePageSpreadPortrait" to it.frameKWHDoublePageSpreadPortrait,
|
|
584
|
+
"frameKWHDoublePageSpreadLandscape" to it.frameKWHDoublePageSpreadLandscape,
|
|
585
|
+
"frameOrientation" to it.frameOrientation,
|
|
586
|
+
"uvTorch" to it.uvTorch,
|
|
587
|
+
"faceExt" to it.faceExt,
|
|
588
|
+
"seriesProcessMode" to it.seriesProcessMode,
|
|
589
|
+
"manualCrop" to it.manualCrop
|
|
590
|
+
).toJson()
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
fun rectFromJSON(input: JSONObject?) = input?.let {
|
|
708
594
|
val result = Rect()
|
|
709
595
|
|
|
710
|
-
result.bottom =
|
|
711
|
-
result.top =
|
|
712
|
-
result.left =
|
|
713
|
-
result.right =
|
|
596
|
+
result.bottom = it.optInt("bottom")
|
|
597
|
+
result.top = it.optInt("top")
|
|
598
|
+
result.left = it.optInt("left")
|
|
599
|
+
result.right = it.optInt("right")
|
|
714
600
|
|
|
715
|
-
|
|
601
|
+
result
|
|
716
602
|
}
|
|
717
603
|
|
|
718
|
-
fun generateRect(
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
result.put("left", input.left)
|
|
726
|
-
result.put("right", input.right)
|
|
727
|
-
|
|
728
|
-
return result
|
|
604
|
+
fun generateRect(input: Rect?) = input?.let {
|
|
605
|
+
mapOf(
|
|
606
|
+
"bottom" to it.bottom,
|
|
607
|
+
"top" to it.top,
|
|
608
|
+
"left" to it.left,
|
|
609
|
+
"right" to it.right
|
|
610
|
+
).toJson()
|
|
729
611
|
}
|
|
730
612
|
|
|
731
|
-
fun docReaderFieldRectFromJSON(
|
|
732
|
-
temp ?: return null
|
|
733
|
-
val input: JSONObject = temp
|
|
613
|
+
fun docReaderFieldRectFromJSON(input: JSONObject?) = input?.let {
|
|
734
614
|
val result = DocReaderFieldRect()
|
|
735
615
|
|
|
736
|
-
result.bottom =
|
|
737
|
-
result.top =
|
|
738
|
-
result.left =
|
|
739
|
-
result.right =
|
|
616
|
+
result.bottom = it.optInt("bottom")
|
|
617
|
+
result.top = it.optInt("top")
|
|
618
|
+
result.left = it.optInt("left")
|
|
619
|
+
result.right = it.optInt("right")
|
|
740
620
|
|
|
741
|
-
|
|
621
|
+
result
|
|
742
622
|
}
|
|
743
623
|
|
|
744
|
-
fun generateDocReaderFieldRect(
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
result.put("left", input.left)
|
|
752
|
-
result.put("right", input.right)
|
|
753
|
-
|
|
754
|
-
return result
|
|
624
|
+
fun generateDocReaderFieldRect(input: DocReaderFieldRect?) = input?.let {
|
|
625
|
+
mapOf(
|
|
626
|
+
"bottom" to it.bottom,
|
|
627
|
+
"top" to it.top,
|
|
628
|
+
"left" to it.left,
|
|
629
|
+
"right" to it.right
|
|
630
|
+
).toJson()
|
|
755
631
|
}
|
|
756
632
|
|
|
757
|
-
fun documentReaderGraphicFieldFromJSON(
|
|
758
|
-
temp ?: return null
|
|
759
|
-
val input: JSONObject = temp
|
|
633
|
+
fun documentReaderGraphicFieldFromJSON(input: JSONObject?) = input?.let {
|
|
760
634
|
val result = DocumentReaderGraphicField()
|
|
761
635
|
|
|
762
|
-
|
|
763
|
-
result.sourceType =
|
|
764
|
-
result.fieldType =
|
|
765
|
-
result.light =
|
|
766
|
-
result.pageIndex =
|
|
767
|
-
result.originalPageIndex =
|
|
768
|
-
result.boundRect = docReaderFieldRectFromJSON(
|
|
636
|
+
it.remove("value")
|
|
637
|
+
result.sourceType = it.optInt("sourceType")
|
|
638
|
+
result.fieldType = it.optInt("fieldType")
|
|
639
|
+
result.light = it.optInt("light")
|
|
640
|
+
result.pageIndex = it.optInt("pageIndex")
|
|
641
|
+
result.originalPageIndex = it.optInt("originalPageIndex")
|
|
642
|
+
result.boundRect = docReaderFieldRectFromJSON(it.optJSONObject("fieldRect"))
|
|
769
643
|
|
|
770
|
-
|
|
644
|
+
result
|
|
771
645
|
}
|
|
772
646
|
|
|
773
|
-
fun generateDocumentReaderGraphicField(
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
result.put("value", input.imageBase64())
|
|
786
|
-
result.put("fieldRect", generateDocReaderFieldRect(input.boundRect))
|
|
787
|
-
|
|
788
|
-
return result
|
|
647
|
+
fun generateDocumentReaderGraphicField(input: DocumentReaderGraphicField?) = input?.let {
|
|
648
|
+
mapOf(
|
|
649
|
+
"sourceType" to it.sourceType,
|
|
650
|
+
"fieldType" to it.fieldType,
|
|
651
|
+
"light" to it.light,
|
|
652
|
+
"pageIndex" to it.pageIndex,
|
|
653
|
+
"originalPageIndex" to it.originalPageIndex,
|
|
654
|
+
"fieldName" to eGraphicFieldType.getTranslation(context, it.fieldType),
|
|
655
|
+
"lightName" to eRPRM_Lights.getTranslation(context, it.light),
|
|
656
|
+
"value" to it.imageBase64(),
|
|
657
|
+
"fieldRect" to generateDocReaderFieldRect(it.boundRect)
|
|
658
|
+
).toJson()
|
|
789
659
|
}
|
|
790
660
|
|
|
791
|
-
fun documentReaderGraphicResultFromJSON(
|
|
792
|
-
temp ?: return null
|
|
793
|
-
val input: JSONObject = temp
|
|
661
|
+
fun documentReaderGraphicResultFromJSON(input: JSONObject?) = input?.let {
|
|
794
662
|
val result = DocumentReaderGraphicResult()
|
|
795
|
-
|
|
796
|
-
result
|
|
797
|
-
|
|
798
|
-
return result
|
|
663
|
+
result.fields = it.optJSONArray("fields").toList(::documentReaderGraphicFieldFromJSON)!!
|
|
664
|
+
result
|
|
799
665
|
}
|
|
800
666
|
|
|
801
|
-
fun generateDocumentReaderGraphicResult(
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
result.put("fields", generateList(input.fields, ::generateDocumentReaderGraphicField, context))
|
|
807
|
-
|
|
808
|
-
return result
|
|
667
|
+
fun generateDocumentReaderGraphicResult(input: DocumentReaderGraphicResult?) = input?.let {
|
|
668
|
+
mapOf(
|
|
669
|
+
"fields" to it.fields.toJson(::generateDocumentReaderGraphicField)
|
|
670
|
+
).toJson()
|
|
809
671
|
}
|
|
810
672
|
|
|
811
|
-
fun documentReaderValueFromJSON(
|
|
812
|
-
temp ?: return null
|
|
813
|
-
val input: JSONObject = temp
|
|
673
|
+
fun documentReaderValueFromJSON(input: JSONObject?) = input?.let {
|
|
814
674
|
val result = DocumentReaderValue()
|
|
815
675
|
|
|
816
|
-
result.pageIndex =
|
|
817
|
-
result.sourceType =
|
|
818
|
-
result.probability =
|
|
819
|
-
result.value =
|
|
820
|
-
result.originalValue =
|
|
821
|
-
result.boundRect = rectFromJSON(
|
|
822
|
-
result.originalSymbols =
|
|
823
|
-
result.rfidOrigin = documentReaderRFIDOriginFromJSON(
|
|
676
|
+
result.pageIndex = it.optInt("pageIndex")
|
|
677
|
+
result.sourceType = it.optInt("sourceType")
|
|
678
|
+
result.probability = it.optInt("probability")
|
|
679
|
+
result.value = it.optString("value")
|
|
680
|
+
result.originalValue = it.optString("originalValue")
|
|
681
|
+
result.boundRect = rectFromJSON(it.optJSONObject("boundRect"))
|
|
682
|
+
result.originalSymbols = it.optJSONArray("originalSymbols").toList(::documentReaderSymbolFromJSON)!!
|
|
683
|
+
result.rfidOrigin = documentReaderRFIDOriginFromJSON(it.optJSONObject("rfidOrigin"))
|
|
824
684
|
|
|
825
|
-
|
|
685
|
+
result
|
|
826
686
|
}
|
|
827
687
|
|
|
828
|
-
fun generateDocumentReaderValue(
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
result.put("originalSymbols", generateList(input.originalSymbols, ::generateDocumentReaderSymbol))
|
|
840
|
-
result.put("rfidOrigin", generateDocumentReaderRFIDOrigin(input.rfidOrigin))
|
|
841
|
-
|
|
842
|
-
return result
|
|
688
|
+
fun generateDocumentReaderValue(input: DocumentReaderValue?) = input?.let {
|
|
689
|
+
mapOf(
|
|
690
|
+
"pageIndex" to it.pageIndex,
|
|
691
|
+
"sourceType" to it.sourceType,
|
|
692
|
+
"probability" to it.probability,
|
|
693
|
+
"value" to it.value,
|
|
694
|
+
"originalValue" to it.originalValue,
|
|
695
|
+
"boundRect" to generateRect(it.boundRect),
|
|
696
|
+
"originalSymbols" to it.originalSymbols.toJson(::generateDocumentReaderSymbol),
|
|
697
|
+
"rfidOrigin" to generateDocumentReaderRFIDOrigin(it.rfidOrigin)
|
|
698
|
+
).toJson()
|
|
843
699
|
}
|
|
844
700
|
|
|
845
|
-
fun documentReaderTextFieldFromJSON(
|
|
846
|
-
temp ?: return null
|
|
847
|
-
val input: JSONObject = temp
|
|
701
|
+
fun documentReaderTextFieldFromJSON(input: JSONObject?) = input?.let {
|
|
848
702
|
val result = DocumentReaderTextField()
|
|
849
703
|
|
|
850
|
-
|
|
851
|
-
result.fieldType =
|
|
852
|
-
result.lcid =
|
|
853
|
-
result.status =
|
|
854
|
-
result.value =
|
|
855
|
-
result.values =
|
|
856
|
-
result.comparisonList =
|
|
857
|
-
result.validityList =
|
|
858
|
-
result.comparisonStatus =
|
|
859
|
-
result.validityStatus =
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
fun generateDocumentReaderTextField(
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
return result
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
fun documentReaderTextResultFromJSON(temp: JSONObject?): DocumentReaderTextResult? {
|
|
886
|
-
temp ?: return null
|
|
887
|
-
val input: JSONObject = temp
|
|
704
|
+
it.remove("getValue")
|
|
705
|
+
result.fieldType = it.optInt("fieldType")
|
|
706
|
+
result.lcid = it.optInt("lcid")
|
|
707
|
+
result.status = it.optInt("status")
|
|
708
|
+
result.value = it.optString("value")
|
|
709
|
+
result.values = it.optJSONArray("values").toList(::documentReaderValueFromJSON)!!
|
|
710
|
+
result.comparisonList = it.optJSONArray("comparisonList").toList(::documentReaderComparisonFromJSON)!!
|
|
711
|
+
result.validityList = it.optJSONArray("validityList").toList(::documentReaderValidityFromJSON)!!
|
|
712
|
+
result.comparisonStatus = it.optInt("comparisonStatus")
|
|
713
|
+
result.validityStatus = it.optInt("validityStatus")
|
|
714
|
+
|
|
715
|
+
result
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
fun generateDocumentReaderTextField(input: DocumentReaderTextField?) = input?.let {
|
|
719
|
+
mapOf(
|
|
720
|
+
"fieldType" to it.fieldType,
|
|
721
|
+
"lcid" to it.lcid,
|
|
722
|
+
"status" to it.status,
|
|
723
|
+
"lcidName" to it.getLcidName(context),
|
|
724
|
+
"fieldName" to it.getFieldName(context),
|
|
725
|
+
"value" to it.value,
|
|
726
|
+
"getValue" to generateDocumentReaderValue(it.value()),
|
|
727
|
+
"values" to it.values.toJson(::generateDocumentReaderValue),
|
|
728
|
+
"comparisonList" to it.comparisonList.toJson(::generateDocumentReaderComparison),
|
|
729
|
+
"validityList" to it.validityList.toJson(::generateDocumentReaderValidity),
|
|
730
|
+
"comparisonStatus" to it.comparisonStatus,
|
|
731
|
+
"validityStatus" to it.validityStatus
|
|
732
|
+
).toJson()
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
fun documentReaderTextResultFromJSON(input: JSONObject?) = input?.let {
|
|
888
736
|
val result = DocumentReaderTextResult()
|
|
889
737
|
|
|
890
|
-
result.status =
|
|
891
|
-
result.comparisonStatus =
|
|
892
|
-
result.validityStatus =
|
|
893
|
-
result.availableSourceList =
|
|
894
|
-
result.fields =
|
|
738
|
+
result.status = it.optInt("status")
|
|
739
|
+
result.comparisonStatus = it.optInt("comparisonStatus")
|
|
740
|
+
result.validityStatus = it.optInt("validityStatus")
|
|
741
|
+
result.availableSourceList = it.optJSONArray("availableSourceList").toList(::documentReaderTextSourceFromJSON)!!
|
|
742
|
+
result.fields = it.optJSONArray("fields").toList(::documentReaderTextFieldFromJSON)!!
|
|
895
743
|
|
|
896
|
-
|
|
744
|
+
result
|
|
897
745
|
}
|
|
898
746
|
|
|
899
|
-
fun generateDocumentReaderTextResult(
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
result.put("availableSourceList", generateList(input.availableSourceList, ::generateDocumentReaderTextSource))
|
|
908
|
-
result.put("fields", generateList(input.fields, ::generateDocumentReaderTextField, context))
|
|
909
|
-
|
|
910
|
-
return result
|
|
747
|
+
fun generateDocumentReaderTextResult(input: DocumentReaderTextResult?) = input?.let {
|
|
748
|
+
mapOf(
|
|
749
|
+
"status" to it.status,
|
|
750
|
+
"comparisonStatus" to it.comparisonStatus,
|
|
751
|
+
"validityStatus" to it.validityStatus,
|
|
752
|
+
"availableSourceList" to it.availableSourceList.toJson(::generateDocumentReaderTextSource),
|
|
753
|
+
"fields" to it.fields.toJson(::generateDocumentReaderTextField)
|
|
754
|
+
).toJson()
|
|
911
755
|
}
|
|
912
756
|
|
|
913
|
-
fun coordinateFromJSON(
|
|
914
|
-
temp ?: return null
|
|
915
|
-
val input: JSONObject = temp
|
|
757
|
+
fun coordinateFromJSON(input: JSONObject?) = input?.let {
|
|
916
758
|
val result = Coordinate()
|
|
917
|
-
|
|
918
|
-
result.
|
|
919
|
-
result
|
|
920
|
-
|
|
921
|
-
return result
|
|
759
|
+
result.x = it.optInt("x")
|
|
760
|
+
result.y = it.optInt("y")
|
|
761
|
+
result
|
|
922
762
|
}
|
|
923
763
|
|
|
924
|
-
fun generateCoordinate(
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
result.put("x", input.x)
|
|
930
|
-
result.put("y", input.y)
|
|
931
|
-
|
|
932
|
-
return result
|
|
764
|
+
fun generateCoordinate(input: Coordinate?) = input?.let {
|
|
765
|
+
mapOf(
|
|
766
|
+
"x" to it.x,
|
|
767
|
+
"y" to it.y
|
|
768
|
+
).toJson()
|
|
933
769
|
}
|
|
934
770
|
|
|
935
|
-
fun elementPositionFromJSON(
|
|
936
|
-
temp ?: return null
|
|
937
|
-
val input: JSONObject = temp
|
|
771
|
+
fun elementPositionFromJSON(input: JSONObject?) = input?.let {
|
|
938
772
|
val result = ElementPosition()
|
|
939
773
|
|
|
940
|
-
result.docFormat =
|
|
941
|
-
result.width =
|
|
942
|
-
result.height =
|
|
943
|
-
result.dpi =
|
|
944
|
-
result.pageIndex =
|
|
945
|
-
result.inverse =
|
|
946
|
-
result.perspectiveTr =
|
|
947
|
-
result.objArea =
|
|
948
|
-
result.objIntAngleDev =
|
|
949
|
-
result.resultStatus =
|
|
950
|
-
result.angle =
|
|
951
|
-
result.center = coordinateFromJSON(
|
|
952
|
-
result.leftTop = coordinateFromJSON(
|
|
953
|
-
result.leftBottom = coordinateFromJSON(
|
|
954
|
-
result.rightTop = coordinateFromJSON(
|
|
955
|
-
result.rightBottom = coordinateFromJSON(
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
fun generateElementPosition(
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
return result
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
fun imageQualityFromJSON(temp: JSONObject?): ImageQuality? {
|
|
986
|
-
temp ?: return null
|
|
987
|
-
val input: JSONObject = temp
|
|
774
|
+
result.docFormat = it.optInt("docFormat")
|
|
775
|
+
result.width = it.optInt("width")
|
|
776
|
+
result.height = it.optInt("height")
|
|
777
|
+
result.dpi = it.optInt("dpi")
|
|
778
|
+
result.pageIndex = it.optInt("pageIndex")
|
|
779
|
+
result.inverse = it.optInt("inverse")
|
|
780
|
+
result.perspectiveTr = it.optInt("perspectiveTr")
|
|
781
|
+
result.objArea = it.optInt("objArea")
|
|
782
|
+
result.objIntAngleDev = it.optInt("objIntAngleDev")
|
|
783
|
+
result.resultStatus = it.optInt("resultStatus")
|
|
784
|
+
result.angle = it.optDouble("angle")
|
|
785
|
+
result.center = coordinateFromJSON(it.optJSONObject("center"))
|
|
786
|
+
result.leftTop = coordinateFromJSON(it.optJSONObject("leftTop"))
|
|
787
|
+
result.leftBottom = coordinateFromJSON(it.optJSONObject("leftBottom"))
|
|
788
|
+
result.rightTop = coordinateFromJSON(it.optJSONObject("rightTop"))
|
|
789
|
+
result.rightBottom = coordinateFromJSON(it.optJSONObject("rightBottom"))
|
|
790
|
+
|
|
791
|
+
result
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
fun generateElementPosition(input: ElementPosition?) = input?.let {
|
|
795
|
+
mapOf(
|
|
796
|
+
"docFormat" to it.docFormat,
|
|
797
|
+
"width" to it.width,
|
|
798
|
+
"height" to it.height,
|
|
799
|
+
"dpi" to it.dpi,
|
|
800
|
+
"pageIndex" to it.pageIndex,
|
|
801
|
+
"inverse" to it.inverse,
|
|
802
|
+
"perspectiveTr" to it.perspectiveTr,
|
|
803
|
+
"objArea" to it.objArea,
|
|
804
|
+
"objIntAngleDev" to it.objIntAngleDev,
|
|
805
|
+
"resultStatus" to it.resultStatus,
|
|
806
|
+
"angle" to it.angle,
|
|
807
|
+
"center" to generateCoordinate(it.center),
|
|
808
|
+
"leftTop" to generateCoordinate(it.leftTop),
|
|
809
|
+
"leftBottom" to generateCoordinate(it.leftBottom),
|
|
810
|
+
"rightTop" to generateCoordinate(it.rightTop),
|
|
811
|
+
"rightBottom" to generateCoordinate(it.rightBottom)
|
|
812
|
+
).toJson()
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
fun imageQualityFromJSON(input: JSONObject?) = input?.let {
|
|
988
816
|
val result = ImageQuality()
|
|
989
817
|
|
|
990
|
-
result.featureType =
|
|
991
|
-
result.result =
|
|
992
|
-
result.type =
|
|
993
|
-
result.boundRects =
|
|
818
|
+
result.featureType = it.optInt("featureType")
|
|
819
|
+
result.result = it.optInt("result")
|
|
820
|
+
result.type = it.optInt("type")
|
|
821
|
+
result.boundRects = it.optJSONArray("boundRects").toList(::docReaderFieldRectFromJSON)!!
|
|
994
822
|
|
|
995
|
-
|
|
823
|
+
result
|
|
996
824
|
}
|
|
997
825
|
|
|
998
|
-
fun generateImageQuality(
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
result.put("type", input.type)
|
|
1006
|
-
result.put("boundRects", generateList(input.boundRects, ::generateDocReaderFieldRect))
|
|
1007
|
-
|
|
1008
|
-
return result
|
|
826
|
+
fun generateImageQuality(input: ImageQuality?) = input?.let {
|
|
827
|
+
mapOf(
|
|
828
|
+
"featureType" to it.featureType,
|
|
829
|
+
"result" to it.result,
|
|
830
|
+
"type" to it.type,
|
|
831
|
+
"boundRects" to it.boundRects.toJson(::generateDocReaderFieldRect)
|
|
832
|
+
).toJson()
|
|
1009
833
|
}
|
|
1010
834
|
|
|
1011
|
-
fun imageQualityGroupFromJSON(
|
|
1012
|
-
temp ?: return null
|
|
1013
|
-
val input: JSONObject = temp
|
|
835
|
+
fun imageQualityGroupFromJSON(input: JSONObject?) = input?.let {
|
|
1014
836
|
val result = ImageQualityGroup()
|
|
1015
837
|
|
|
1016
|
-
result.count =
|
|
1017
|
-
result.result =
|
|
1018
|
-
result.pageIndex =
|
|
1019
|
-
result.imageQualityList =
|
|
838
|
+
result.count = it.optInt("count")
|
|
839
|
+
result.result = it.optInt("result")
|
|
840
|
+
result.pageIndex = it.optInt("pageIndex")
|
|
841
|
+
result.imageQualityList = it.optJSONArray("imageQualityList").toList(::imageQualityFromJSON)!!
|
|
1020
842
|
|
|
1021
|
-
|
|
843
|
+
result
|
|
1022
844
|
}
|
|
1023
845
|
|
|
1024
|
-
fun generateImageQualityGroup(
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
result.put("imageQualityList", generateList(input.imageQualityList, ::generateImageQuality))
|
|
1032
|
-
result.put("pageIndex", input.pageIndex)
|
|
1033
|
-
|
|
1034
|
-
return result
|
|
846
|
+
fun generateImageQualityGroup(input: ImageQualityGroup?) = input?.let {
|
|
847
|
+
mapOf(
|
|
848
|
+
"count" to it.count,
|
|
849
|
+
"result" to it.result,
|
|
850
|
+
"imageQualityList" to it.imageQualityList.toJson(::generateImageQuality),
|
|
851
|
+
"pageIndex" to it.pageIndex
|
|
852
|
+
).toJson()
|
|
1035
853
|
}
|
|
1036
854
|
|
|
1037
|
-
fun cameraSizeFromJSON(input: JSONObject)
|
|
1038
|
-
val width =
|
|
1039
|
-
val height =
|
|
1040
|
-
|
|
855
|
+
fun cameraSizeFromJSON(input: JSONObject) = input.let {
|
|
856
|
+
val width = it.getInt("width")
|
|
857
|
+
val height = it.getInt("height")
|
|
858
|
+
Pair(width, height)
|
|
1041
859
|
}
|
|
1042
860
|
|
|
1043
861
|
fun generateCameraSize(width: Int?, height: Int?): JSONObject? {
|
|
1044
862
|
width ?: return null
|
|
1045
863
|
height ?: return null
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
864
|
+
return mapOf(
|
|
865
|
+
"width" to width,
|
|
866
|
+
"height" to height
|
|
867
|
+
).toJson()
|
|
1050
868
|
}
|
|
1051
869
|
|
|
1052
|
-
fun documentReaderDocumentTypeFromJSON(
|
|
1053
|
-
temp ?: return null
|
|
1054
|
-
val input: JSONObject = temp
|
|
870
|
+
fun documentReaderDocumentTypeFromJSON(input: JSONObject?) = input?.let {
|
|
1055
871
|
val result = DocumentReaderDocumentType()
|
|
1056
872
|
|
|
1057
|
-
result.pageIndex =
|
|
1058
|
-
result.documentID =
|
|
1059
|
-
result.dType =
|
|
1060
|
-
result.dFormat =
|
|
1061
|
-
result.dMRZ =
|
|
1062
|
-
result.isDeprecated =
|
|
1063
|
-
result.name =
|
|
1064
|
-
result.ICAOCode =
|
|
1065
|
-
result.dDescription =
|
|
1066
|
-
result.dCountryName =
|
|
1067
|
-
result.dYear =
|
|
1068
|
-
result.FDSID =
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
fun generateDocumentReaderDocumentType(
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
result.put("notificationCode", input.notificationCode)
|
|
1100
|
-
result.put("dataFileType", input.dataFileType)
|
|
1101
|
-
result.put("progress", input.progress)
|
|
1102
|
-
|
|
1103
|
-
return result
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
fun accessControlProcedureTypeFromJSON(temp: JSONObject?): AccessControlProcedureType? {
|
|
1107
|
-
temp ?: return null
|
|
1108
|
-
val input: JSONObject = temp
|
|
873
|
+
result.pageIndex = it.optInt("pageIndex")
|
|
874
|
+
result.documentID = it.optInt("documentID")
|
|
875
|
+
result.dType = it.optInt("dType")
|
|
876
|
+
result.dFormat = it.optInt("dFormat")
|
|
877
|
+
result.dMRZ = it.optBoolean("dMRZ")
|
|
878
|
+
result.isDeprecated = it.optBoolean("isDeprecated")
|
|
879
|
+
result.name = it.optString("name")
|
|
880
|
+
result.ICAOCode = it.optString("ICAOCode")
|
|
881
|
+
result.dDescription = it.optString("dDescription")
|
|
882
|
+
result.dCountryName = it.optString("dCountryName")
|
|
883
|
+
result.dYear = it.optString("dYear")
|
|
884
|
+
result.FDSID = it.optJSONArray("FDSID").toIntArray()
|
|
885
|
+
|
|
886
|
+
result
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
fun generateDocumentReaderDocumentType(input: DocumentReaderDocumentType?) = input?.let {
|
|
890
|
+
mapOf(
|
|
891
|
+
"pageIndex" to it.pageIndex,
|
|
892
|
+
"documentID" to it.documentID,
|
|
893
|
+
"dType" to it.dType,
|
|
894
|
+
"dFormat" to it.dFormat,
|
|
895
|
+
"dMRZ" to it.dMRZ,
|
|
896
|
+
"isDeprecated" to it.isDeprecated,
|
|
897
|
+
"name" to it.name,
|
|
898
|
+
"ICAOCode" to it.ICAOCode,
|
|
899
|
+
"dDescription" to it.dDescription,
|
|
900
|
+
"dYear" to it.dYear,
|
|
901
|
+
"dCountryName" to it.dCountryName,
|
|
902
|
+
"FDSID" to it.FDSID.toJson()
|
|
903
|
+
).toJson()
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
fun generateDocumentReaderNotification(input: DocumentReaderNotification?) = input?.let {
|
|
907
|
+
mapOf(
|
|
908
|
+
"notificationCode" to it.notificationCode,
|
|
909
|
+
"dataFileType" to it.dataFileType,
|
|
910
|
+
"progress" to it.progress
|
|
911
|
+
).toJson()
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
fun accessControlProcedureTypeFromJSON(input: JSONObject?) = input?.let {
|
|
1109
915
|
val result = AccessControlProcedureType()
|
|
1110
916
|
|
|
1111
|
-
result.activeOptionIdx =
|
|
1112
|
-
result.type =
|
|
1113
|
-
result.status =
|
|
1114
|
-
result.notifications =
|
|
917
|
+
result.activeOptionIdx = it.optInt("activeOptionIdx")
|
|
918
|
+
result.type = it.optInt("type")
|
|
919
|
+
result.status = it.optInt("status").toLong()
|
|
920
|
+
result.notifications = it.optJSONArray("notifications")!!.toList()
|
|
1115
921
|
|
|
1116
|
-
|
|
922
|
+
result
|
|
1117
923
|
}
|
|
1118
924
|
|
|
1119
|
-
fun generateAccessControlProcedureType(
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
result.put("status", input.status)
|
|
1127
|
-
result.put("notifications", generateList(input.notifications))
|
|
1128
|
-
|
|
1129
|
-
return result
|
|
925
|
+
fun generateAccessControlProcedureType(input: AccessControlProcedureType?) = input?.let {
|
|
926
|
+
mapOf(
|
|
927
|
+
"activeOptionIdx" to it.activeOptionIdx,
|
|
928
|
+
"type" to it.type,
|
|
929
|
+
"status" to it.status,
|
|
930
|
+
"notifications" to it.notifications.toJson()
|
|
931
|
+
).toJson()
|
|
1130
932
|
}
|
|
1131
933
|
|
|
1132
|
-
fun fileDataFromJSON(
|
|
1133
|
-
temp ?: return null
|
|
1134
|
-
val input: JSONObject = temp
|
|
934
|
+
fun fileDataFromJSON(input: JSONObject?) = input?.let {
|
|
1135
935
|
val result = FileData()
|
|
1136
936
|
|
|
1137
|
-
result.length =
|
|
1138
|
-
result.type =
|
|
1139
|
-
result.status =
|
|
1140
|
-
result.data =
|
|
937
|
+
result.length = it.optInt("length")
|
|
938
|
+
result.type = it.optInt("type")
|
|
939
|
+
result.status = it.optInt("status").toLong()
|
|
940
|
+
result.data = it.optString("data")
|
|
1141
941
|
|
|
1142
|
-
|
|
942
|
+
result
|
|
1143
943
|
}
|
|
1144
944
|
|
|
1145
|
-
fun generateFileData(
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
result.put("status", input.status)
|
|
1153
|
-
result.put("data", input.data)
|
|
1154
|
-
|
|
1155
|
-
return result
|
|
945
|
+
fun generateFileData(input: FileData?) = input?.let {
|
|
946
|
+
mapOf(
|
|
947
|
+
"length" to it.length,
|
|
948
|
+
"type" to it.type,
|
|
949
|
+
"status" to it.status,
|
|
950
|
+
"data" to it.data
|
|
951
|
+
).toJson()
|
|
1156
952
|
}
|
|
1157
953
|
|
|
1158
|
-
fun certificateDataFromJSON(
|
|
1159
|
-
temp ?: return null
|
|
1160
|
-
val input: JSONObject = temp
|
|
954
|
+
fun certificateDataFromJSON(input: JSONObject?) = input?.let {
|
|
1161
955
|
val result = CertificateData()
|
|
1162
|
-
|
|
1163
|
-
result.
|
|
1164
|
-
result
|
|
1165
|
-
|
|
1166
|
-
return result
|
|
956
|
+
result.length = it.optInt("length")
|
|
957
|
+
result.data = it.optString("data")
|
|
958
|
+
result
|
|
1167
959
|
}
|
|
1168
960
|
|
|
1169
|
-
fun generateCertificateData(
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
result.put("length", input.length)
|
|
1175
|
-
result.put("data", input.data)
|
|
1176
|
-
|
|
1177
|
-
return result
|
|
961
|
+
fun generateCertificateData(input: CertificateData?) = input?.let {
|
|
962
|
+
mapOf(
|
|
963
|
+
"length" to it.length,
|
|
964
|
+
"data" to it.data
|
|
965
|
+
).toJson()
|
|
1178
966
|
}
|
|
1179
967
|
|
|
1180
|
-
fun securityObjectCertificatesFromJSON(
|
|
1181
|
-
temp ?: return null
|
|
1182
|
-
val input: JSONObject = temp
|
|
968
|
+
fun securityObjectCertificatesFromJSON(input: JSONObject?) = input?.let {
|
|
1183
969
|
val result = SecurityObjectCertificates()
|
|
1184
|
-
|
|
1185
|
-
result
|
|
1186
|
-
|
|
1187
|
-
return result
|
|
970
|
+
result.securityObject = certificateDataFromJSON(it.optJSONObject("securityObject"))
|
|
971
|
+
result
|
|
1188
972
|
}
|
|
1189
973
|
|
|
1190
|
-
fun generateSecurityObjectCertificates(
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
result.put("securityObject", generateCertificateData(input.securityObject))
|
|
1196
|
-
|
|
1197
|
-
return result
|
|
974
|
+
fun generateSecurityObjectCertificates(input: SecurityObjectCertificates?) = input?.let {
|
|
975
|
+
mapOf(
|
|
976
|
+
"securityObject" to generateCertificateData(it.securityObject)
|
|
977
|
+
).toJson()
|
|
1198
978
|
}
|
|
1199
979
|
|
|
1200
|
-
fun fileFromJSON(
|
|
1201
|
-
temp ?: return null
|
|
1202
|
-
val input: JSONObject = temp
|
|
980
|
+
fun fileFromJSON(input: JSONObject?) = input?.let {
|
|
1203
981
|
val result = File()
|
|
1204
982
|
|
|
1205
|
-
result.readingTime =
|
|
1206
|
-
result.type =
|
|
1207
|
-
result.pAStatus =
|
|
1208
|
-
result.readingStatus =
|
|
1209
|
-
result.fileID =
|
|
1210
|
-
result.fileData = fileDataFromJSON(
|
|
1211
|
-
result.certificates = securityObjectCertificatesFromJSON(
|
|
1212
|
-
result.docFieldsText =
|
|
1213
|
-
result.docFieldsGraphics =
|
|
1214
|
-
result.docFieldsOriginals =
|
|
1215
|
-
result.notifications =
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
fun generateFile(
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
return result
|
|
1239
|
-
}
|
|
1240
|
-
|
|
1241
|
-
fun applicationFromJSON(temp: JSONObject?): Application? {
|
|
1242
|
-
temp ?: return null
|
|
1243
|
-
val input: JSONObject = temp
|
|
983
|
+
result.readingTime = it.optInt("readingTime")
|
|
984
|
+
result.type = it.optInt("type")
|
|
985
|
+
result.pAStatus = it.optLong("pAStatus")
|
|
986
|
+
result.readingStatus = it.optInt("readingStatus").toLong()
|
|
987
|
+
result.fileID = it.optString("fileID")
|
|
988
|
+
result.fileData = fileDataFromJSON(it.optJSONObject("fileData"))
|
|
989
|
+
result.certificates = securityObjectCertificatesFromJSON(it.optJSONObject("certificates"))
|
|
990
|
+
result.docFieldsText = it.optJSONArray("docFieldsText")!!.toList()
|
|
991
|
+
result.docFieldsGraphics = it.optJSONArray("docFieldsGraphics")!!.toList()
|
|
992
|
+
result.docFieldsOriginals = it.optJSONArray("docFieldsOriginals")!!.toList()
|
|
993
|
+
result.notifications = it.optJSONArray("notifications")!!.toList()
|
|
994
|
+
|
|
995
|
+
result
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
fun generateFile(input: File?) = input?.let {
|
|
999
|
+
mapOf(
|
|
1000
|
+
"readingTime" to it.readingTime,
|
|
1001
|
+
"type" to it.type,
|
|
1002
|
+
"typeName" to eRFID_DataFile_Type.getTranslation(context, it.type),
|
|
1003
|
+
"pAStatus" to it.pAStatus,
|
|
1004
|
+
"readingStatus" to it.readingStatus,
|
|
1005
|
+
"fileID" to it.fileID,
|
|
1006
|
+
"fileData" to generateFileData(it.fileData),
|
|
1007
|
+
"certificates" to generateSecurityObjectCertificates(it.certificates),
|
|
1008
|
+
"docFieldsText" to it.docFieldsText.toJson(),
|
|
1009
|
+
"docFieldsGraphics" to it.docFieldsGraphics.toJson(),
|
|
1010
|
+
"docFieldsOriginals" to it.docFieldsOriginals.toJson(),
|
|
1011
|
+
"notifications" to it.notifications.toJson()
|
|
1012
|
+
).toJson()
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
fun applicationFromJSON(input: JSONObject?) = input?.let {
|
|
1244
1016
|
val result = Application()
|
|
1245
1017
|
|
|
1246
|
-
result.type =
|
|
1247
|
-
result.status =
|
|
1248
|
-
result.applicationID =
|
|
1249
|
-
result.dataHashAlgorithm =
|
|
1250
|
-
result.unicodeVersion =
|
|
1251
|
-
result.version =
|
|
1252
|
-
result.files =
|
|
1018
|
+
result.type = it.optInt("type")
|
|
1019
|
+
result.status = it.optInt("status")
|
|
1020
|
+
result.applicationID = it.optString("applicationID")
|
|
1021
|
+
result.dataHashAlgorithm = it.optString("dataHashAlgorithm")
|
|
1022
|
+
result.unicodeVersion = it.optString("unicodeVersion")
|
|
1023
|
+
result.version = it.optString("version")
|
|
1024
|
+
result.files = it.optJSONArray("files").toList(::fileFromJSON)!!
|
|
1253
1025
|
|
|
1254
|
-
|
|
1026
|
+
result
|
|
1255
1027
|
}
|
|
1256
1028
|
|
|
1257
|
-
fun generateApplication(
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
result.put("version", input.version)
|
|
1268
|
-
result.put("files", generateList(input.files, ::generateFile, context))
|
|
1269
|
-
|
|
1270
|
-
return result
|
|
1029
|
+
fun generateApplication(input: Application?) = input?.let {
|
|
1030
|
+
mapOf(
|
|
1031
|
+
"type" to it.type,
|
|
1032
|
+
"status" to it.status,
|
|
1033
|
+
"applicationID" to it.applicationID,
|
|
1034
|
+
"dataHashAlgorithm" to it.dataHashAlgorithm,
|
|
1035
|
+
"unicodeVersion" to it.unicodeVersion,
|
|
1036
|
+
"version" to it.version,
|
|
1037
|
+
"files" to it.files.toJson(::generateFile)
|
|
1038
|
+
).toJson()
|
|
1271
1039
|
}
|
|
1272
1040
|
|
|
1273
|
-
fun valueFromJSON(
|
|
1274
|
-
temp ?: return null
|
|
1275
|
-
val input: JSONObject = temp
|
|
1041
|
+
fun valueFromJSON(input: JSONObject?) = input?.let {
|
|
1276
1042
|
val result = Value()
|
|
1277
1043
|
|
|
1278
|
-
result.length =
|
|
1279
|
-
result.type =
|
|
1280
|
-
result.status =
|
|
1281
|
-
result.data =
|
|
1282
|
-
result.format =
|
|
1044
|
+
result.length = it.optInt("length")
|
|
1045
|
+
result.type = it.optInt("type")
|
|
1046
|
+
result.status = it.optInt("status").toLong()
|
|
1047
|
+
result.data = it.optString("data")
|
|
1048
|
+
result.format = it.optString("format")
|
|
1283
1049
|
|
|
1284
|
-
|
|
1050
|
+
result
|
|
1285
1051
|
}
|
|
1286
1052
|
|
|
1287
|
-
fun generateValue(
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
result.put("data", input.data)
|
|
1296
|
-
result.put("format", input.format)
|
|
1297
|
-
|
|
1298
|
-
return result
|
|
1053
|
+
fun generateValue(input: Value?) = input?.let {
|
|
1054
|
+
mapOf(
|
|
1055
|
+
"length" to it.length,
|
|
1056
|
+
"type" to it.type,
|
|
1057
|
+
"status" to it.status,
|
|
1058
|
+
"data" to it.data,
|
|
1059
|
+
"format" to it.format
|
|
1060
|
+
).toJson()
|
|
1299
1061
|
}
|
|
1300
1062
|
|
|
1301
|
-
fun attributeFromJSON(
|
|
1302
|
-
temp ?: return null
|
|
1303
|
-
val input: JSONObject = temp
|
|
1063
|
+
fun attributeFromJSON(input: JSONObject?) = input?.let {
|
|
1304
1064
|
val result = Attribute()
|
|
1305
|
-
|
|
1306
|
-
result.
|
|
1307
|
-
result
|
|
1308
|
-
|
|
1309
|
-
return result
|
|
1065
|
+
result.type = it.optString("type")
|
|
1066
|
+
result.value = valueFromJSON(it.optJSONObject("value"))
|
|
1067
|
+
result
|
|
1310
1068
|
}
|
|
1311
1069
|
|
|
1312
|
-
fun generateAttribute(
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
result.put("type", input.type)
|
|
1318
|
-
result.put("value", generateValue(input.value))
|
|
1319
|
-
|
|
1320
|
-
return result
|
|
1070
|
+
fun generateAttribute(input: Attribute?) = input?.let {
|
|
1071
|
+
mapOf(
|
|
1072
|
+
"type" to it.type,
|
|
1073
|
+
"value" to generateValue(it.value)
|
|
1074
|
+
).toJson()
|
|
1321
1075
|
}
|
|
1322
1076
|
|
|
1323
|
-
fun authorityFromJSON(
|
|
1324
|
-
temp ?: return null
|
|
1325
|
-
val input: JSONObject = temp
|
|
1077
|
+
fun authorityFromJSON(input: JSONObject?) = input?.let {
|
|
1326
1078
|
val result = Authority()
|
|
1327
|
-
|
|
1328
|
-
result.
|
|
1329
|
-
result.
|
|
1330
|
-
result
|
|
1331
|
-
|
|
1332
|
-
return result
|
|
1079
|
+
result.data = it.optString("data")
|
|
1080
|
+
result.friendlyName = valueFromJSON(it.optJSONObject("friendlyName"))
|
|
1081
|
+
result.attributes = it.optJSONArray("attributes").toList(::attributeFromJSON)!!
|
|
1082
|
+
result
|
|
1333
1083
|
}
|
|
1334
1084
|
|
|
1335
|
-
fun generateAuthority(
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
result.put("friendlyName", generateValue(input.friendlyName))
|
|
1342
|
-
result.put("attributes", generateList(input.attributes, ::generateAttribute))
|
|
1343
|
-
|
|
1344
|
-
return result
|
|
1085
|
+
fun generateAuthority(input: Authority?) = input?.let {
|
|
1086
|
+
mapOf(
|
|
1087
|
+
"data" to it.data,
|
|
1088
|
+
"friendlyName" to generateValue(it.friendlyName),
|
|
1089
|
+
"attributes" to it.attributes.toJson(::generateAttribute)
|
|
1090
|
+
).toJson()
|
|
1345
1091
|
}
|
|
1346
1092
|
|
|
1347
|
-
fun extensionFromJSON(
|
|
1348
|
-
temp ?: return null
|
|
1349
|
-
val input: JSONObject = temp
|
|
1093
|
+
fun extensionFromJSON(input: JSONObject?) = input?.let {
|
|
1350
1094
|
val result = Extension()
|
|
1351
|
-
|
|
1352
|
-
result.
|
|
1353
|
-
result
|
|
1354
|
-
|
|
1355
|
-
return result
|
|
1095
|
+
result.data = it.optString("data")
|
|
1096
|
+
result.type = it.optString("type")
|
|
1097
|
+
result
|
|
1356
1098
|
}
|
|
1357
1099
|
|
|
1358
|
-
fun generateExtension(
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
result.put("data", input.data)
|
|
1364
|
-
result.put("type", input.type)
|
|
1365
|
-
|
|
1366
|
-
return result
|
|
1100
|
+
fun generateExtension(input: Extension?) = input?.let {
|
|
1101
|
+
mapOf(
|
|
1102
|
+
"data" to it.data,
|
|
1103
|
+
"type" to it.type
|
|
1104
|
+
).toJson()
|
|
1367
1105
|
}
|
|
1368
1106
|
|
|
1369
|
-
fun validityFromJSON(
|
|
1370
|
-
temp ?: return null
|
|
1371
|
-
val input: JSONObject = temp
|
|
1107
|
+
fun validityFromJSON(input: JSONObject?) = input?.let {
|
|
1372
1108
|
val result = Validity()
|
|
1373
|
-
|
|
1374
|
-
result.
|
|
1375
|
-
result
|
|
1376
|
-
|
|
1377
|
-
return result
|
|
1109
|
+
result.notAfter = valueFromJSON(it.optJSONObject("notAfter"))
|
|
1110
|
+
result.notBefore = valueFromJSON(it.optJSONObject("notBefore"))
|
|
1111
|
+
result
|
|
1378
1112
|
}
|
|
1379
1113
|
|
|
1380
|
-
fun generateValidity(
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
result.put("notAfter", generateValue(input.notAfter))
|
|
1386
|
-
result.put("notBefore", generateValue(input.notBefore))
|
|
1387
|
-
|
|
1388
|
-
return result
|
|
1114
|
+
fun generateValidity(input: Validity?) = input?.let {
|
|
1115
|
+
mapOf(
|
|
1116
|
+
"notAfter" to generateValue(it.notAfter),
|
|
1117
|
+
"notBefore" to generateValue(it.notBefore)
|
|
1118
|
+
).toJson()
|
|
1389
1119
|
}
|
|
1390
1120
|
|
|
1391
|
-
fun certificateChainFromJSON(
|
|
1392
|
-
temp ?: return null
|
|
1393
|
-
val input: JSONObject = temp
|
|
1121
|
+
fun certificateChainFromJSON(input: JSONObject?) = input?.let {
|
|
1394
1122
|
val result = CertificateChain()
|
|
1395
1123
|
|
|
1396
|
-
result.origin =
|
|
1397
|
-
result.type =
|
|
1398
|
-
result.version =
|
|
1399
|
-
result.paStatus =
|
|
1400
|
-
result.serialNumber =
|
|
1401
|
-
result.signatureAlgorithm =
|
|
1402
|
-
result.subjectPKAlgorithm =
|
|
1403
|
-
result.fileName = valueFromJSON(
|
|
1404
|
-
result.validity = validityFromJSON(
|
|
1405
|
-
result.issuer = authorityFromJSON(
|
|
1406
|
-
result.subject = authorityFromJSON(
|
|
1407
|
-
result.notifications =
|
|
1408
|
-
result.extensions =
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
}
|
|
1412
|
-
|
|
1413
|
-
fun generateCertificateChain(
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
return result
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
fun signerInfoFromJSON(temp: JSONObject?): SignerInfo? {
|
|
1436
|
-
temp ?: return null
|
|
1437
|
-
val input: JSONObject = temp
|
|
1124
|
+
result.origin = it.optInt("origin")
|
|
1125
|
+
result.type = it.optInt("type")
|
|
1126
|
+
result.version = it.optInt("version")
|
|
1127
|
+
result.paStatus = it.optInt("paStatus").toLong()
|
|
1128
|
+
result.serialNumber = it.optString("serialNumber")
|
|
1129
|
+
result.signatureAlgorithm = it.optString("signatureAlgorithm")
|
|
1130
|
+
result.subjectPKAlgorithm = it.optString("subjectPKAlgorithm")
|
|
1131
|
+
result.fileName = valueFromJSON(it.optJSONObject("fileName"))
|
|
1132
|
+
result.validity = validityFromJSON(it.optJSONObject("validity"))
|
|
1133
|
+
result.issuer = authorityFromJSON(it.optJSONObject("issuer"))
|
|
1134
|
+
result.subject = authorityFromJSON(it.optJSONObject("subject"))
|
|
1135
|
+
result.notifications = it.optJSONArray("notifications")!!.toList()
|
|
1136
|
+
result.extensions = it.optJSONArray("extensions").toList(::extensionFromJSON)!!
|
|
1137
|
+
|
|
1138
|
+
result
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
fun generateCertificateChain(input: CertificateChain?) = input?.let {
|
|
1142
|
+
mapOf(
|
|
1143
|
+
"origin" to it.origin,
|
|
1144
|
+
"type" to it.type,
|
|
1145
|
+
"version" to it.version,
|
|
1146
|
+
"paStatus" to it.paStatus,
|
|
1147
|
+
"serialNumber" to it.serialNumber,
|
|
1148
|
+
"signatureAlgorithm" to it.signatureAlgorithm,
|
|
1149
|
+
"subjectPKAlgorithm" to it.subjectPKAlgorithm,
|
|
1150
|
+
"fileName" to generateValue(it.fileName),
|
|
1151
|
+
"validity" to generateValidity(it.validity),
|
|
1152
|
+
"issuer" to generateAuthority(it.issuer),
|
|
1153
|
+
"subject" to generateAuthority(it.subject),
|
|
1154
|
+
"notifications" to it.notifications.toJson(),
|
|
1155
|
+
"extensions" to it.extensions.toJson(::generateExtension)
|
|
1156
|
+
).toJson()
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
fun signerInfoFromJSON(input: JSONObject?) = input?.let {
|
|
1438
1160
|
val result = SignerInfo()
|
|
1439
1161
|
|
|
1440
|
-
result.version =
|
|
1441
|
-
result.paStatus =
|
|
1442
|
-
result.dataToHash =
|
|
1443
|
-
result.digestAlgorithm =
|
|
1444
|
-
result.signatureAlgorithm =
|
|
1445
|
-
result.serialNumber = valueFromJSON(
|
|
1446
|
-
result.signature = valueFromJSON(
|
|
1447
|
-
result.subjectKeyIdentifier = valueFromJSON(
|
|
1448
|
-
result.issuer = authorityFromJSON(
|
|
1449
|
-
result.notifications =
|
|
1450
|
-
result.signedAttributes =
|
|
1451
|
-
result.certificateChain =
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
}
|
|
1455
|
-
|
|
1456
|
-
fun generateSignerInfo(
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
return result
|
|
1475
|
-
}
|
|
1476
|
-
|
|
1477
|
-
fun securityObjectFromJSON(temp: JSONObject?): SecurityObject? {
|
|
1478
|
-
temp ?: return null
|
|
1479
|
-
val input: JSONObject = temp
|
|
1162
|
+
result.version = it.optInt("version")
|
|
1163
|
+
result.paStatus = it.optInt("paStatus").toLong()
|
|
1164
|
+
result.dataToHash = it.optString("dataToHash")
|
|
1165
|
+
result.digestAlgorithm = it.optString("digestAlgorithm")
|
|
1166
|
+
result.signatureAlgorithm = it.optString("signatureAlgorithm")
|
|
1167
|
+
result.serialNumber = valueFromJSON(it.optJSONObject("serialNumber"))
|
|
1168
|
+
result.signature = valueFromJSON(it.optJSONObject("signature"))
|
|
1169
|
+
result.subjectKeyIdentifier = valueFromJSON(it.optJSONObject("subjectKeyIdentifier"))
|
|
1170
|
+
result.issuer = authorityFromJSON(it.optJSONObject("issuer"))
|
|
1171
|
+
result.notifications = it.optJSONArray("notifications")!!.toList()
|
|
1172
|
+
result.signedAttributes = it.optJSONArray("signedAttributes").toList(::extensionFromJSON)!!
|
|
1173
|
+
result.certificateChain = it.optJSONArray("certificateChain").toList(::certificateChainFromJSON)!!
|
|
1174
|
+
|
|
1175
|
+
result
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
fun generateSignerInfo(input: SignerInfo?) = input?.let {
|
|
1179
|
+
mapOf(
|
|
1180
|
+
"version" to it.version,
|
|
1181
|
+
"paStatus" to it.paStatus,
|
|
1182
|
+
"dataToHash" to it.dataToHash,
|
|
1183
|
+
"digestAlgorithm" to it.digestAlgorithm,
|
|
1184
|
+
"signatureAlgorithm" to it.signatureAlgorithm,
|
|
1185
|
+
"serialNumber" to generateValue(it.serialNumber),
|
|
1186
|
+
"signature" to generateValue(it.signature),
|
|
1187
|
+
"subjectKeyIdentifier" to generateValue(it.subjectKeyIdentifier),
|
|
1188
|
+
"issuer" to generateAuthority(it.issuer),
|
|
1189
|
+
"notifications" to it.notifications.toJson(),
|
|
1190
|
+
"signedAttributes" to it.signedAttributes.toJson(::generateExtension),
|
|
1191
|
+
"certificateChain" to it.certificateChain.toJson(::generateCertificateChain)
|
|
1192
|
+
).toJson()
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
fun securityObjectFromJSON(input: JSONObject?) = input?.let {
|
|
1480
1196
|
val result = SecurityObject()
|
|
1481
1197
|
|
|
1482
|
-
result.fileReference =
|
|
1483
|
-
result.version =
|
|
1484
|
-
result.objectType =
|
|
1485
|
-
result.notifications =
|
|
1486
|
-
result.signerInfos =
|
|
1198
|
+
result.fileReference = it.optInt("fileReference")
|
|
1199
|
+
result.version = it.optInt("version")
|
|
1200
|
+
result.objectType = it.optString("objectType")
|
|
1201
|
+
result.notifications = it.optJSONArray("notifications")!!.toList()
|
|
1202
|
+
result.signerInfos = it.optJSONArray("signerInfos").toList(::signerInfoFromJSON)!!
|
|
1487
1203
|
|
|
1488
|
-
|
|
1204
|
+
result
|
|
1489
1205
|
}
|
|
1490
1206
|
|
|
1491
|
-
fun generateSecurityObject(
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
result.put("notifications", generateList(input.notifications))
|
|
1500
|
-
result.put("signerInfos", generateList(input.signerInfos, ::generateSignerInfo))
|
|
1501
|
-
|
|
1502
|
-
return result
|
|
1207
|
+
fun generateSecurityObject(input: SecurityObject?) = input?.let {
|
|
1208
|
+
mapOf(
|
|
1209
|
+
"fileReference" to it.fileReference,
|
|
1210
|
+
"version" to it.version,
|
|
1211
|
+
"objectType" to it.objectType,
|
|
1212
|
+
"notifications" to it.notifications.toJson(),
|
|
1213
|
+
"signerInfos" to it.signerInfos.toJson(::generateSignerInfo)
|
|
1214
|
+
).toJson()
|
|
1503
1215
|
}
|
|
1504
1216
|
|
|
1505
|
-
fun cardPropertiesFromJSON(
|
|
1506
|
-
temp ?: return null
|
|
1507
|
-
val input: JSONObject = temp
|
|
1217
|
+
fun cardPropertiesFromJSON(input: JSONObject?) = input?.let {
|
|
1508
1218
|
val result = CardProperties()
|
|
1509
1219
|
|
|
1510
|
-
result.aTQA =
|
|
1511
|
-
result.bitRateR =
|
|
1512
|
-
result.bitRateS =
|
|
1513
|
-
result.chipTypeA =
|
|
1514
|
-
result.mifareMemory =
|
|
1515
|
-
result.rfidType =
|
|
1516
|
-
result.sAK =
|
|
1517
|
-
result.support4 =
|
|
1518
|
-
result.supportMifare =
|
|
1519
|
-
result.aTQB =
|
|
1520
|
-
result.aTR =
|
|
1521
|
-
result.baudrate1 =
|
|
1522
|
-
result.baudrate2 =
|
|
1523
|
-
result.uID =
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
fun generateCardProperties(
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
return result
|
|
1549
|
-
}
|
|
1550
|
-
|
|
1551
|
-
fun rfidSessionDataFromJSON(temp: JSONObject?): RFIDSessionData? {
|
|
1552
|
-
temp ?: return null
|
|
1553
|
-
val input: JSONObject = temp
|
|
1220
|
+
result.aTQA = it.optInt("aTQA")
|
|
1221
|
+
result.bitRateR = it.optInt("bitRateR")
|
|
1222
|
+
result.bitRateS = it.optInt("bitRateS")
|
|
1223
|
+
result.chipTypeA = it.optInt("chipTypeA")
|
|
1224
|
+
result.mifareMemory = it.optInt("mifareMemory")
|
|
1225
|
+
result.rfidType = it.optInt("rfidType")
|
|
1226
|
+
result.sAK = it.optInt("sAK")
|
|
1227
|
+
result.support4 = it.optBoolean("support4")
|
|
1228
|
+
result.supportMifare = it.optBoolean("supportMifare")
|
|
1229
|
+
result.aTQB = it.optString("aTQB")
|
|
1230
|
+
result.aTR = it.optString("aTR")
|
|
1231
|
+
result.baudrate1 = it.optString("baudrate1")
|
|
1232
|
+
result.baudrate2 = it.optString("baudrate2")
|
|
1233
|
+
result.uID = it.optString("uID")
|
|
1234
|
+
|
|
1235
|
+
result
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
fun generateCardProperties(input: CardProperties?) = input?.let {
|
|
1239
|
+
mapOf(
|
|
1240
|
+
"aTQA" to it.aTQA,
|
|
1241
|
+
"bitRateR" to it.bitRateR,
|
|
1242
|
+
"bitRateS" to it.bitRateS,
|
|
1243
|
+
"chipTypeA" to it.chipTypeA,
|
|
1244
|
+
"mifareMemory" to it.mifareMemory,
|
|
1245
|
+
"rfidType" to it.rfidType,
|
|
1246
|
+
"sAK" to it.sAK,
|
|
1247
|
+
"support4" to it.support4,
|
|
1248
|
+
"supportMifare" to it.supportMifare,
|
|
1249
|
+
"aTQB" to it.aTQB,
|
|
1250
|
+
"aTR" to it.aTR,
|
|
1251
|
+
"baudrate1" to it.baudrate1,
|
|
1252
|
+
"baudrate2" to it.baudrate2,
|
|
1253
|
+
"uID" to it.uID
|
|
1254
|
+
).toJson()
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
fun rfidSessionDataFromJSON(input: JSONObject?) = input?.let {
|
|
1554
1258
|
val result = RFIDSessionData()
|
|
1555
1259
|
|
|
1556
|
-
result.totalBytesReceived =
|
|
1557
|
-
result.totalBytesSent =
|
|
1558
|
-
result.status =
|
|
1559
|
-
result.extLeSupport =
|
|
1560
|
-
result.processTime =
|
|
1561
|
-
result.cardProperties = cardPropertiesFromJSON(
|
|
1562
|
-
result.accessControls =
|
|
1563
|
-
result.applications =
|
|
1564
|
-
result.securityObjects =
|
|
1565
|
-
result.dataFields =
|
|
1566
|
-
result.dataGroups =
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
}
|
|
1570
|
-
|
|
1571
|
-
fun generateRFIDSessionData(
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
return result
|
|
1589
|
-
}
|
|
1590
|
-
|
|
1591
|
-
fun dataFieldFromJSON(temp: JSONObject?): DataField? {
|
|
1592
|
-
temp ?: return null
|
|
1593
|
-
val input: JSONObject = temp
|
|
1260
|
+
result.totalBytesReceived = it.optInt("totalBytesReceived")
|
|
1261
|
+
result.totalBytesSent = it.optInt("totalBytesSent")
|
|
1262
|
+
result.status = it.optInt("status").toLong()
|
|
1263
|
+
result.extLeSupport = it.optLong("extLeSupport")
|
|
1264
|
+
result.processTime = it.optLong("processTime")
|
|
1265
|
+
result.cardProperties = cardPropertiesFromJSON(it.optJSONObject("cardProperties"))
|
|
1266
|
+
result.accessControls = it.optJSONArray("accessControls").toList(::accessControlProcedureTypeFromJSON)!!
|
|
1267
|
+
result.applications = it.optJSONArray("applications").toList(::applicationFromJSON)!!
|
|
1268
|
+
result.securityObjects = it.optJSONArray("securityObjects").toList(::securityObjectFromJSON)!!
|
|
1269
|
+
result.dataFields = it.optJSONArray("dataFields").toList(::dataFieldFromJSON)!!
|
|
1270
|
+
result.dataGroups = it.optJSONArray("dataGroups").toIntArray()
|
|
1271
|
+
|
|
1272
|
+
result
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
fun generateRFIDSessionData(input: RFIDSessionData?) = input?.let {
|
|
1276
|
+
mapOf(
|
|
1277
|
+
"totalBytesReceived" to it.totalBytesReceived,
|
|
1278
|
+
"totalBytesSent" to it.totalBytesSent,
|
|
1279
|
+
"status" to it.status,
|
|
1280
|
+
"extLeSupport" to it.extLeSupport,
|
|
1281
|
+
"processTime" to it.processTime,
|
|
1282
|
+
"cardProperties" to generateCardProperties(it.cardProperties),
|
|
1283
|
+
"accessControls" to it.accessControls.toJson(::generateAccessControlProcedureType),
|
|
1284
|
+
"applications" to it.applications.toJson(::generateApplication),
|
|
1285
|
+
"securityObjects" to it.securityObjects.toJson(::generateSecurityObject),
|
|
1286
|
+
"dataGroups" to it.dataGroups.toJson(),
|
|
1287
|
+
"dataFields" to it.dataFields.toJson(::generateDataField)
|
|
1288
|
+
).toJson()
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
fun dataFieldFromJSON(input: JSONObject?) = input?.let {
|
|
1594
1292
|
val result = DataField()
|
|
1595
|
-
|
|
1596
|
-
result.
|
|
1597
|
-
result
|
|
1598
|
-
|
|
1599
|
-
return result
|
|
1293
|
+
result.data = it.optString("data")
|
|
1294
|
+
result.fieldType = it.optInt("fieldType")
|
|
1295
|
+
result
|
|
1600
1296
|
}
|
|
1601
1297
|
|
|
1602
|
-
fun generateDataField(
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
result.put("data", input.data)
|
|
1608
|
-
result.put("fieldType", input.fieldType)
|
|
1609
|
-
|
|
1610
|
-
return result
|
|
1298
|
+
fun generateDataField(input: DataField?) = input?.let {
|
|
1299
|
+
mapOf(
|
|
1300
|
+
"data" to it.data,
|
|
1301
|
+
"fieldType" to it.fieldType
|
|
1302
|
+
).toJson()
|
|
1611
1303
|
}
|
|
1612
1304
|
|
|
1613
|
-
fun documentReaderAuthenticityCheckFromJSON(
|
|
1614
|
-
temp ?: return null
|
|
1615
|
-
val input: JSONObject = temp
|
|
1305
|
+
fun documentReaderAuthenticityCheckFromJSON(input: JSONObject?) = input?.let {
|
|
1616
1306
|
val result = DocumentReaderAuthenticityCheck()
|
|
1617
|
-
|
|
1618
|
-
result.
|
|
1619
|
-
result.
|
|
1620
|
-
result
|
|
1621
|
-
|
|
1622
|
-
return result
|
|
1307
|
+
result.type = it.optInt("type")
|
|
1308
|
+
result.pageIndex = it.optInt("pageIndex")
|
|
1309
|
+
result.elements = it.optJSONArray("elements").toList(::documentReaderAuthenticityElementFromJSON)!!
|
|
1310
|
+
result
|
|
1623
1311
|
}
|
|
1624
1312
|
|
|
1625
|
-
fun generateDocumentReaderAuthenticityCheck(
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
result.put("pageIndex", input.pageIndex)
|
|
1634
|
-
result.put("elements", generateList(input.elements, ::generateDocumentReaderAuthenticityElement, context))
|
|
1635
|
-
|
|
1636
|
-
return result
|
|
1313
|
+
fun generateDocumentReaderAuthenticityCheck(input: DocumentReaderAuthenticityCheck?) = input?.let {
|
|
1314
|
+
mapOf(
|
|
1315
|
+
"type" to it.type,
|
|
1316
|
+
"status" to it.status,
|
|
1317
|
+
"typeName" to it.getTypeName(context),
|
|
1318
|
+
"pageIndex" to it.pageIndex,
|
|
1319
|
+
"elements" to it.elements.toJson(::generateDocumentReaderAuthenticityElement)
|
|
1320
|
+
).toJson()
|
|
1637
1321
|
}
|
|
1638
1322
|
|
|
1639
|
-
fun pdf417InfoFromJSON(
|
|
1640
|
-
temp ?: return null
|
|
1641
|
-
val input: JSONObject = temp
|
|
1323
|
+
fun pdf417InfoFromJSON(input: JSONObject?) = input?.let {
|
|
1642
1324
|
val result = PDF417Info()
|
|
1643
|
-
|
|
1644
|
-
result.
|
|
1645
|
-
result.
|
|
1646
|
-
result
|
|
1647
|
-
|
|
1648
|
-
return result
|
|
1325
|
+
result.errorLevel = it.optInt("errorLevel")
|
|
1326
|
+
result.columns = it.optInt("columns")
|
|
1327
|
+
result.rows = it.optInt("rows")
|
|
1328
|
+
result
|
|
1649
1329
|
}
|
|
1650
1330
|
|
|
1651
|
-
fun generatePDF417Info(
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
result.put("columns", input.columns)
|
|
1658
|
-
result.put("rows", input.rows)
|
|
1659
|
-
|
|
1660
|
-
return result
|
|
1331
|
+
fun generatePDF417Info(input: PDF417Info?) = input?.let {
|
|
1332
|
+
mapOf(
|
|
1333
|
+
"errorLevel" to it.errorLevel,
|
|
1334
|
+
"columns" to it.columns,
|
|
1335
|
+
"rows" to it.rows
|
|
1336
|
+
).toJson()
|
|
1661
1337
|
}
|
|
1662
1338
|
|
|
1663
|
-
fun documentReaderBarcodeResultFromJSON(
|
|
1664
|
-
temp ?: return null
|
|
1665
|
-
val input: JSONObject = temp
|
|
1339
|
+
fun documentReaderBarcodeResultFromJSON(input: JSONObject?) = input?.let {
|
|
1666
1340
|
val result = DocumentReaderBarcodeResult()
|
|
1667
|
-
|
|
1668
|
-
result
|
|
1669
|
-
|
|
1670
|
-
return result
|
|
1341
|
+
result.fields = it.optJSONArray("fields").toList(::documentReaderBarcodeFieldFromJSON)!!
|
|
1342
|
+
result
|
|
1671
1343
|
}
|
|
1672
1344
|
|
|
1673
|
-
fun generateDocumentReaderBarcodeResult(
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
result.put("fields", generateList(input.fields, ::generateDocumentReaderBarcodeField))
|
|
1679
|
-
|
|
1680
|
-
return result
|
|
1345
|
+
fun generateDocumentReaderBarcodeResult(input: DocumentReaderBarcodeResult?) = input?.let {
|
|
1346
|
+
mapOf(
|
|
1347
|
+
"fields" to it.fields.toJson(::generateDocumentReaderBarcodeField)
|
|
1348
|
+
).toJson()
|
|
1681
1349
|
}
|
|
1682
1350
|
|
|
1683
|
-
fun documentReaderBarcodeFieldFromJSON(
|
|
1684
|
-
temp ?: return null
|
|
1685
|
-
val input: JSONObject = temp
|
|
1351
|
+
fun documentReaderBarcodeFieldFromJSON(input: JSONObject?) = input?.let {
|
|
1686
1352
|
val result = DocumentReaderBarcodeField()
|
|
1687
1353
|
|
|
1688
|
-
result.barcodeType =
|
|
1689
|
-
result.status =
|
|
1690
|
-
result.pageIndex =
|
|
1691
|
-
result.pdf417Info = pdf417InfoFromJSON(
|
|
1692
|
-
result.data =
|
|
1354
|
+
result.barcodeType = it.optInt("barcodeType")
|
|
1355
|
+
result.status = it.optInt("status")
|
|
1356
|
+
result.pageIndex = it.optInt("pageIndex")
|
|
1357
|
+
result.pdf417Info = pdf417InfoFromJSON(it.optJSONObject("pdf417Info"))
|
|
1358
|
+
result.data = it.optString("data").toByteArray()
|
|
1693
1359
|
|
|
1694
|
-
|
|
1360
|
+
result
|
|
1695
1361
|
}
|
|
1696
1362
|
|
|
1697
|
-
fun generateDocumentReaderBarcodeField(
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
result.put("pdf417Info", generatePDF417Info(input.pdf417Info))
|
|
1706
|
-
result.put("data", generateByteArray(input.data))
|
|
1707
|
-
|
|
1708
|
-
return result
|
|
1363
|
+
fun generateDocumentReaderBarcodeField(input: DocumentReaderBarcodeField?) = input?.let {
|
|
1364
|
+
mapOf(
|
|
1365
|
+
"barcodeType" to it.barcodeType,
|
|
1366
|
+
"status" to it.status,
|
|
1367
|
+
"pageIndex" to it.pageIndex,
|
|
1368
|
+
"pdf417Info" to generatePDF417Info(it.pdf417Info),
|
|
1369
|
+
"data" to it.data.toBase64()
|
|
1370
|
+
).toJson()
|
|
1709
1371
|
}
|
|
1710
1372
|
|
|
1711
|
-
fun documentReaderAuthenticityResultFromJSON(
|
|
1712
|
-
temp ?: return null
|
|
1713
|
-
val input: JSONObject = temp
|
|
1373
|
+
fun documentReaderAuthenticityResultFromJSON(input: JSONObject?) = input?.let {
|
|
1714
1374
|
val result = DocumentReaderAuthenticityResult()
|
|
1715
|
-
|
|
1716
|
-
result
|
|
1717
|
-
|
|
1718
|
-
return result
|
|
1375
|
+
result.checks = it.optJSONArray("checks").toList(::documentReaderAuthenticityCheckFromJSON)!!
|
|
1376
|
+
result
|
|
1719
1377
|
}
|
|
1720
1378
|
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
result.put("status", input.status)
|
|
1728
|
-
result.put("checks", generateList(input.checks, ::generateDocumentReaderAuthenticityCheck, context))
|
|
1729
|
-
|
|
1730
|
-
return result
|
|
1379
|
+
@Suppress("DEPRECATION")
|
|
1380
|
+
fun generateDocumentReaderAuthenticityResult(input: DocumentReaderAuthenticityResult?) = input?.let {
|
|
1381
|
+
mapOf(
|
|
1382
|
+
"status" to it.status,
|
|
1383
|
+
"checks" to it.checks.toJson(::generateDocumentReaderAuthenticityCheck)
|
|
1384
|
+
).toJson()
|
|
1731
1385
|
}
|
|
1732
1386
|
|
|
1733
|
-
fun documentReaderAuthenticityElementFromJSON(
|
|
1734
|
-
temp ?: return null
|
|
1735
|
-
val input: JSONObject = temp
|
|
1387
|
+
fun documentReaderAuthenticityElementFromJSON(input: JSONObject?) = input?.let {
|
|
1736
1388
|
val result = DocumentReaderAuthenticityElement()
|
|
1737
|
-
|
|
1738
|
-
result.
|
|
1739
|
-
result.
|
|
1740
|
-
result
|
|
1741
|
-
|
|
1742
|
-
return result
|
|
1389
|
+
result.status = it.optInt("status")
|
|
1390
|
+
result.elementType = it.optInt("elementType")
|
|
1391
|
+
result.elementDiagnose = it.optInt("elementDiagnose")
|
|
1392
|
+
result
|
|
1743
1393
|
}
|
|
1744
1394
|
|
|
1745
|
-
fun generateDocumentReaderAuthenticityElement(
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
result.put("elementTypeName", input.getElementTypeName(context))
|
|
1754
|
-
result.put("elementDiagnoseName", input.getElementDiagnoseName(context))
|
|
1755
|
-
|
|
1756
|
-
return result
|
|
1395
|
+
fun generateDocumentReaderAuthenticityElement(input: DocumentReaderAuthenticityElement?) = input?.let {
|
|
1396
|
+
mapOf(
|
|
1397
|
+
"status" to it.status,
|
|
1398
|
+
"elementType" to it.elementType,
|
|
1399
|
+
"elementDiagnose" to it.elementDiagnose,
|
|
1400
|
+
"elementTypeName" to it.getElementTypeName(context),
|
|
1401
|
+
"elementDiagnoseName" to it.getElementDiagnoseName(context)
|
|
1402
|
+
).toJson()
|
|
1757
1403
|
}
|
|
1758
1404
|
|
|
1759
|
-
fun paResourcesIssuerFromJSON(
|
|
1760
|
-
temp ?: return null
|
|
1761
|
-
val input: JSONObject = temp
|
|
1405
|
+
fun paResourcesIssuerFromJSON(input: JSONObject?) = input?.let {
|
|
1762
1406
|
val result = PAResourcesIssuer()
|
|
1763
|
-
|
|
1764
|
-
result.
|
|
1765
|
-
result.
|
|
1766
|
-
result
|
|
1767
|
-
|
|
1768
|
-
return result
|
|
1407
|
+
result.data = it.optString("data").toByteArray()
|
|
1408
|
+
result.friendlyName = it.optString("friendlyName")
|
|
1409
|
+
result.attributes = it.optJSONArray("attributes").toArray(::paAttributeFromJSON)
|
|
1410
|
+
result
|
|
1769
1411
|
}
|
|
1770
1412
|
|
|
1771
|
-
fun generatePAResourcesIssuer(
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
result.put("friendlyName", input.friendlyName)
|
|
1778
|
-
result.put("attributes", generateArray(input.attributes, ::generatePAAttribute))
|
|
1779
|
-
|
|
1780
|
-
return result
|
|
1413
|
+
fun generatePAResourcesIssuer(input: PAResourcesIssuer?) = input?.let {
|
|
1414
|
+
mapOf(
|
|
1415
|
+
"data" to it.data.toBase64(),
|
|
1416
|
+
"friendlyName" to it.friendlyName,
|
|
1417
|
+
"attributes" to it.attributes.toJson(::generatePAAttribute)
|
|
1418
|
+
).toJson()
|
|
1781
1419
|
}
|
|
1782
1420
|
|
|
1783
|
-
fun paAttributeFromJSON(
|
|
1784
|
-
temp ?: return null
|
|
1785
|
-
val input: JSONObject = temp
|
|
1421
|
+
fun paAttributeFromJSON(input: JSONObject?) = input?.let {
|
|
1786
1422
|
val result = PAAttribute()
|
|
1787
|
-
|
|
1788
|
-
result.
|
|
1789
|
-
result
|
|
1790
|
-
|
|
1791
|
-
return result
|
|
1423
|
+
result.type = it.optString("type")
|
|
1424
|
+
result.value = it.optString("value")
|
|
1425
|
+
result
|
|
1792
1426
|
}
|
|
1793
1427
|
|
|
1794
|
-
fun generatePAAttribute(
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
result.put("type", input.type)
|
|
1800
|
-
result.put("value", input.value)
|
|
1801
|
-
|
|
1802
|
-
return result
|
|
1428
|
+
fun generatePAAttribute(input: PAAttribute?) = input?.let {
|
|
1429
|
+
mapOf(
|
|
1430
|
+
"type" to it.type,
|
|
1431
|
+
"value" to it.value
|
|
1432
|
+
).toJson()
|
|
1803
1433
|
}
|
|
1804
1434
|
|
|
1805
|
-
fun taChallengeFromJSON(
|
|
1806
|
-
temp ?: return null
|
|
1807
|
-
val input: JSONObject = temp
|
|
1435
|
+
fun taChallengeFromJSON(input: JSONObject?) = input?.let {
|
|
1808
1436
|
val result = TAChallenge()
|
|
1809
1437
|
|
|
1810
|
-
result.data =
|
|
1811
|
-
result.auxPCD =
|
|
1812
|
-
result.challengePICC =
|
|
1813
|
-
result.hashPK =
|
|
1814
|
-
result.idPICC =
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
}
|
|
1818
|
-
|
|
1819
|
-
fun generateTAChallenge(
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
result.put("
|
|
1882
|
-
result.put("
|
|
1883
|
-
result.put("
|
|
1884
|
-
|
|
1885
|
-
result
|
|
1886
|
-
result.put("pace", input.pace)
|
|
1887
|
-
result.put("overallStatus", input.overallStatus)
|
|
1888
|
-
|
|
1889
|
-
return result
|
|
1890
|
-
}
|
|
1891
|
-
|
|
1892
|
-
fun vdsncDataDictionaryFromJSON(input: JSONObject): JSONObject {
|
|
1893
|
-
val temp = JSONObject(input.toString())
|
|
1894
|
-
|
|
1895
|
-
temp.put("Type", input.optString("type"))
|
|
1896
|
-
temp.put("Version", input.optInt("version"))
|
|
1897
|
-
temp.put("IssuingCountry", input.optString("issuingCountry"))
|
|
1898
|
-
temp.put("Message", input.optJSONObject("message"))
|
|
1899
|
-
temp.put("SignatureAlg", input.optString("signatureAlgorithm"))
|
|
1900
|
-
temp.put("Signature", bytesDataDictionaryFromJSON(input.optJSONObject("signature")))
|
|
1901
|
-
temp.put("Certificate", bytesDataDictionaryFromJSON(input.optJSONObject("certificate")))
|
|
1902
|
-
temp.put("CertificateChain", input.optJSONArray("certificateChain"))
|
|
1903
|
-
temp.put("Notifications", input.optJSONArray("notifications"))
|
|
1904
|
-
|
|
1905
|
-
return temp
|
|
1438
|
+
result.data = it.optString("data").toByteArray()
|
|
1439
|
+
result.auxPCD = it.optString("auxPCD")
|
|
1440
|
+
result.challengePICC = it.optString("challengePICC")
|
|
1441
|
+
result.hashPK = it.optString("hashPK")
|
|
1442
|
+
result.idPICC = it.optString("idPICC")
|
|
1443
|
+
|
|
1444
|
+
result
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
fun generateTAChallenge(input: TAChallenge?) = input?.let {
|
|
1448
|
+
mapOf(
|
|
1449
|
+
"data" to it.data.toBase64(),
|
|
1450
|
+
"auxPCD" to it.auxPCD,
|
|
1451
|
+
"challengePICC" to it.challengePICC,
|
|
1452
|
+
"hashPK" to it.hashPK,
|
|
1453
|
+
"idPICC" to it.idPICC
|
|
1454
|
+
).toJson()
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
fun documentReaderResultsStatusFromJSON(input: JSONObject?) = input?.let {
|
|
1458
|
+
it.remove("detailsRFID")
|
|
1459
|
+
DocumentReaderResultsStatus.fromJson(input)
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
fun generateDocumentReaderResultsStatus(input: DocumentReaderResultsStatus?) = input?.let {
|
|
1463
|
+
mapOf(
|
|
1464
|
+
"overallStatus" to it.overallStatus,
|
|
1465
|
+
"optical" to it.optical,
|
|
1466
|
+
"detailsOptical" to generateDetailsOptical(it.detailsOptical),
|
|
1467
|
+
"rfid" to it.rfid,
|
|
1468
|
+
"detailsRFID" to generateDetailsRFID(it.detailsRFID),
|
|
1469
|
+
"portrait" to it.portrait,
|
|
1470
|
+
"stopList" to it.stopList
|
|
1471
|
+
).toJson()
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
fun generateDetailsOptical(input: DetailsOptical?) = input?.let {
|
|
1475
|
+
mapOf(
|
|
1476
|
+
"overallStatus" to it.overallStatus,
|
|
1477
|
+
"mrz" to it.mrz,
|
|
1478
|
+
"text" to it.text,
|
|
1479
|
+
"docType" to it.docType,
|
|
1480
|
+
"security" to it.security,
|
|
1481
|
+
"imageQA" to it.imageQA,
|
|
1482
|
+
"expiry" to it.expiry,
|
|
1483
|
+
"vds" to it.vds,
|
|
1484
|
+
"pagesCount" to it.pagesCount
|
|
1485
|
+
).toJson()
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
fun generateDetailsRFID(input: DetailsRFID?) = input?.let {
|
|
1489
|
+
mapOf(
|
|
1490
|
+
"pa" to it.pa,
|
|
1491
|
+
"ca" to it.ca,
|
|
1492
|
+
"aa" to it.aa,
|
|
1493
|
+
"ta" to it.ta,
|
|
1494
|
+
"bac" to it.bac,
|
|
1495
|
+
"pace" to it.pace,
|
|
1496
|
+
"overallStatus" to it.overallStatus
|
|
1497
|
+
).toJson()
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
fun vdsncDataDictionaryFromJSON(input: JSONObject) = input.let {
|
|
1501
|
+
val result = JSONObject(it.toString())
|
|
1502
|
+
|
|
1503
|
+
result.put("Type", it.optString("type"))
|
|
1504
|
+
result.put("Version", it.optInt("version"))
|
|
1505
|
+
result.put("IssuingCountry", it.optString("issuingCountry"))
|
|
1506
|
+
result.put("Message", it.optJSONObject("message"))
|
|
1507
|
+
result.put("SignatureAlg", it.optString("signatureAlgorithm"))
|
|
1508
|
+
result.put("Signature", bytesDataDictionaryFromJSON(it.optJSONObject("signature")))
|
|
1509
|
+
result.put("Certificate", bytesDataDictionaryFromJSON(it.optJSONObject("certificate")))
|
|
1510
|
+
result.put("CertificateChain", it.optJSONArray("certificateChain"))
|
|
1511
|
+
result.put("Notifications", it.optJSONArray("notifications"))
|
|
1512
|
+
|
|
1513
|
+
result
|
|
1906
1514
|
}
|
|
1907
1515
|
|
|
1908
1516
|
fun vdsncDataFromJSON(input: JSONObject) = VDSNCData.fromJson(vdsncDataDictionaryFromJSON(input))
|
|
1909
1517
|
|
|
1910
|
-
fun generateVDSNCData(
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1518
|
+
fun generateVDSNCData(input: VDSNCData?) = input?.let {
|
|
1519
|
+
mapOf(
|
|
1520
|
+
"type" to it.type,
|
|
1521
|
+
"version" to it.version,
|
|
1522
|
+
"issuingCountry" to it.issuingCountry,
|
|
1523
|
+
"message" to it.message,
|
|
1524
|
+
"signatureAlgorithm" to it.signatureAlg,
|
|
1525
|
+
"signature" to generateBytesData(it.signature),
|
|
1526
|
+
"certificate" to generateBytesData(it.certificate),
|
|
1527
|
+
"certificateChain" to it.certificateChain.toJson(::generateCertificateChain),
|
|
1528
|
+
"notifications" to if (it.notifications == null) null else {
|
|
1529
|
+
val notifications = JSONArray()
|
|
1530
|
+
for (i in it.notifications!!.indices) notifications.put(i, it.notifications!![i])
|
|
1531
|
+
notifications
|
|
1532
|
+
}
|
|
1533
|
+
).toJson()
|
|
1926
1534
|
}
|
|
1927
1535
|
|
|
1928
|
-
fun bytesDataDictionaryFromJSON(input: JSONObject?)
|
|
1929
|
-
|
|
1930
|
-
val temp = JSONObject(input.toString())
|
|
1536
|
+
fun bytesDataDictionaryFromJSON(input: JSONObject?) = input?.let {
|
|
1537
|
+
val result = JSONObject(input.toString())
|
|
1931
1538
|
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1539
|
+
result.put("Data", input.optString("data"))
|
|
1540
|
+
result.put("Length", input.optInt("length"))
|
|
1541
|
+
result.put("Status", input.optLong("status"))
|
|
1542
|
+
result.put("Type", input.optInt("type"))
|
|
1936
1543
|
|
|
1937
|
-
|
|
1544
|
+
result
|
|
1938
1545
|
}
|
|
1939
1546
|
|
|
1940
1547
|
fun bytesDataFromJSON(input: JSONObject?) = BytesData.fromJson(bytesDataDictionaryFromJSON(input))
|
|
1941
1548
|
|
|
1942
|
-
fun generateBytesData(
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
result.put("
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
}
|
|
1990
|
-
|
|
1991
|
-
fun generateDocReaderDocumentsDatabase(temp: DocReaderDocumentsDatabase?): JSONObject? {
|
|
1992
|
-
val result = JSONObject()
|
|
1993
|
-
temp ?: return null
|
|
1994
|
-
val input: DocReaderDocumentsDatabase = temp
|
|
1995
|
-
|
|
1996
|
-
result.put("databaseID", input.databaseID)
|
|
1997
|
-
result.put("version", input.version)
|
|
1998
|
-
result.put("date", input.date)
|
|
1999
|
-
result.put("databaseDescription", input.databaseDescription)
|
|
2000
|
-
result.put("countriesNumber", input.countriesNumber)
|
|
2001
|
-
result.put("documentsNumber", input.documentsNumber)
|
|
2002
|
-
result.put("size", input.size)
|
|
2003
|
-
|
|
2004
|
-
return result
|
|
2005
|
-
}
|
|
2006
|
-
|
|
2007
|
-
fun documentReaderComparisonFromJSON(temp: JSONObject?): DocumentReaderComparison? {
|
|
2008
|
-
temp ?: return null
|
|
2009
|
-
val input: JSONObject = temp
|
|
1549
|
+
fun generateBytesData(input: BytesData?) = input?.let {
|
|
1550
|
+
mapOf(
|
|
1551
|
+
"data" to it.data,
|
|
1552
|
+
"length" to it.length,
|
|
1553
|
+
"status" to it.status,
|
|
1554
|
+
"type" to it.type
|
|
1555
|
+
).toJson()
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
fun generateLicense(input: License?) = input?.let {
|
|
1559
|
+
mapOf(
|
|
1560
|
+
"expiryDate" to it.expiryDate?.toString(),
|
|
1561
|
+
"countryFilter" to it.countryFilter?.toJson(),
|
|
1562
|
+
"isRfidAvailable" to it.isRfidAvailable
|
|
1563
|
+
).toJson()
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
fun generateDocReaderVersion(input: DocReaderVersion?) = input?.let {
|
|
1567
|
+
mapOf(
|
|
1568
|
+
"api" to it.api,
|
|
1569
|
+
"core" to it.core,
|
|
1570
|
+
"coreMode" to it.coreMode,
|
|
1571
|
+
"database" to generateDocReaderDocumentsDatabase(it.database)
|
|
1572
|
+
).toJson()
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
fun docReaderDocumentsDatabaseFromJSON(input: JSONObject?) = input?.let {
|
|
1576
|
+
val result = JSONObject(it.toString())
|
|
1577
|
+
result.put("id", it.optString("databaseID"))
|
|
1578
|
+
result.put("export_date", it.optString("date"))
|
|
1579
|
+
result.put("description", it.optString("databaseDescription"))
|
|
1580
|
+
DocReaderDocumentsDatabase.fromJson(result)
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
fun generateDocReaderDocumentsDatabase(input: DocReaderDocumentsDatabase?) = input?.let {
|
|
1584
|
+
mapOf(
|
|
1585
|
+
"databaseID" to it.databaseID,
|
|
1586
|
+
"version" to it.version,
|
|
1587
|
+
"date" to it.date,
|
|
1588
|
+
"databaseDescription" to it.databaseDescription,
|
|
1589
|
+
"countriesNumber" to it.countriesNumber,
|
|
1590
|
+
"documentsNumber" to it.documentsNumber,
|
|
1591
|
+
"size" to it.size
|
|
1592
|
+
).toJson()
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
fun documentReaderComparisonFromJSON(input: JSONObject?) = input?.let {
|
|
2010
1596
|
val result = DocumentReaderComparison()
|
|
2011
|
-
|
|
2012
|
-
result.
|
|
2013
|
-
result.
|
|
2014
|
-
result
|
|
2015
|
-
|
|
2016
|
-
return result
|
|
1597
|
+
result.sourceTypeLeft = it.optInt("sourceTypeLeft")
|
|
1598
|
+
result.sourceTypeRight = it.optInt("sourceTypeRight")
|
|
1599
|
+
result.status = it.optInt("status")
|
|
1600
|
+
result
|
|
2017
1601
|
}
|
|
2018
1602
|
|
|
2019
|
-
fun generateDocumentReaderComparison(
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
result.put("sourceTypeRight", input.sourceTypeRight)
|
|
2026
|
-
result.put("status", input.status)
|
|
2027
|
-
|
|
2028
|
-
return result
|
|
1603
|
+
fun generateDocumentReaderComparison(input: DocumentReaderComparison?) = input?.let {
|
|
1604
|
+
mapOf(
|
|
1605
|
+
"sourceTypeLeft" to it.sourceTypeLeft,
|
|
1606
|
+
"sourceTypeRight" to it.sourceTypeRight,
|
|
1607
|
+
"status" to it.status
|
|
1608
|
+
).toJson()
|
|
2029
1609
|
}
|
|
2030
1610
|
|
|
2031
|
-
fun documentReaderRFIDOriginFromJSON(
|
|
2032
|
-
temp ?: return null
|
|
2033
|
-
val input: JSONObject = temp
|
|
1611
|
+
fun documentReaderRFIDOriginFromJSON(input: JSONObject?) = input?.let {
|
|
2034
1612
|
val result = DocumentReaderRfidOrigin()
|
|
2035
1613
|
|
|
2036
|
-
result.dg =
|
|
2037
|
-
result.dgTag =
|
|
2038
|
-
result.entryView =
|
|
2039
|
-
result.tagEntry =
|
|
1614
|
+
result.dg = it.optInt("dg")
|
|
1615
|
+
result.dgTag = it.optInt("dgTag")
|
|
1616
|
+
result.entryView = it.optInt("entryView")
|
|
1617
|
+
result.tagEntry = it.optInt("tagEntry")
|
|
2040
1618
|
|
|
2041
|
-
|
|
1619
|
+
result
|
|
2042
1620
|
}
|
|
2043
1621
|
|
|
2044
|
-
fun generateDocumentReaderRFIDOrigin(
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
result.put("entryView", input.entryView)
|
|
2052
|
-
result.put("tagEntry", input.tagEntry)
|
|
2053
|
-
|
|
2054
|
-
return result
|
|
1622
|
+
fun generateDocumentReaderRFIDOrigin(input: DocumentReaderRfidOrigin?) = input?.let {
|
|
1623
|
+
mapOf(
|
|
1624
|
+
"dg" to it.dg,
|
|
1625
|
+
"dgTag" to it.dgTag,
|
|
1626
|
+
"entryView" to it.entryView,
|
|
1627
|
+
"tagEntry" to it.tagEntry
|
|
1628
|
+
).toJson()
|
|
2055
1629
|
}
|
|
2056
1630
|
|
|
2057
|
-
fun documentReaderTextSourceFromJSON(
|
|
2058
|
-
temp ?: return null
|
|
2059
|
-
val input: JSONObject = temp
|
|
1631
|
+
fun documentReaderTextSourceFromJSON(input: JSONObject?) = input?.let {
|
|
2060
1632
|
val result = DocumentReaderTextSource()
|
|
2061
|
-
|
|
2062
|
-
result.
|
|
2063
|
-
result.
|
|
2064
|
-
result
|
|
2065
|
-
|
|
2066
|
-
return result
|
|
1633
|
+
result.sourceType = it.optInt("sourceType")
|
|
1634
|
+
result.source = it.optString("source")
|
|
1635
|
+
result.validityStatus = it.optInt("validityStatus")
|
|
1636
|
+
result
|
|
2067
1637
|
}
|
|
2068
1638
|
|
|
2069
|
-
fun generateDocumentReaderTextSource(
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
result.put("source", input.source)
|
|
2076
|
-
result.put("validityStatus", input.validityStatus)
|
|
2077
|
-
|
|
2078
|
-
return result
|
|
1639
|
+
fun generateDocumentReaderTextSource(input: DocumentReaderTextSource?) = input?.let {
|
|
1640
|
+
mapOf(
|
|
1641
|
+
"sourceType" to it.sourceType,
|
|
1642
|
+
"source" to it.source,
|
|
1643
|
+
"validityStatus" to it.validityStatus
|
|
1644
|
+
).toJson()
|
|
2079
1645
|
}
|
|
2080
1646
|
|
|
2081
|
-
fun documentReaderSymbolFromJSON(
|
|
2082
|
-
temp ?: return null
|
|
2083
|
-
val input: JSONObject = temp
|
|
1647
|
+
fun documentReaderSymbolFromJSON(input: JSONObject?) = input?.let {
|
|
2084
1648
|
val result = DocumentReaderSymbol()
|
|
2085
|
-
|
|
2086
|
-
result.
|
|
2087
|
-
result.
|
|
2088
|
-
result
|
|
2089
|
-
|
|
2090
|
-
return result
|
|
1649
|
+
result.code = it.optInt("code")
|
|
1650
|
+
result.probability = it.optInt("probability")
|
|
1651
|
+
result.rect = rectFromJSON(it.optJSONObject("rect"))
|
|
1652
|
+
result
|
|
2091
1653
|
}
|
|
2092
1654
|
|
|
2093
|
-
fun generateDocumentReaderSymbol(
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
result.put("rect", generateRect(input.rect))
|
|
2100
|
-
result.put("probability", input.probability)
|
|
2101
|
-
|
|
2102
|
-
return result
|
|
1655
|
+
fun generateDocumentReaderSymbol(input: DocumentReaderSymbol?) = input?.let {
|
|
1656
|
+
mapOf(
|
|
1657
|
+
"code" to it.code,
|
|
1658
|
+
"rect" to generateRect(it.rect),
|
|
1659
|
+
"probability" to it.probability
|
|
1660
|
+
).toJson()
|
|
2103
1661
|
}
|
|
2104
1662
|
|
|
2105
|
-
fun documentReaderValidityFromJSON(
|
|
2106
|
-
temp ?: return null
|
|
2107
|
-
val input: JSONObject = temp
|
|
1663
|
+
fun documentReaderValidityFromJSON(input: JSONObject?) = input?.let {
|
|
2108
1664
|
val result = DocumentReaderValidity()
|
|
2109
|
-
|
|
2110
|
-
result.
|
|
2111
|
-
result
|
|
2112
|
-
|
|
2113
|
-
return result
|
|
1665
|
+
result.sourceType = it.optInt("sourceType")
|
|
1666
|
+
result.status = it.optInt("status")
|
|
1667
|
+
result
|
|
2114
1668
|
}
|
|
2115
1669
|
|
|
2116
|
-
fun generateDocumentReaderValidity(
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
result.put("sourceType", input.sourceType)
|
|
2122
|
-
result.put("status", input.status)
|
|
2123
|
-
|
|
2124
|
-
return result
|
|
1670
|
+
fun generateDocumentReaderValidity(input: DocumentReaderValidity?) = input?.let {
|
|
1671
|
+
mapOf(
|
|
1672
|
+
"sourceType" to it.sourceType,
|
|
1673
|
+
"status" to it.status
|
|
1674
|
+
).toJson()
|
|
2125
1675
|
}
|
|
2126
1676
|
|
|
2127
|
-
fun barcodeTypeArrayFromJson(
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
val result = arrayOfNulls<String>(input.length())
|
|
2132
|
-
for (i in 0 until input.length()) result[i] = BarcodeType.valueOf(input.getInt(i))
|
|
2133
|
-
|
|
2134
|
-
return result
|
|
1677
|
+
fun barcodeTypeArrayFromJson(input: JSONArray?) = input?.let {
|
|
1678
|
+
val result = arrayOfNulls<String>(it.length())
|
|
1679
|
+
for (i in 0 until it.length()) result[i] = BarcodeType.valueOf(it.getInt(i))
|
|
1680
|
+
result
|
|
2135
1681
|
}
|
|
2136
1682
|
|
|
2137
|
-
fun generateBarcodeTypeArray(
|
|
2138
|
-
temp ?: return null
|
|
2139
|
-
val input: Array<String?> = temp
|
|
1683
|
+
fun generateBarcodeTypeArray(input: Array<String?>?) = input?.let {
|
|
2140
1684
|
val result = JSONArray()
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
fun documentReaderResultsFromJSON(temp: JSONObject?): DocumentReaderResults? {
|
|
2171
|
-
temp ?: return null
|
|
2172
|
-
val input: JSONObject = temp
|
|
1685
|
+
for (s in it) result.put(
|
|
1686
|
+
when (s) {
|
|
1687
|
+
"bct_Code128" -> 1
|
|
1688
|
+
"bct_Code39" -> 2
|
|
1689
|
+
"bct_EAN8" -> 3
|
|
1690
|
+
"bct_ITF" -> 4
|
|
1691
|
+
"bct_PDF417" -> 5
|
|
1692
|
+
"bct_STF" -> 6
|
|
1693
|
+
"bct_MTF" -> 7
|
|
1694
|
+
"bct_IATA" -> 8
|
|
1695
|
+
"bct_CODABAR" -> 9
|
|
1696
|
+
"bct_UPCA" -> 10
|
|
1697
|
+
"bct_CODE93" -> 11
|
|
1698
|
+
"bct_UPCE" -> 12
|
|
1699
|
+
"bct_EAN13" -> 13
|
|
1700
|
+
"bct_QRCODE" -> 14
|
|
1701
|
+
"bct_AZTEC" -> 15
|
|
1702
|
+
"bct_DATAMATRIX" -> 16
|
|
1703
|
+
"bct_ALL_1D" -> 17
|
|
1704
|
+
"bct_Code11" -> 18
|
|
1705
|
+
"bct_JABCODE" -> 19
|
|
1706
|
+
else -> 0
|
|
1707
|
+
}
|
|
1708
|
+
)
|
|
1709
|
+
result
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
fun documentReaderResultsFromJSON(input: JSONObject?) = input?.let {
|
|
2173
1713
|
val result = DocumentReaderResults()
|
|
2174
1714
|
|
|
2175
|
-
result.chipPage =
|
|
2176
|
-
result.processingFinishedStatus =
|
|
2177
|
-
result.elapsedTime =
|
|
2178
|
-
result.elapsedTimeRFID =
|
|
2179
|
-
result.morePagesAvailable =
|
|
2180
|
-
result.graphicResult = documentReaderGraphicResultFromJSON(
|
|
2181
|
-
result.textResult = documentReaderTextResultFromJSON(
|
|
2182
|
-
result.documentPosition =
|
|
2183
|
-
result.barcodePosition =
|
|
2184
|
-
result.mrzPosition =
|
|
2185
|
-
result.imageQuality =
|
|
2186
|
-
result.rawResult =
|
|
2187
|
-
result.rfidSessionData = rfidSessionDataFromJSON(
|
|
2188
|
-
result.authenticityResult = documentReaderAuthenticityResultFromJSON(
|
|
2189
|
-
result.barcodeResult = documentReaderBarcodeResultFromJSON(
|
|
2190
|
-
result.rfidSessionData = rfidSessionDataFromJSON(
|
|
2191
|
-
result.documentType =
|
|
2192
|
-
result.status = documentReaderResultsStatusFromJSON(
|
|
2193
|
-
result.vdsncData = vdsncDataFromJSON(
|
|
2194
|
-
result.dtcData =
|
|
2195
|
-
result.transactionInfo = transactionInfoFromJSON(
|
|
2196
|
-
|
|
2197
|
-
|
|
1715
|
+
result.chipPage = it.optInt("chipPage")
|
|
1716
|
+
result.processingFinishedStatus = it.optInt("processingFinishedStatus")
|
|
1717
|
+
result.elapsedTime = it.optInt("elapsedTime")
|
|
1718
|
+
result.elapsedTimeRFID = it.optInt("elapsedTimeRFID")
|
|
1719
|
+
result.morePagesAvailable = it.optInt("morePagesAvailable")
|
|
1720
|
+
result.graphicResult = documentReaderGraphicResultFromJSON(it.optJSONObject("graphicResult"))
|
|
1721
|
+
result.textResult = documentReaderTextResultFromJSON(it.optJSONObject("textResult"))
|
|
1722
|
+
result.documentPosition = it.optJSONArray("documentPosition").toList(::elementPositionFromJSON)!!
|
|
1723
|
+
result.barcodePosition = it.optJSONArray("barcodePosition").toList(::elementPositionFromJSON)!!
|
|
1724
|
+
result.mrzPosition = it.optJSONArray("mrzPosition").toList(::elementPositionFromJSON)!!
|
|
1725
|
+
result.imageQuality = it.optJSONArray("imageQuality").toList(::imageQualityGroupFromJSON)!!
|
|
1726
|
+
result.rawResult = it.optString("rawResult")
|
|
1727
|
+
result.rfidSessionData = rfidSessionDataFromJSON(it.optJSONObject("rfidSessionData"))
|
|
1728
|
+
result.authenticityResult = documentReaderAuthenticityResultFromJSON(it.optJSONObject("authenticityResult"))
|
|
1729
|
+
result.barcodeResult = documentReaderBarcodeResultFromJSON(it.optJSONObject("barcodeResult"))
|
|
1730
|
+
result.rfidSessionData = rfidSessionDataFromJSON(it.optJSONObject("rfidSessionData"))
|
|
1731
|
+
result.documentType = it.optJSONArray("documentType").toList(::documentReaderDocumentTypeFromJSON)!!
|
|
1732
|
+
result.status = documentReaderResultsStatusFromJSON(it.optJSONObject("status"))!!
|
|
1733
|
+
result.vdsncData = vdsncDataFromJSON(it.optJSONObject("vdsncData")!!)
|
|
1734
|
+
result.dtcData = it.getString("dtcData")
|
|
1735
|
+
result.transactionInfo = transactionInfoFromJSON(it.optJSONObject("transactionInfo"))!!
|
|
1736
|
+
result
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
fun generateDocumentReaderResults(input: DocumentReaderResults?) = input?.let {
|
|
1740
|
+
mapOf(
|
|
1741
|
+
"chipPage" to it.chipPage,
|
|
1742
|
+
"processingFinishedStatus" to it.processingFinishedStatus,
|
|
1743
|
+
"elapsedTime" to it.elapsedTime,
|
|
1744
|
+
"elapsedTimeRFID" to it.elapsedTimeRFID,
|
|
1745
|
+
"morePagesAvailable" to it.morePagesAvailable,
|
|
1746
|
+
"graphicResult" to generateDocumentReaderGraphicResult(it.graphicResult),
|
|
1747
|
+
"textResult" to generateDocumentReaderTextResult(it.textResult),
|
|
1748
|
+
"documentPosition" to it.documentPosition.toJson(::generateElementPosition),
|
|
1749
|
+
"barcodePosition" to it.barcodePosition.toJson(::generateElementPosition),
|
|
1750
|
+
"mrzPosition" to it.mrzPosition.toJson(::generateElementPosition),
|
|
1751
|
+
"imageQuality" to it.imageQuality.toJson(::generateImageQualityGroup),
|
|
1752
|
+
"rawResult" to it.rawResult,
|
|
1753
|
+
"rfidSessionData" to generateRFIDSessionData(it.rfidSessionData),
|
|
1754
|
+
"authenticityResult" to generateDocumentReaderAuthenticityResult(it.authenticityResult),
|
|
1755
|
+
"barcodeResult" to generateDocumentReaderBarcodeResult(it.barcodeResult),
|
|
1756
|
+
"documentType" to it.documentType.toJson(::generateDocumentReaderDocumentType),
|
|
1757
|
+
"status" to generateDocumentReaderResultsStatus(it.status),
|
|
1758
|
+
"vdsncData" to generateVDSNCData(it.vdsncData),
|
|
1759
|
+
"dtcData" to it.dtcData,
|
|
1760
|
+
"transactionInfo" to generateTransactionInfo(it.transactionInfo)
|
|
1761
|
+
).toJson()
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
fun matrixFromJSON(input: JSONArray?) = input?.let {
|
|
1765
|
+
val matrix = Matrix()
|
|
1766
|
+
val result = FloatArray(it.length())
|
|
1767
|
+
for (i in 0 until it.length()) result[i] = it.getDouble(i).toFloat()
|
|
1768
|
+
matrix.setValues(result)
|
|
1769
|
+
matrix
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
fun generateMatrix(input: Matrix?) = input?.let {
|
|
1773
|
+
val floats = FloatArray(9)
|
|
1774
|
+
it.getValues(floats)
|
|
1775
|
+
val result = JSONArray()
|
|
1776
|
+
for (f in floats) result.put(java.lang.Float.valueOf(f))
|
|
1777
|
+
result
|
|
2198
1778
|
}
|
|
2199
|
-
|
|
2200
|
-
fun generateDocumentReaderResults(temp: DocumentReaderResults?, context: Context?): JSONObject? {
|
|
2201
|
-
val result = JSONObject()
|
|
2202
|
-
temp ?: return null
|
|
2203
|
-
val input: DocumentReaderResults = temp
|
|
2204
|
-
|
|
2205
|
-
result.put("chipPage", input.chipPage)
|
|
2206
|
-
result.put("processingFinishedStatus", input.processingFinishedStatus)
|
|
2207
|
-
result.put("elapsedTime", input.elapsedTime)
|
|
2208
|
-
result.put("elapsedTimeRFID", input.elapsedTimeRFID)
|
|
2209
|
-
result.put("morePagesAvailable", input.morePagesAvailable)
|
|
2210
|
-
result.put("graphicResult", generateDocumentReaderGraphicResult(input.graphicResult, context))
|
|
2211
|
-
result.put("textResult", generateDocumentReaderTextResult(input.textResult, context))
|
|
2212
|
-
result.put("documentPosition", generateList(input.documentPosition, ::generateElementPosition))
|
|
2213
|
-
result.put("barcodePosition", generateList(input.barcodePosition, ::generateElementPosition))
|
|
2214
|
-
result.put("mrzPosition", generateList(input.mrzPosition, ::generateElementPosition))
|
|
2215
|
-
result.put("imageQuality", generateList(input.imageQuality, ::generateImageQualityGroup))
|
|
2216
|
-
result.put("rawResult", input.rawResult)
|
|
2217
|
-
result.put("rfidSessionData", generateRFIDSessionData(input.rfidSessionData, context))
|
|
2218
|
-
result.put("authenticityResult", generateDocumentReaderAuthenticityResult(input.authenticityResult, context))
|
|
2219
|
-
result.put("barcodeResult", generateDocumentReaderBarcodeResult(input.barcodeResult))
|
|
2220
|
-
result.put("documentType", generateList(input.documentType, ::generateDocumentReaderDocumentType))
|
|
2221
|
-
result.put("status", generateDocumentReaderResultsStatus(input.status))
|
|
2222
|
-
result.put("vdsncData", generateVDSNCData(input.vdsncData))
|
|
2223
|
-
result.put("dtcData", input.dtcData)
|
|
2224
|
-
result.put("transactionInfo", generateTransactionInfo(input.transactionInfo))
|
|
2225
|
-
|
|
2226
|
-
return result
|
|
2227
|
-
}
|