@regulaforensics/react-native-document-reader-api 8.1.136-nightly → 8.1.139-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/RNDocumentReaderApi.podspec +1 -1
- package/android/build.gradle +2 -2
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/regula/{documentreader → plugin/documentreader}/BluetoothUtil.kt +7 -16
- package/android/src/main/java/com/regula/{documentreader → plugin/documentreader}/Config.kt +154 -120
- package/android/src/main/java/com/regula/plugin/documentreader/JSONConstructor.kt +1778 -0
- package/android/src/main/java/com/regula/plugin/documentreader/Main.kt +553 -0
- package/android/src/main/java/com/regula/plugin/documentreader/RNRegulaDocumentReaderModule.kt +103 -0
- package/android/src/main/java/com/regula/plugin/documentreader/Utils.kt +181 -0
- package/example/android/app/build.gradle +7 -4
- package/example/android/app/src/debug/java/com/regula/dr/fullrfid/ReactNativeFlipper.java +1 -1
- package/example/android/app/src/main/java/com/regula/dr/{fullrfid → fullauthrfid}/MainActivity.java +1 -1
- package/example/android/app/src/main/java/com/regula/dr/{fullrfid → fullauthrfid}/MainApplication.java +10 -3
- package/example/android/app/src/release/java/com/regula/dr/fullrfid/ReactNativeFlipper.java +1 -1
- package/example/android/build.gradle +5 -5
- package/example/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/example/android/settings.gradle +4 -2
- package/example/ios/DocumentReader/AppDelegate.mm +5 -0
- package/example/ios/DocumentReader/Info.plist +22 -0
- package/example/ios/DocumentReader.xcodeproj/project.pbxproj +4 -14
- package/example/ios/Podfile +1 -6
- package/example/package-lock.json +2665 -1874
- package/example/package.json +25 -22
- package/ios/RGLWConfig.h +0 -8
- package/ios/RGLWConfig.m +44 -52
- package/ios/RGLWJSONConstructor.h +1 -8
- package/ios/RGLWJSONConstructor.m +12 -10
- package/ios/RGLWMain.h +36 -0
- package/ios/RGLWMain.m +591 -0
- package/ios/RNRegulaDocumentReader.h +4 -20
- package/ios/RNRegulaDocumentReader.m +18 -726
- package/package.json +1 -1
- package/android/src/main/java/com/regula/documentreader/JSONConstructor.kt +0 -2227
- package/android/src/main/java/com/regula/documentreader/RNRegulaDocumentReaderModule.kt +0 -560
- package/android/src/main/java/com/regula/documentreader/RNRegulaDocumentReaderPackage.kt +0 -11
- package/android/src/main/java/com/regula/documentreader/Utils.kt +0 -268
|
@@ -0,0 +1,1778 @@
|
|
|
1
|
+
@file:SuppressLint("MissingPermission")
|
|
2
|
+
@file:Suppress("unused")
|
|
3
|
+
|
|
4
|
+
package com.regula.plugin.documentreader
|
|
5
|
+
|
|
6
|
+
import android.annotation.SuppressLint
|
|
7
|
+
import android.graphics.Bitmap
|
|
8
|
+
import android.graphics.Matrix
|
|
9
|
+
import android.graphics.Rect
|
|
10
|
+
import android.graphics.Typeface
|
|
11
|
+
import android.util.Pair
|
|
12
|
+
import com.regula.common.exception.RegulaException
|
|
13
|
+
import com.regula.documentreader.api.License
|
|
14
|
+
import com.regula.documentreader.api.completions.model.PrepareProgress
|
|
15
|
+
import com.regula.documentreader.api.config.RecognizeConfig
|
|
16
|
+
import com.regula.documentreader.api.config.ScannerConfig
|
|
17
|
+
import com.regula.documentreader.api.enums.BarcodeType
|
|
18
|
+
import com.regula.documentreader.api.enums.DocReaderAction
|
|
19
|
+
import com.regula.documentreader.api.enums.PDF417Info
|
|
20
|
+
import com.regula.documentreader.api.enums.eGraphicFieldType
|
|
21
|
+
import com.regula.documentreader.api.enums.eRFID_DataFile_Type
|
|
22
|
+
import com.regula.documentreader.api.enums.eRPRM_Lights
|
|
23
|
+
import com.regula.documentreader.api.listener.NetworkInterceptorListener
|
|
24
|
+
import com.regula.documentreader.api.params.AuthenticityParams
|
|
25
|
+
import com.regula.documentreader.api.params.BackendProcessingConfig
|
|
26
|
+
import com.regula.documentreader.api.params.BleDeviceConfig
|
|
27
|
+
import com.regula.documentreader.api.params.DocReaderConfig
|
|
28
|
+
import com.regula.documentreader.api.params.FaceApiParams
|
|
29
|
+
import com.regula.documentreader.api.params.Functionality
|
|
30
|
+
import com.regula.documentreader.api.params.ImageInputData
|
|
31
|
+
import com.regula.documentreader.api.params.ImageQA
|
|
32
|
+
import com.regula.documentreader.api.params.ImageQA.GlaresCheckParams
|
|
33
|
+
import com.regula.documentreader.api.params.LivenessParams
|
|
34
|
+
import com.regula.documentreader.api.params.OnlineProcessingConfig
|
|
35
|
+
import com.regula.documentreader.api.params.ParamsCustomization
|
|
36
|
+
import com.regula.documentreader.api.params.ProcessParam
|
|
37
|
+
import com.regula.documentreader.api.params.RfidScenario
|
|
38
|
+
import com.regula.documentreader.api.params.rfid.PKDCertificate
|
|
39
|
+
import com.regula.documentreader.api.params.rfid.RFIDParams
|
|
40
|
+
import com.regula.documentreader.api.params.rfid.TccParams
|
|
41
|
+
import com.regula.documentreader.api.params.rfid.authorization.PAAttribute
|
|
42
|
+
import com.regula.documentreader.api.params.rfid.authorization.PAResourcesIssuer
|
|
43
|
+
import com.regula.documentreader.api.params.rfid.authorization.TAChallenge
|
|
44
|
+
import com.regula.documentreader.api.params.rfid.dg.DTCDataGroup
|
|
45
|
+
import com.regula.documentreader.api.params.rfid.dg.EDLDataGroups
|
|
46
|
+
import com.regula.documentreader.api.params.rfid.dg.EIDDataGroups
|
|
47
|
+
import com.regula.documentreader.api.params.rfid.dg.EPassportDataGroups
|
|
48
|
+
import com.regula.documentreader.api.results.BytesData
|
|
49
|
+
import com.regula.documentreader.api.results.Coordinate
|
|
50
|
+
import com.regula.documentreader.api.results.DocReaderDocumentsDatabase
|
|
51
|
+
import com.regula.documentreader.api.results.DocReaderFieldRect
|
|
52
|
+
import com.regula.documentreader.api.results.DocReaderVersion
|
|
53
|
+
import com.regula.documentreader.api.results.DocumentReaderBarcodeField
|
|
54
|
+
import com.regula.documentreader.api.results.DocumentReaderBarcodeResult
|
|
55
|
+
import com.regula.documentreader.api.results.DocumentReaderComparison
|
|
56
|
+
import com.regula.documentreader.api.results.DocumentReaderDocumentType
|
|
57
|
+
import com.regula.documentreader.api.results.DocumentReaderGraphicField
|
|
58
|
+
import com.regula.documentreader.api.results.DocumentReaderGraphicResult
|
|
59
|
+
import com.regula.documentreader.api.results.DocumentReaderNotification
|
|
60
|
+
import com.regula.documentreader.api.results.DocumentReaderResults
|
|
61
|
+
import com.regula.documentreader.api.results.DocumentReaderResultsStatus
|
|
62
|
+
import com.regula.documentreader.api.results.DocumentReaderResultsStatus.DetailsOptical
|
|
63
|
+
import com.regula.documentreader.api.results.DocumentReaderResultsStatus.DetailsRFID
|
|
64
|
+
import com.regula.documentreader.api.results.DocumentReaderRfidOrigin
|
|
65
|
+
import com.regula.documentreader.api.results.DocumentReaderScenario
|
|
66
|
+
import com.regula.documentreader.api.results.DocumentReaderSymbol
|
|
67
|
+
import com.regula.documentreader.api.results.DocumentReaderTextField
|
|
68
|
+
import com.regula.documentreader.api.results.DocumentReaderTextResult
|
|
69
|
+
import com.regula.documentreader.api.results.DocumentReaderTextSource
|
|
70
|
+
import com.regula.documentreader.api.results.DocumentReaderValidity
|
|
71
|
+
import com.regula.documentreader.api.results.DocumentReaderValue
|
|
72
|
+
import com.regula.documentreader.api.results.ElementPosition
|
|
73
|
+
import com.regula.documentreader.api.results.ImageQuality
|
|
74
|
+
import com.regula.documentreader.api.results.ImageQualityGroup
|
|
75
|
+
import com.regula.documentreader.api.results.TransactionInfo
|
|
76
|
+
import com.regula.documentreader.api.results.VDSNCData
|
|
77
|
+
import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityCheck
|
|
78
|
+
import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityElement
|
|
79
|
+
import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityResult
|
|
80
|
+
import com.regula.documentreader.api.results.rfid.AccessControlProcedureType
|
|
81
|
+
import com.regula.documentreader.api.results.rfid.Application
|
|
82
|
+
import com.regula.documentreader.api.results.rfid.Attribute
|
|
83
|
+
import com.regula.documentreader.api.results.rfid.Authority
|
|
84
|
+
import com.regula.documentreader.api.results.rfid.CardProperties
|
|
85
|
+
import com.regula.documentreader.api.results.rfid.CertificateChain
|
|
86
|
+
import com.regula.documentreader.api.results.rfid.CertificateData
|
|
87
|
+
import com.regula.documentreader.api.results.rfid.DataField
|
|
88
|
+
import com.regula.documentreader.api.results.rfid.Extension
|
|
89
|
+
import com.regula.documentreader.api.results.rfid.File
|
|
90
|
+
import com.regula.documentreader.api.results.rfid.FileData
|
|
91
|
+
import com.regula.documentreader.api.results.rfid.RFIDSessionData
|
|
92
|
+
import com.regula.documentreader.api.results.rfid.SecurityObject
|
|
93
|
+
import com.regula.documentreader.api.results.rfid.SecurityObjectCertificates
|
|
94
|
+
import com.regula.documentreader.api.results.rfid.SignerInfo
|
|
95
|
+
import com.regula.documentreader.api.results.rfid.Validity
|
|
96
|
+
import com.regula.documentreader.api.results.rfid.Value
|
|
97
|
+
import org.json.JSONArray
|
|
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()
|
|
108
|
+
|
|
109
|
+
fun generateSuccessCompletion(success: Boolean, error: RegulaException?) = mapOf(
|
|
110
|
+
"success" to success,
|
|
111
|
+
"error" to generateRegulaException(error)
|
|
112
|
+
).toJson()
|
|
113
|
+
|
|
114
|
+
fun prepareProgressFromJSON(it: JSONObject) = PrepareProgress(
|
|
115
|
+
it.getInt("downloadedBytes"),
|
|
116
|
+
it.getInt("totalBytes")
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
fun generatePrepareProgress(it: PrepareProgress) = mapOf(
|
|
120
|
+
"downloadedBytes" to it.downloadedBytes,
|
|
121
|
+
"totalBytes" to it.totalBytes,
|
|
122
|
+
"progress" to it.progress
|
|
123
|
+
).toJson()
|
|
124
|
+
|
|
125
|
+
fun generatePACertificateCompletion(serialNumber: ByteArray?, issuer: PAResourcesIssuer?) = mapOf(
|
|
126
|
+
"serialNumber" to serialNumber.toBase64(),
|
|
127
|
+
"issuer" to generatePAResourcesIssuer(issuer)
|
|
128
|
+
).toJson()
|
|
129
|
+
|
|
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()
|
|
135
|
+
|
|
136
|
+
fun regulaExceptionFromJSON(input: JSONObject?) = input?.let {
|
|
137
|
+
RegulaException(
|
|
138
|
+
it.optInt("code"),
|
|
139
|
+
it.optString("message")
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
fun generateRegulaException(input: RegulaException?) = input?.let {
|
|
144
|
+
mapOf(
|
|
145
|
+
"code" to it.errorCode,
|
|
146
|
+
"message" to it.message
|
|
147
|
+
).toJson()
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
fun transactionInfoFromJSON(input: JSONObject?) = input?.let {
|
|
151
|
+
val result = TransactionInfo()
|
|
152
|
+
result.transactionId = it.getStringOrNull("transactionId")
|
|
153
|
+
result.tag = it.getStringOrNull("tag")
|
|
154
|
+
result.sessionLogFolder = it.getStringOrNull("sessionLogFolder")
|
|
155
|
+
result
|
|
156
|
+
}
|
|
157
|
+
|
|
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()
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
fun tccParamsFromJSON(input: JSONObject) = input.let {
|
|
167
|
+
val result = TccParams()
|
|
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 {
|
|
210
|
+
var result = BleDeviceConfig(bluetooth!!)
|
|
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")
|
|
252
|
+
val images = arrayOfNulls<Bitmap>(base64Images.length())
|
|
253
|
+
for (i in images.indices) images[i] = base64Images.getString(i).toBitmap()
|
|
254
|
+
builder.setBitmaps(images)
|
|
255
|
+
}
|
|
256
|
+
if (it.has("imageInputData")) {
|
|
257
|
+
val base64InputData = it.getJSONArray("imageInputData")
|
|
258
|
+
val inputData = arrayOfNulls<ImageInputData>(base64InputData.length())
|
|
259
|
+
for (i in inputData.indices) inputData[i] = imageInputDataFromJSON(base64InputData.getJSONObject(i))
|
|
260
|
+
builder.setImageInputData(inputData)
|
|
261
|
+
}
|
|
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
|
|
292
|
+
}
|
|
293
|
+
result.rfidServerSideChipVerification = it.getBooleanOrNull("rfidServerSideChipVerification")
|
|
294
|
+
result.timeoutConnection = it.getDoubleOrNull("timeoutConnection")
|
|
295
|
+
result
|
|
296
|
+
}
|
|
297
|
+
|
|
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()
|
|
309
|
+
}
|
|
310
|
+
|
|
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")) {
|
|
320
|
+
val listener = NetworkInterceptorListener { input.getJSONObject("requestHeaders").forEach { k, v -> it.setRequestProperty(k, v as String) } }
|
|
321
|
+
weakReferencesHolder.add(listener)
|
|
322
|
+
builder.setNetworkInterceptorListener(listener)
|
|
323
|
+
}
|
|
324
|
+
builder.build()
|
|
325
|
+
}
|
|
326
|
+
|
|
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()
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
fun faceApiParamsFromJSON(input: JSONObject?) = input?.let {
|
|
338
|
+
val result = FaceApiParams()
|
|
339
|
+
|
|
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")
|
|
348
|
+
|
|
349
|
+
result
|
|
350
|
+
}
|
|
351
|
+
|
|
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()
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
fun faceApiSearchParamsFromJSON(input: JSONObject?) = input?.let {
|
|
366
|
+
val result = FaceApiParams.Search()
|
|
367
|
+
|
|
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")
|
|
372
|
+
val groupIds = IntArray(jsonArrayGroupIds.length())
|
|
373
|
+
for (i in 0 until jsonArrayGroupIds.length())
|
|
374
|
+
groupIds[i] = jsonArrayGroupIds.getInt(i)
|
|
375
|
+
result.groupIds = groupIds
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
result
|
|
379
|
+
}
|
|
380
|
+
|
|
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()
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
fun rfidParamsFromJSON(input: JSONObject?) = input?.let {
|
|
390
|
+
val result = RFIDParams()
|
|
391
|
+
if (it.has("paIgnoreNotificationCodes")) result.paIgnoreNotificationCodes = it.getJSONArray("paIgnoreNotificationCodes").toIntArray()
|
|
392
|
+
result
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
fun generateRFIDParams(input: RFIDParams?) = input?.let {
|
|
396
|
+
mapOf(
|
|
397
|
+
"paIgnoreNotificationCodes" to it.paIgnoreNotificationCodes.toJson()
|
|
398
|
+
).toJson()
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
fun processParamFromJSON(input: JSONObject): ProcessParam {
|
|
402
|
+
val result = ProcessParam()
|
|
403
|
+
setProcessParams(result, input)
|
|
404
|
+
return result
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
fun generateProcessParam(input: ProcessParam): JSONObject = getProcessParams(input)
|
|
408
|
+
|
|
409
|
+
fun imageQAFromJSON(input: JSONObject): ImageQA {
|
|
410
|
+
val result = ImageQA()
|
|
411
|
+
setImageQA(result, input)
|
|
412
|
+
return result
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
fun generateImageQA(input: ImageQA) = getImageQA(input)
|
|
416
|
+
|
|
417
|
+
fun authenticityParamsFromJSON(input: JSONObject): AuthenticityParams {
|
|
418
|
+
val result = AuthenticityParams.defaultParams()
|
|
419
|
+
setAuthenticityParams(result, input)
|
|
420
|
+
return result
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
fun generateAuthenticityParams(input: AuthenticityParams?) = getAuthenticityParams(input)
|
|
424
|
+
|
|
425
|
+
fun livenessParamsFromJSON(input: JSONObject): LivenessParams {
|
|
426
|
+
val result = LivenessParams.defaultParams()
|
|
427
|
+
setLivenessParams(result, input)
|
|
428
|
+
return result
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
fun generateLivenessParams(input: LivenessParams?) = getLivenessParams(input)
|
|
432
|
+
|
|
433
|
+
fun eDLDataGroupsFromJSON(input: JSONObject): EDLDataGroups {
|
|
434
|
+
val result = EDLDataGroups()
|
|
435
|
+
setDataGroups(result, input)
|
|
436
|
+
return result
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
fun generateEDLDataGroups(input: EDLDataGroups): JSONObject = getDataGroups(input)
|
|
440
|
+
|
|
441
|
+
fun ePassportDataGroupsFromJSON(input: JSONObject): EPassportDataGroups {
|
|
442
|
+
val result = EPassportDataGroups()
|
|
443
|
+
setDataGroups(result, input)
|
|
444
|
+
return result
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
fun generateEPassportDataGroups(input: EPassportDataGroups): JSONObject = getDataGroups(input)
|
|
448
|
+
|
|
449
|
+
fun eIDDataGroupsFromJSON(input: JSONObject): EIDDataGroups {
|
|
450
|
+
val result = EIDDataGroups()
|
|
451
|
+
setDataGroups(result, input)
|
|
452
|
+
return result
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
fun generateEIDDataGroups(input: EIDDataGroups): JSONObject = getDataGroups(input)
|
|
456
|
+
|
|
457
|
+
fun dtcDataGroupFromJSON(input: JSONObject): DTCDataGroup {
|
|
458
|
+
val result = DTCDataGroup()
|
|
459
|
+
setDTCDataGroup(result, input)
|
|
460
|
+
return result
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
fun generateDTCDataGroup(input: DTCDataGroup): JSONObject = getDTCDataGroup(input)
|
|
464
|
+
|
|
465
|
+
fun rfidScenarioFromJSON(input: JSONObject): RfidScenario {
|
|
466
|
+
val result = RfidScenario()
|
|
467
|
+
setRfidScenario(result, input)
|
|
468
|
+
return result
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
fun generateRfidScenario(input: RfidScenario): JSONObject = getRfidScenario(input)
|
|
472
|
+
|
|
473
|
+
fun customizationFromJSON(input: JSONObject): ParamsCustomization {
|
|
474
|
+
val result = ParamsCustomization()
|
|
475
|
+
setCustomization(result, input)
|
|
476
|
+
return result
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
fun generateCustomization(input: ParamsCustomization): JSONObject = getCustomization(input)
|
|
480
|
+
|
|
481
|
+
fun functionalityFromJSON(input: JSONObject): Functionality {
|
|
482
|
+
val result = Functionality()
|
|
483
|
+
setFunctionality(result, input)
|
|
484
|
+
return result
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
fun generateFunctionality(input: Functionality): JSONObject = getFunctionality(input)
|
|
488
|
+
|
|
489
|
+
fun glaresCheckParamsFromJSON(input: JSONObject?) = input?.let {
|
|
490
|
+
val result = GlaresCheckParams()
|
|
491
|
+
if (it.has("imgMarginPart")) result.imgMarginPart = it.getDouble("imgMarginPart")
|
|
492
|
+
if (it.has("maxGlaringPart")) result.maxGlaringPart = it.getDouble("maxGlaringPart")
|
|
493
|
+
result
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
fun generateGlaresCheckParams(input: GlaresCheckParams?) = input?.let {
|
|
497
|
+
mapOf(
|
|
498
|
+
"imgMarginPart" to it.imgMarginPart,
|
|
499
|
+
"maxGlaringPart" to it.maxGlaringPart
|
|
500
|
+
).toJson()
|
|
501
|
+
}
|
|
502
|
+
|
|
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
|
+
)
|
|
510
|
+
|
|
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()
|
|
517
|
+
}
|
|
518
|
+
|
|
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
|
+
)
|
|
525
|
+
}
|
|
526
|
+
|
|
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()
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
fun pkdCertificateFromJSON(input: JSONObject?) = input?.let {
|
|
536
|
+
var resourceType = 0
|
|
537
|
+
var binaryData = ByteArray(0)
|
|
538
|
+
|
|
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()
|
|
543
|
+
return PKDCertificate(binaryData, resourceType, privateKey)
|
|
544
|
+
}
|
|
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 {
|
|
594
|
+
val result = Rect()
|
|
595
|
+
|
|
596
|
+
result.bottom = it.optInt("bottom")
|
|
597
|
+
result.top = it.optInt("top")
|
|
598
|
+
result.left = it.optInt("left")
|
|
599
|
+
result.right = it.optInt("right")
|
|
600
|
+
|
|
601
|
+
result
|
|
602
|
+
}
|
|
603
|
+
|
|
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()
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
fun docReaderFieldRectFromJSON(input: JSONObject?) = input?.let {
|
|
614
|
+
val result = DocReaderFieldRect()
|
|
615
|
+
|
|
616
|
+
result.bottom = it.optInt("bottom")
|
|
617
|
+
result.top = it.optInt("top")
|
|
618
|
+
result.left = it.optInt("left")
|
|
619
|
+
result.right = it.optInt("right")
|
|
620
|
+
|
|
621
|
+
result
|
|
622
|
+
}
|
|
623
|
+
|
|
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()
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
fun documentReaderGraphicFieldFromJSON(input: JSONObject?) = input?.let {
|
|
634
|
+
val result = DocumentReaderGraphicField()
|
|
635
|
+
|
|
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"))
|
|
643
|
+
|
|
644
|
+
result
|
|
645
|
+
}
|
|
646
|
+
|
|
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()
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
fun documentReaderGraphicResultFromJSON(input: JSONObject?) = input?.let {
|
|
662
|
+
val result = DocumentReaderGraphicResult()
|
|
663
|
+
result.fields = it.optJSONArray("fields").toList(::documentReaderGraphicFieldFromJSON)!!
|
|
664
|
+
result
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
fun generateDocumentReaderGraphicResult(input: DocumentReaderGraphicResult?) = input?.let {
|
|
668
|
+
mapOf(
|
|
669
|
+
"fields" to it.fields.toJson(::generateDocumentReaderGraphicField)
|
|
670
|
+
).toJson()
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
fun documentReaderValueFromJSON(input: JSONObject?) = input?.let {
|
|
674
|
+
val result = DocumentReaderValue()
|
|
675
|
+
|
|
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"))
|
|
684
|
+
|
|
685
|
+
result
|
|
686
|
+
}
|
|
687
|
+
|
|
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()
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
fun documentReaderTextFieldFromJSON(input: JSONObject?) = input?.let {
|
|
702
|
+
val result = DocumentReaderTextField()
|
|
703
|
+
|
|
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 {
|
|
736
|
+
val result = DocumentReaderTextResult()
|
|
737
|
+
|
|
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)!!
|
|
743
|
+
|
|
744
|
+
result
|
|
745
|
+
}
|
|
746
|
+
|
|
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()
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
fun coordinateFromJSON(input: JSONObject?) = input?.let {
|
|
758
|
+
val result = Coordinate()
|
|
759
|
+
result.x = it.optInt("x")
|
|
760
|
+
result.y = it.optInt("y")
|
|
761
|
+
result
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
fun generateCoordinate(input: Coordinate?) = input?.let {
|
|
765
|
+
mapOf(
|
|
766
|
+
"x" to it.x,
|
|
767
|
+
"y" to it.y
|
|
768
|
+
).toJson()
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
fun elementPositionFromJSON(input: JSONObject?) = input?.let {
|
|
772
|
+
val result = ElementPosition()
|
|
773
|
+
|
|
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 {
|
|
816
|
+
val result = ImageQuality()
|
|
817
|
+
|
|
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)!!
|
|
822
|
+
|
|
823
|
+
result
|
|
824
|
+
}
|
|
825
|
+
|
|
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()
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
fun imageQualityGroupFromJSON(input: JSONObject?) = input?.let {
|
|
836
|
+
val result = ImageQualityGroup()
|
|
837
|
+
|
|
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)!!
|
|
842
|
+
|
|
843
|
+
result
|
|
844
|
+
}
|
|
845
|
+
|
|
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()
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
fun cameraSizeFromJSON(input: JSONObject) = input.let {
|
|
856
|
+
val width = it.getInt("width")
|
|
857
|
+
val height = it.getInt("height")
|
|
858
|
+
Pair(width, height)
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
fun generateCameraSize(width: Int?, height: Int?): JSONObject? {
|
|
862
|
+
width ?: return null
|
|
863
|
+
height ?: return null
|
|
864
|
+
return mapOf(
|
|
865
|
+
"width" to width,
|
|
866
|
+
"height" to height
|
|
867
|
+
).toJson()
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
fun documentReaderDocumentTypeFromJSON(input: JSONObject?) = input?.let {
|
|
871
|
+
val result = DocumentReaderDocumentType()
|
|
872
|
+
|
|
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 {
|
|
915
|
+
val result = AccessControlProcedureType()
|
|
916
|
+
|
|
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()
|
|
921
|
+
|
|
922
|
+
result
|
|
923
|
+
}
|
|
924
|
+
|
|
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()
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
fun fileDataFromJSON(input: JSONObject?) = input?.let {
|
|
935
|
+
val result = FileData()
|
|
936
|
+
|
|
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")
|
|
941
|
+
|
|
942
|
+
result
|
|
943
|
+
}
|
|
944
|
+
|
|
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()
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
fun certificateDataFromJSON(input: JSONObject?) = input?.let {
|
|
955
|
+
val result = CertificateData()
|
|
956
|
+
result.length = it.optInt("length")
|
|
957
|
+
result.data = it.optString("data")
|
|
958
|
+
result
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
fun generateCertificateData(input: CertificateData?) = input?.let {
|
|
962
|
+
mapOf(
|
|
963
|
+
"length" to it.length,
|
|
964
|
+
"data" to it.data
|
|
965
|
+
).toJson()
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
fun securityObjectCertificatesFromJSON(input: JSONObject?) = input?.let {
|
|
969
|
+
val result = SecurityObjectCertificates()
|
|
970
|
+
result.securityObject = certificateDataFromJSON(it.optJSONObject("securityObject"))
|
|
971
|
+
result
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
fun generateSecurityObjectCertificates(input: SecurityObjectCertificates?) = input?.let {
|
|
975
|
+
mapOf(
|
|
976
|
+
"securityObject" to generateCertificateData(it.securityObject)
|
|
977
|
+
).toJson()
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
fun fileFromJSON(input: JSONObject?) = input?.let {
|
|
981
|
+
val result = File()
|
|
982
|
+
|
|
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 {
|
|
1016
|
+
val result = Application()
|
|
1017
|
+
|
|
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)!!
|
|
1025
|
+
|
|
1026
|
+
result
|
|
1027
|
+
}
|
|
1028
|
+
|
|
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()
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
fun valueFromJSON(input: JSONObject?) = input?.let {
|
|
1042
|
+
val result = Value()
|
|
1043
|
+
|
|
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")
|
|
1049
|
+
|
|
1050
|
+
result
|
|
1051
|
+
}
|
|
1052
|
+
|
|
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()
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
fun attributeFromJSON(input: JSONObject?) = input?.let {
|
|
1064
|
+
val result = Attribute()
|
|
1065
|
+
result.type = it.optString("type")
|
|
1066
|
+
result.value = valueFromJSON(it.optJSONObject("value"))
|
|
1067
|
+
result
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
fun generateAttribute(input: Attribute?) = input?.let {
|
|
1071
|
+
mapOf(
|
|
1072
|
+
"type" to it.type,
|
|
1073
|
+
"value" to generateValue(it.value)
|
|
1074
|
+
).toJson()
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
fun authorityFromJSON(input: JSONObject?) = input?.let {
|
|
1078
|
+
val result = Authority()
|
|
1079
|
+
result.data = it.optString("data")
|
|
1080
|
+
result.friendlyName = valueFromJSON(it.optJSONObject("friendlyName"))
|
|
1081
|
+
result.attributes = it.optJSONArray("attributes").toList(::attributeFromJSON)!!
|
|
1082
|
+
result
|
|
1083
|
+
}
|
|
1084
|
+
|
|
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()
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
fun extensionFromJSON(input: JSONObject?) = input?.let {
|
|
1094
|
+
val result = Extension()
|
|
1095
|
+
result.data = it.optString("data")
|
|
1096
|
+
result.type = it.optString("type")
|
|
1097
|
+
result
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
fun generateExtension(input: Extension?) = input?.let {
|
|
1101
|
+
mapOf(
|
|
1102
|
+
"data" to it.data,
|
|
1103
|
+
"type" to it.type
|
|
1104
|
+
).toJson()
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
fun validityFromJSON(input: JSONObject?) = input?.let {
|
|
1108
|
+
val result = Validity()
|
|
1109
|
+
result.notAfter = valueFromJSON(it.optJSONObject("notAfter"))
|
|
1110
|
+
result.notBefore = valueFromJSON(it.optJSONObject("notBefore"))
|
|
1111
|
+
result
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
fun generateValidity(input: Validity?) = input?.let {
|
|
1115
|
+
mapOf(
|
|
1116
|
+
"notAfter" to generateValue(it.notAfter),
|
|
1117
|
+
"notBefore" to generateValue(it.notBefore)
|
|
1118
|
+
).toJson()
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
fun certificateChainFromJSON(input: JSONObject?) = input?.let {
|
|
1122
|
+
val result = CertificateChain()
|
|
1123
|
+
|
|
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 {
|
|
1160
|
+
val result = SignerInfo()
|
|
1161
|
+
|
|
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 {
|
|
1196
|
+
val result = SecurityObject()
|
|
1197
|
+
|
|
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)!!
|
|
1203
|
+
|
|
1204
|
+
result
|
|
1205
|
+
}
|
|
1206
|
+
|
|
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()
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
fun cardPropertiesFromJSON(input: JSONObject?) = input?.let {
|
|
1218
|
+
val result = CardProperties()
|
|
1219
|
+
|
|
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 {
|
|
1258
|
+
val result = RFIDSessionData()
|
|
1259
|
+
|
|
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 {
|
|
1292
|
+
val result = DataField()
|
|
1293
|
+
result.data = it.optString("data")
|
|
1294
|
+
result.fieldType = it.optInt("fieldType")
|
|
1295
|
+
result
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
fun generateDataField(input: DataField?) = input?.let {
|
|
1299
|
+
mapOf(
|
|
1300
|
+
"data" to it.data,
|
|
1301
|
+
"fieldType" to it.fieldType
|
|
1302
|
+
).toJson()
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
fun documentReaderAuthenticityCheckFromJSON(input: JSONObject?) = input?.let {
|
|
1306
|
+
val result = DocumentReaderAuthenticityCheck()
|
|
1307
|
+
result.type = it.optInt("type")
|
|
1308
|
+
result.pageIndex = it.optInt("pageIndex")
|
|
1309
|
+
result.elements = it.optJSONArray("elements").toList(::documentReaderAuthenticityElementFromJSON)!!
|
|
1310
|
+
result
|
|
1311
|
+
}
|
|
1312
|
+
|
|
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()
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
fun pdf417InfoFromJSON(input: JSONObject?) = input?.let {
|
|
1324
|
+
val result = PDF417Info()
|
|
1325
|
+
result.errorLevel = it.optInt("errorLevel")
|
|
1326
|
+
result.columns = it.optInt("columns")
|
|
1327
|
+
result.rows = it.optInt("rows")
|
|
1328
|
+
result
|
|
1329
|
+
}
|
|
1330
|
+
|
|
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()
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
fun documentReaderBarcodeResultFromJSON(input: JSONObject?) = input?.let {
|
|
1340
|
+
val result = DocumentReaderBarcodeResult()
|
|
1341
|
+
result.fields = it.optJSONArray("fields").toList(::documentReaderBarcodeFieldFromJSON)!!
|
|
1342
|
+
result
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
fun generateDocumentReaderBarcodeResult(input: DocumentReaderBarcodeResult?) = input?.let {
|
|
1346
|
+
mapOf(
|
|
1347
|
+
"fields" to it.fields.toJson(::generateDocumentReaderBarcodeField)
|
|
1348
|
+
).toJson()
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
fun documentReaderBarcodeFieldFromJSON(input: JSONObject?) = input?.let {
|
|
1352
|
+
val result = DocumentReaderBarcodeField()
|
|
1353
|
+
|
|
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()
|
|
1359
|
+
|
|
1360
|
+
result
|
|
1361
|
+
}
|
|
1362
|
+
|
|
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()
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
fun documentReaderAuthenticityResultFromJSON(input: JSONObject?) = input?.let {
|
|
1374
|
+
val result = DocumentReaderAuthenticityResult()
|
|
1375
|
+
result.checks = it.optJSONArray("checks").toList(::documentReaderAuthenticityCheckFromJSON)!!
|
|
1376
|
+
result
|
|
1377
|
+
}
|
|
1378
|
+
|
|
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()
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
fun documentReaderAuthenticityElementFromJSON(input: JSONObject?) = input?.let {
|
|
1388
|
+
val result = DocumentReaderAuthenticityElement()
|
|
1389
|
+
result.status = it.optInt("status")
|
|
1390
|
+
result.elementType = it.optInt("elementType")
|
|
1391
|
+
result.elementDiagnose = it.optInt("elementDiagnose")
|
|
1392
|
+
result
|
|
1393
|
+
}
|
|
1394
|
+
|
|
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()
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
fun paResourcesIssuerFromJSON(input: JSONObject?) = input?.let {
|
|
1406
|
+
val result = PAResourcesIssuer()
|
|
1407
|
+
result.data = it.optString("data").toByteArray()
|
|
1408
|
+
result.friendlyName = it.optString("friendlyName")
|
|
1409
|
+
result.attributes = it.optJSONArray("attributes").toArray(::paAttributeFromJSON)
|
|
1410
|
+
result
|
|
1411
|
+
}
|
|
1412
|
+
|
|
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()
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
fun paAttributeFromJSON(input: JSONObject?) = input?.let {
|
|
1422
|
+
val result = PAAttribute()
|
|
1423
|
+
result.type = it.optString("type")
|
|
1424
|
+
result.value = it.optString("value")
|
|
1425
|
+
result
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
fun generatePAAttribute(input: PAAttribute?) = input?.let {
|
|
1429
|
+
mapOf(
|
|
1430
|
+
"type" to it.type,
|
|
1431
|
+
"value" to it.value
|
|
1432
|
+
).toJson()
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
fun taChallengeFromJSON(input: JSONObject?) = input?.let {
|
|
1436
|
+
val result = TAChallenge()
|
|
1437
|
+
|
|
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
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
fun vdsncDataFromJSON(input: JSONObject) = VDSNCData.fromJson(vdsncDataDictionaryFromJSON(input))
|
|
1517
|
+
|
|
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()
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
fun bytesDataDictionaryFromJSON(input: JSONObject?) = input?.let {
|
|
1537
|
+
val result = JSONObject(input.toString())
|
|
1538
|
+
|
|
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"))
|
|
1543
|
+
|
|
1544
|
+
result
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
fun bytesDataFromJSON(input: JSONObject?) = BytesData.fromJson(bytesDataDictionaryFromJSON(input))
|
|
1548
|
+
|
|
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 {
|
|
1596
|
+
val result = DocumentReaderComparison()
|
|
1597
|
+
result.sourceTypeLeft = it.optInt("sourceTypeLeft")
|
|
1598
|
+
result.sourceTypeRight = it.optInt("sourceTypeRight")
|
|
1599
|
+
result.status = it.optInt("status")
|
|
1600
|
+
result
|
|
1601
|
+
}
|
|
1602
|
+
|
|
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()
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
fun documentReaderRFIDOriginFromJSON(input: JSONObject?) = input?.let {
|
|
1612
|
+
val result = DocumentReaderRfidOrigin()
|
|
1613
|
+
|
|
1614
|
+
result.dg = it.optInt("dg")
|
|
1615
|
+
result.dgTag = it.optInt("dgTag")
|
|
1616
|
+
result.entryView = it.optInt("entryView")
|
|
1617
|
+
result.tagEntry = it.optInt("tagEntry")
|
|
1618
|
+
|
|
1619
|
+
result
|
|
1620
|
+
}
|
|
1621
|
+
|
|
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()
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
fun documentReaderTextSourceFromJSON(input: JSONObject?) = input?.let {
|
|
1632
|
+
val result = DocumentReaderTextSource()
|
|
1633
|
+
result.sourceType = it.optInt("sourceType")
|
|
1634
|
+
result.source = it.optString("source")
|
|
1635
|
+
result.validityStatus = it.optInt("validityStatus")
|
|
1636
|
+
result
|
|
1637
|
+
}
|
|
1638
|
+
|
|
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()
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
fun documentReaderSymbolFromJSON(input: JSONObject?) = input?.let {
|
|
1648
|
+
val result = DocumentReaderSymbol()
|
|
1649
|
+
result.code = it.optInt("code")
|
|
1650
|
+
result.probability = it.optInt("probability")
|
|
1651
|
+
result.rect = rectFromJSON(it.optJSONObject("rect"))
|
|
1652
|
+
result
|
|
1653
|
+
}
|
|
1654
|
+
|
|
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()
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
fun documentReaderValidityFromJSON(input: JSONObject?) = input?.let {
|
|
1664
|
+
val result = DocumentReaderValidity()
|
|
1665
|
+
result.sourceType = it.optInt("sourceType")
|
|
1666
|
+
result.status = it.optInt("status")
|
|
1667
|
+
result
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
fun generateDocumentReaderValidity(input: DocumentReaderValidity?) = input?.let {
|
|
1671
|
+
mapOf(
|
|
1672
|
+
"sourceType" to it.sourceType,
|
|
1673
|
+
"status" to it.status
|
|
1674
|
+
).toJson()
|
|
1675
|
+
}
|
|
1676
|
+
|
|
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
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
fun generateBarcodeTypeArray(input: Array<String?>?) = input?.let {
|
|
1684
|
+
val result = JSONArray()
|
|
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 {
|
|
1713
|
+
val result = DocumentReaderResults()
|
|
1714
|
+
|
|
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
|
|
1778
|
+
}
|