@regulaforensics/cordova-plugin-document-reader-api 5.4.0 → 5.8.0
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/README.md +4 -3
- package/example/config.xml +1 -1
- package/example/package.json +7 -5
- package/example/www/index.html +6 -1
- package/example/www/js/index.js +61 -7
- package/package.json +1 -1
- package/plugin.xml +5 -4
- package/src/android/DocumentReader.java +227 -20
- package/src/android/Helpers.java +146 -0
- package/src/android/JSONConstructor.java +1830 -507
- package/src/android/RegulaConfig.java +85 -18
- package/src/android/build.gradle +11 -11
- package/src/ios/RGLDocumentReader.h +8 -3
- package/src/ios/RGLDocumentReader.m +163 -12
- package/src/ios/RGLWJSONConstructor.h +60 -0
- package/src/ios/RGLWJSONConstructor.m +918 -0
- package/src/ios/RegulaConfig.h +2 -0
- package/src/ios/RegulaConfig.m +128 -33
- package/www/DocumentReader.js +902 -667
- package/src/ios/JSONConstructor.h +0 -33
- package/src/ios/JSONConstructor.m +0 -821
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
package cordova.plugin.documentreader;
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
|
+
import android.graphics.Bitmap;
|
|
4
5
|
import android.graphics.BitmapFactory;
|
|
5
|
-
import android.graphics.Canvas;
|
|
6
|
-
import android.graphics.Matrix;
|
|
7
6
|
import android.graphics.Rect;
|
|
8
|
-
import android.graphics.Bitmap;
|
|
9
|
-
import android.graphics.drawable.BitmapDrawable;
|
|
10
|
-
import android.graphics.drawable.Drawable;
|
|
11
7
|
import android.util.Base64;
|
|
12
8
|
|
|
13
|
-
import com.regula.documentreader.api.enums.BarcodeType;
|
|
14
9
|
import com.regula.documentreader.api.enums.DocReaderAction;
|
|
10
|
+
import com.regula.documentreader.api.enums.PDF417Info;
|
|
11
|
+
import com.regula.documentreader.api.enums.eGraphicFieldType;
|
|
12
|
+
import com.regula.documentreader.api.enums.eRPRM_Lights;
|
|
13
|
+
import com.regula.documentreader.api.errors.DocumentReaderException;
|
|
15
14
|
import com.regula.documentreader.api.params.FaceMetaData;
|
|
15
|
+
import com.regula.documentreader.api.params.rfid.authorization.PAAttribute;
|
|
16
|
+
import com.regula.documentreader.api.params.rfid.authorization.PAResourcesIssuer;
|
|
17
|
+
import com.regula.documentreader.api.params.rfid.authorization.TAChallenge;
|
|
16
18
|
import com.regula.documentreader.api.results.Bounds;
|
|
17
19
|
import com.regula.documentreader.api.results.Coordinate;
|
|
18
20
|
import com.regula.documentreader.api.results.DocReaderFieldRect;
|
|
21
|
+
import com.regula.documentreader.api.results.DocumentReaderBarcodeField;
|
|
22
|
+
import com.regula.documentreader.api.results.DocumentReaderBarcodeResult;
|
|
19
23
|
import com.regula.documentreader.api.results.DocumentReaderDocumentType;
|
|
20
24
|
import com.regula.documentreader.api.results.DocumentReaderGraphicField;
|
|
21
25
|
import com.regula.documentreader.api.results.DocumentReaderGraphicResult;
|
|
22
26
|
import com.regula.documentreader.api.results.DocumentReaderNotification;
|
|
23
27
|
import com.regula.documentreader.api.results.DocumentReaderResults;
|
|
28
|
+
import com.regula.documentreader.api.results.DocumentReaderScenario;
|
|
24
29
|
import com.regula.documentreader.api.results.DocumentReaderScenarioFull;
|
|
25
30
|
import com.regula.documentreader.api.results.DocumentReaderTextField;
|
|
26
31
|
import com.regula.documentreader.api.results.DocumentReaderTextResult;
|
|
@@ -28,12 +33,9 @@ import com.regula.documentreader.api.results.DocumentReaderValue;
|
|
|
28
33
|
import com.regula.documentreader.api.results.ElementPosition;
|
|
29
34
|
import com.regula.documentreader.api.results.ImageQuality;
|
|
30
35
|
import com.regula.documentreader.api.results.ImageQualityGroup;
|
|
31
|
-
import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityResult;
|
|
32
36
|
import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityCheck;
|
|
33
37
|
import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityElement;
|
|
34
|
-
import com.regula.documentreader.api.results.
|
|
35
|
-
import com.regula.documentreader.api.results.DocumentReaderBarcodeField;
|
|
36
|
-
import com.regula.documentreader.api.results.DocumentReaderScenario;
|
|
38
|
+
import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityResult;
|
|
37
39
|
import com.regula.documentreader.api.results.rfid.AccessControlProcedureType;
|
|
38
40
|
import com.regula.documentreader.api.results.rfid.Application;
|
|
39
41
|
import com.regula.documentreader.api.results.rfid.Attribute;
|
|
@@ -51,218 +53,189 @@ import com.regula.documentreader.api.results.rfid.SecurityObjectCertificates;
|
|
|
51
53
|
import com.regula.documentreader.api.results.rfid.SignerInfo;
|
|
52
54
|
import com.regula.documentreader.api.results.rfid.Validity;
|
|
53
55
|
import com.regula.documentreader.api.results.rfid.Value;
|
|
54
|
-
import com.regula.documentreader.api.enums.PDF417Info;
|
|
55
|
-
import com.regula.documentreader.api.enums.eRPRM_Lights;
|
|
56
|
-
import com.regula.documentreader.api.enums.eGraphicFieldType;
|
|
57
56
|
|
|
58
57
|
import org.json.JSONArray;
|
|
59
58
|
import org.json.JSONException;
|
|
60
59
|
import org.json.JSONObject;
|
|
61
60
|
|
|
62
|
-
import java.io.ByteArrayInputStream;
|
|
63
61
|
import java.io.ByteArrayOutputStream;
|
|
64
62
|
import java.util.ArrayList;
|
|
65
63
|
import java.util.List;
|
|
66
64
|
import java.util.Map;
|
|
67
|
-
import java.util.Objects;
|
|
68
65
|
|
|
69
|
-
@SuppressWarnings("RedundantSuppression")
|
|
66
|
+
@SuppressWarnings({"ConstantConditions", "unused", "RedundantSuppression"})
|
|
70
67
|
class JSONConstructor {
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
interface JSONObjectGeneratorWithContext<T> {
|
|
69
|
+
JSONObject generateJSONObject(T param, Context context) throws JSONException;
|
|
70
|
+
}
|
|
73
71
|
|
|
74
72
|
interface JSONObjectGenerator<T> {
|
|
75
|
-
JSONObject generateJSONObject(T param
|
|
73
|
+
JSONObject generateJSONObject(T param) throws JSONException;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
interface StringGenerator<T> {
|
|
77
|
+
String generateString(T param);
|
|
76
78
|
}
|
|
77
79
|
|
|
78
|
-
static <T> JSONArray generateList(List<T> list
|
|
80
|
+
static <T> JSONArray generateList(List<T> list) {
|
|
79
81
|
JSONArray result = new JSONArray();
|
|
82
|
+
if(list == null) return result;
|
|
80
83
|
for (T t : list)
|
|
81
84
|
if (t != null)
|
|
82
|
-
result.put(
|
|
85
|
+
result.put(t);
|
|
83
86
|
|
|
84
87
|
return result;
|
|
85
88
|
}
|
|
86
89
|
|
|
87
|
-
static <T> JSONArray generateList(List<T> list) {
|
|
90
|
+
static <T> JSONArray generateList(List<T> list, JSONObjectGenerator<T> generator) throws JSONException {
|
|
88
91
|
JSONArray result = new JSONArray();
|
|
92
|
+
if(list == null) return result;
|
|
89
93
|
for (T t : list)
|
|
90
94
|
if (t != null)
|
|
91
|
-
result.put(t);
|
|
95
|
+
result.put(generator.generateJSONObject(t));
|
|
96
|
+
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static <T> JSONArray generateList(List<T> list, StringGenerator<T> generator) {
|
|
101
|
+
JSONArray result = new JSONArray();
|
|
102
|
+
if(list == null) return result;
|
|
103
|
+
for (T t : list)
|
|
104
|
+
if (t != null)
|
|
105
|
+
result.put(generator.generateString(t));
|
|
106
|
+
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
static <T> JSONArray generateList(List<T> list, JSONObjectGeneratorWithContext<T> generator, Context context) throws JSONException {
|
|
111
|
+
JSONArray result = new JSONArray();
|
|
112
|
+
if(list == null) return result;
|
|
113
|
+
for (T t : list)
|
|
114
|
+
if (t != null)
|
|
115
|
+
result.put(generator.generateJSONObject(t, context));
|
|
92
116
|
|
|
93
117
|
return result;
|
|
94
118
|
}
|
|
95
119
|
|
|
96
120
|
static <T> JSONArray generateArray(T[] array) throws JSONException {
|
|
97
121
|
JSONArray result = new JSONArray();
|
|
122
|
+
if(array == null) return result;
|
|
98
123
|
for (int i = 0; i < array.length; i++)
|
|
99
124
|
result.put(i, array[i]);
|
|
100
125
|
|
|
101
126
|
return result;
|
|
102
127
|
}
|
|
103
128
|
|
|
104
|
-
static <T> JSONArray generateArray(T[] array, JSONObjectGenerator<T> generator
|
|
129
|
+
static <T> JSONArray generateArray(T[] array, JSONObjectGenerator<T> generator) throws JSONException {
|
|
105
130
|
JSONArray result = new JSONArray();
|
|
131
|
+
if(array == null) return result;
|
|
106
132
|
for (int i = 0; i < array.length; i++)
|
|
107
|
-
result.put(i, generator.generateJSONObject(array[i]
|
|
133
|
+
result.put(i, generator.generateJSONObject(array[i]));
|
|
108
134
|
|
|
109
135
|
return result;
|
|
110
136
|
}
|
|
111
137
|
|
|
112
|
-
static
|
|
113
|
-
|
|
114
|
-
if
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
jsonObject.put("highResolution", results.highResolution);
|
|
118
|
-
jsonObject.put("morePagesAvailable", results.morePagesAvailable);
|
|
119
|
-
jsonObject.put("processingFinishedStatus", results.processingFinishedStatus);
|
|
120
|
-
jsonObject.put("rfidResult", results.rfidResult);
|
|
121
|
-
jsonObject.put("elapsedTimeRFID", results.elapsedTimeRFID);
|
|
122
|
-
jsonObject.put("elapsedTime", results.elapsedTime);
|
|
123
|
-
jsonObject.put("overallResult", results.getOverallResult());
|
|
124
|
-
jsonObject.put("documentType", generateList(results.documentType, JSONConstructor::generateDocumentReaderDocumentType, context));
|
|
125
|
-
if (results.barcodePosition != null)
|
|
126
|
-
jsonObject.put("barcodePosition", generateElementPosition(results.barcodePosition));
|
|
127
|
-
if (results.documentPosition != null)
|
|
128
|
-
jsonObject.put("documentPosition", generateElementPosition(results.documentPosition));
|
|
129
|
-
if (results.documentReaderNotification != null)
|
|
130
|
-
jsonObject.put("documentReaderNotification", generateDocumentReaderNotification(results.documentReaderNotification));
|
|
131
|
-
if (results.graphicResult != null)
|
|
132
|
-
jsonObject.put("graphicResult", generateDocumentReaderGraphicResult(results.graphicResult, context));
|
|
133
|
-
if (results.imageQuality != null)
|
|
134
|
-
jsonObject.put("imageQuality", generateImageQualityGroup(results.imageQuality, context));
|
|
135
|
-
if (results.rawResult != null)
|
|
136
|
-
jsonObject.put("rawResult", results.rawResult);
|
|
137
|
-
if (results.mrzPosition != null)
|
|
138
|
-
jsonObject.put("mrzPosition", generateElementPosition(results.mrzPosition));
|
|
139
|
-
if (results.rfidSessionData != null)
|
|
140
|
-
jsonObject.put("rfidSessionData", generateRfidSessionData(results.rfidSessionData, context));
|
|
141
|
-
if (results.textResult != null)
|
|
142
|
-
jsonObject.put("textResult", generateDocumentReaderTextResult(results.textResult, context));
|
|
143
|
-
if (results.authenticityResult != null)
|
|
144
|
-
jsonObject.put("authenticityResult", generateDocumentReaderAuthenticityResult(results.authenticityResult, context));
|
|
145
|
-
if (results.barcodeResult != null)
|
|
146
|
-
jsonObject.put("barcodeResult", generateDocumentReaderBarcodeResult(results.barcodeResult, context));
|
|
147
|
-
} catch (JSONException ignored) {
|
|
148
|
-
}
|
|
138
|
+
static <T> JSONArray generateArray(T[] array, StringGenerator<T> generator) throws JSONException {
|
|
139
|
+
JSONArray result = new JSONArray();
|
|
140
|
+
if(array == null) return result;
|
|
141
|
+
for (int i = 0; i < array.length; i++)
|
|
142
|
+
result.put(i, generator.generateString(array[i]));
|
|
149
143
|
|
|
150
|
-
return
|
|
144
|
+
return result;
|
|
151
145
|
}
|
|
152
146
|
|
|
153
|
-
static
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
147
|
+
static <T> JSONArray generateArray(T[] array, JSONObjectGeneratorWithContext<T> generator, Context context) throws JSONException {
|
|
148
|
+
JSONArray result = new JSONArray();
|
|
149
|
+
if(array == null) return result;
|
|
150
|
+
for (int i = 0; i < array.length; i++)
|
|
151
|
+
result.put(i, generator.generateJSONObject(array[i], context));
|
|
152
|
+
|
|
153
|
+
return result;
|
|
157
154
|
}
|
|
158
155
|
|
|
159
|
-
static JSONObject
|
|
156
|
+
static <T, V> JSONObject generateMap(Map<T, V> map) throws JSONException {
|
|
160
157
|
JSONObject result = new JSONObject();
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
result.put("pageIndex", elementPosition.pageIndex);
|
|
166
|
-
result.put("dpi", elementPosition.dpi);
|
|
167
|
-
result.put("inverse", elementPosition.inverse);
|
|
168
|
-
result.put("resultStatus", elementPosition.resultStatus);
|
|
169
|
-
result.put("docFormat", elementPosition.docFormat);
|
|
170
|
-
result.put("height", elementPosition.height);
|
|
171
|
-
result.put("width", elementPosition.width);
|
|
172
|
-
result.put("center", generateCoordinate(elementPosition.center));
|
|
173
|
-
result.put("leftBottom", generateCoordinate(elementPosition.leftBottom));
|
|
174
|
-
result.put("leftTop", generateCoordinate(elementPosition.leftTop));
|
|
175
|
-
result.put("rightBottom", generateCoordinate(elementPosition.rightBottom));
|
|
176
|
-
result.put("rightTop", generateCoordinate(elementPosition.rightTop));
|
|
177
|
-
|
|
158
|
+
if(map == null) return result;
|
|
159
|
+
for (Map.Entry<T, V> entry : map.entrySet())
|
|
160
|
+
if (entry != null)
|
|
161
|
+
result.put(entry.getKey().toString(), entry.getValue());
|
|
178
162
|
return result;
|
|
179
163
|
}
|
|
180
164
|
|
|
181
|
-
static JSONObject
|
|
165
|
+
static <T, V> JSONObject generateMap(Map<T, V> map, JSONObjectGenerator<V> generator) throws JSONException {
|
|
182
166
|
JSONObject result = new JSONObject();
|
|
183
|
-
if
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
167
|
+
if(map == null) return result;
|
|
168
|
+
for (Map.Entry<T, V> entry : map.entrySet())
|
|
169
|
+
if (entry != null)
|
|
170
|
+
result.put(entry.getKey().toString(), generator.generateJSONObject(entry.getValue()));
|
|
187
171
|
return result;
|
|
188
172
|
}
|
|
189
173
|
|
|
190
|
-
static JSONObject
|
|
174
|
+
static <T, V> JSONObject generateMap(Map<T, V> map, StringGenerator<V> generator) throws JSONException {
|
|
191
175
|
JSONObject result = new JSONObject();
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
result.put("seriesProcessMode", documentReaderScenario.seriesProcessMode);
|
|
197
|
-
|
|
176
|
+
if(map == null) return result;
|
|
177
|
+
for (Map.Entry<T, V> entry : map.entrySet())
|
|
178
|
+
if (entry != null)
|
|
179
|
+
result.put(entry.getKey().toString(), generator.generateString(entry.getValue()));
|
|
198
180
|
return result;
|
|
199
181
|
}
|
|
200
182
|
|
|
201
|
-
static JSONObject
|
|
183
|
+
static <T, V> JSONObject generateMap(Map<T, V> map, JSONObjectGeneratorWithContext<V> generator, Context context) throws JSONException {
|
|
202
184
|
JSONObject result = new JSONObject();
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
result
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
result
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
185
|
+
if(map == null) return result;
|
|
186
|
+
for (Map.Entry<T, V> entry : map.entrySet())
|
|
187
|
+
if (entry != null)
|
|
188
|
+
result.put(entry.getKey().toString(), generator.generateJSONObject(entry.getValue(), context));
|
|
189
|
+
return result;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
static JSONArray generateIntArray(int[] array) throws JSONException {
|
|
193
|
+
JSONArray result = new JSONArray();
|
|
194
|
+
if(array == null) return result;
|
|
195
|
+
for (int i = 0; i < array.length; i++)
|
|
196
|
+
result.put(i, array[i]);
|
|
215
197
|
|
|
216
198
|
return result;
|
|
217
199
|
}
|
|
218
200
|
|
|
219
|
-
static
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
201
|
+
static JSONArray generateBooleanArray(boolean[] array) throws JSONException {
|
|
202
|
+
JSONArray result = new JSONArray();
|
|
203
|
+
if(array == null) return result;
|
|
204
|
+
for (int i = 0; i < array.length; i++)
|
|
205
|
+
result.put(i, array[i]);
|
|
224
206
|
|
|
225
207
|
return result;
|
|
226
208
|
}
|
|
227
209
|
|
|
228
|
-
static
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
documentType.put("dType", documentReaderDocumentType.dType);
|
|
234
|
-
documentType.put("dCountryName", documentReaderDocumentType.dCountryName);
|
|
235
|
-
documentType.put("dDescription", documentReaderDocumentType.dDescription);
|
|
236
|
-
documentType.put("dYear", documentReaderDocumentType.dYear);
|
|
237
|
-
documentType.put("ICAOCode", documentReaderDocumentType.ICAOCode);
|
|
238
|
-
documentType.put("name", documentReaderDocumentType.name);
|
|
239
|
-
documentType.put("pageIndex", documentReaderDocumentType.pageIndex);
|
|
240
|
-
if (documentReaderDocumentType.FDSID != null)
|
|
241
|
-
documentType.put("FDSID", generateIntArray(documentReaderDocumentType.FDSID));
|
|
210
|
+
static JSONArray generateDoubleArray(double[] array) throws JSONException {
|
|
211
|
+
JSONArray result = new JSONArray();
|
|
212
|
+
if(array == null) return result;
|
|
213
|
+
for (int i = 0; i < array.length; i++)
|
|
214
|
+
result.put(i, array[i]);
|
|
242
215
|
|
|
243
|
-
return
|
|
216
|
+
return result;
|
|
244
217
|
}
|
|
245
218
|
|
|
246
|
-
static
|
|
247
|
-
|
|
219
|
+
static JSONArray generateByteArray(byte[] array) throws JSONException {
|
|
220
|
+
JSONArray result = new JSONArray();
|
|
221
|
+
if(array == null) return result;
|
|
222
|
+
for (int i = 0; i < array.length; i++)
|
|
223
|
+
result.put(i, array[i]);
|
|
224
|
+
|
|
225
|
+
return result;
|
|
248
226
|
}
|
|
249
227
|
|
|
250
|
-
static
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
result.put("lightType", documentReaderGraphicField.light);
|
|
256
|
-
result.put("lightName", eRPRM_Lights.getTranslation(context, documentReaderGraphicField.light));
|
|
257
|
-
result.put("pageIndex", documentReaderGraphicField.pageIndex);
|
|
258
|
-
result.put("value", documentReaderGraphicField.imageBase64());
|
|
259
|
-
if (documentReaderGraphicField.boundRect != null)
|
|
260
|
-
result.put("fieldRect", generateDocReaderFieldRect(documentReaderGraphicField.boundRect));
|
|
228
|
+
static JSONArray generateLongArray(long[] array) throws JSONException {
|
|
229
|
+
JSONArray result = new JSONArray();
|
|
230
|
+
if(array == null) return result;
|
|
231
|
+
for (int i = 0; i < array.length; i++)
|
|
232
|
+
result.put(i, array[i]);
|
|
261
233
|
|
|
262
234
|
return result;
|
|
263
235
|
}
|
|
264
236
|
|
|
265
|
-
static String
|
|
237
|
+
static String generateBitmap(Bitmap bitmap) {
|
|
238
|
+
if (bitmap == null) return "";
|
|
266
239
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
267
240
|
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
|
|
268
241
|
byte[] byteArray = byteArrayOutputStream.toByteArray();
|
|
@@ -270,555 +243,1905 @@ class JSONConstructor {
|
|
|
270
243
|
return Base64.encodeToString(byteArray, Base64.DEFAULT);
|
|
271
244
|
}
|
|
272
245
|
|
|
273
|
-
static
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
result.
|
|
278
|
-
result.
|
|
279
|
-
|
|
246
|
+
static Bitmap BitmapFromJSON(String base64) {
|
|
247
|
+
byte[] decodedString = Base64.decode(base64, Base64.DEFAULT);
|
|
248
|
+
BitmapFactory.Options options = new BitmapFactory.Options();
|
|
249
|
+
options.inPreferredConfig = Bitmap.Config.RGB_565;
|
|
250
|
+
Bitmap result = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length, options);
|
|
251
|
+
int sizeMultiplier = result.getByteCount() / 5000000;
|
|
252
|
+
if (result.getByteCount() > 5000000)
|
|
253
|
+
result = Bitmap.createScaledBitmap(result, result.getWidth() / (int) Math.sqrt(sizeMultiplier), result.getHeight() / (int) Math.sqrt(sizeMultiplier), false);
|
|
280
254
|
return result;
|
|
281
255
|
}
|
|
282
256
|
|
|
283
|
-
static
|
|
257
|
+
static JSONObject generateVideoEncoderCompletion(String sessionId, java.io.File file) {
|
|
284
258
|
JSONObject result = new JSONObject();
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
259
|
+
|
|
260
|
+
try {
|
|
261
|
+
result.put("sessionId", sessionId);
|
|
262
|
+
result.put("filePath", file.getPath());
|
|
263
|
+
|
|
264
|
+
} catch (JSONException e) {
|
|
265
|
+
e.printStackTrace();
|
|
266
|
+
}
|
|
288
267
|
|
|
289
268
|
return result;
|
|
290
269
|
}
|
|
291
270
|
|
|
292
|
-
static
|
|
271
|
+
static JSONObject generateCompletion(int action, DocumentReaderResults results, DocumentReaderException error, Context context) {
|
|
293
272
|
JSONObject result = new JSONObject();
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
273
|
+
try {
|
|
274
|
+
result.put("action", action);
|
|
275
|
+
switch (action) {
|
|
276
|
+
case DocReaderAction.PROCESS:
|
|
277
|
+
case DocReaderAction.PROCESS_WHITE_UV_IMAGES:
|
|
278
|
+
break;
|
|
279
|
+
case DocReaderAction.NOTIFICATION:
|
|
280
|
+
result.put("results", generateDocumentReaderResultsNotification(results));
|
|
281
|
+
break;
|
|
282
|
+
case DocReaderAction.COMPLETE:
|
|
283
|
+
case DocReaderAction.MORE_PAGES_AVAILABLE:
|
|
284
|
+
case DocReaderAction.CANCEL:
|
|
285
|
+
case DocReaderAction.ERROR:
|
|
286
|
+
result.put("results", generateDocumentReaderResults(results, context));
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
if (error != null)
|
|
290
|
+
result.put("error", generateDocumentReaderException(error));
|
|
291
|
+
} catch (JSONException ignored) {
|
|
292
|
+
}
|
|
297
293
|
|
|
298
294
|
return result;
|
|
299
295
|
}
|
|
300
296
|
|
|
301
|
-
static
|
|
297
|
+
static JSONObject generatePACertificateCompletion(byte[] serialNumber, PAResourcesIssuer issuer) {
|
|
302
298
|
JSONObject result = new JSONObject();
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
result.put("accessControls", generateList(rfidSessionData.accessControls, JSONConstructor::generateAccessControlProcedureType, context));
|
|
309
|
-
result.put("applications", generateList(rfidSessionData.applications, JSONConstructor::generateApplication, context));
|
|
310
|
-
result.put("securityObjects", generateList(rfidSessionData.securityObjects, JSONConstructor::generateSecurityObject, context));
|
|
311
|
-
if (rfidSessionData.cardProperties != null)
|
|
312
|
-
result.put("cardProperties", generateCardProperties(rfidSessionData.cardProperties));
|
|
313
|
-
if (rfidSessionData.sessionDataStatus != null)
|
|
314
|
-
result.put("sessionDataStatus", generateRFIDSessionDataStatus(rfidSessionData.sessionDataStatus));
|
|
299
|
+
try {
|
|
300
|
+
result.put("serialNumber", generateByteArray(serialNumber));
|
|
301
|
+
result.put("issuer", generatePAResourcesIssuer(issuer));
|
|
302
|
+
} catch (JSONException ignored) {
|
|
303
|
+
}
|
|
315
304
|
|
|
316
305
|
return result;
|
|
317
306
|
}
|
|
318
307
|
|
|
319
|
-
static
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
result.put("PA", input.PA);
|
|
325
|
-
result.put("PACE", input.PACE);
|
|
326
|
-
result.put("TA", input.TA);
|
|
327
|
-
result.put("overallStatus", input.overallStatus);
|
|
308
|
+
static JSONObject generateDocumentReaderResultsNotification(DocumentReaderResults results) throws JSONException {
|
|
309
|
+
if (results != null && results.documentReaderNotification != null)
|
|
310
|
+
return new JSONObject().put("documentReaderNotification", generateDocumentReaderNotification(results.documentReaderNotification));
|
|
311
|
+
return new JSONObject();
|
|
312
|
+
}
|
|
328
313
|
|
|
314
|
+
static DocumentReaderNotification DocumentReaderNotificationFromJSON(JSONObject jsonObject) {
|
|
315
|
+
DocumentReaderNotification result = new DocumentReaderNotification();
|
|
316
|
+
try {
|
|
317
|
+
if (jsonObject.has("value"))
|
|
318
|
+
result.value = jsonObject.getInt("value");
|
|
319
|
+
} catch (JSONException ignored) {
|
|
320
|
+
}
|
|
329
321
|
return result;
|
|
330
322
|
}
|
|
331
323
|
|
|
332
|
-
static
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
accessControl.put("status", type.status);
|
|
336
|
-
accessControl.put("type", type.type);
|
|
337
|
-
accessControl.put("notifications", generateList(type.notifications));
|
|
324
|
+
static Throwable ThrowableFromJSON(JSONObject jsonObject) {
|
|
325
|
+
return new Throwable();
|
|
326
|
+
}
|
|
338
327
|
|
|
339
|
-
|
|
328
|
+
static StackTraceElement StackTraceElementFromJSON(JSONObject jsonObject) {
|
|
329
|
+
return null;
|
|
340
330
|
}
|
|
341
331
|
|
|
342
|
-
|
|
343
|
-
JSONObject result = new JSONObject();
|
|
344
|
-
result.put("status", application.status);
|
|
345
|
-
result.put("type", application.type);
|
|
346
|
-
result.put("applicationID", application.applicationID);
|
|
347
|
-
result.put("dataHashAlgorithm", application.dataHashAlgorithm);
|
|
348
|
-
result.put("unicodeVersion", application.unicodeVersion);
|
|
349
|
-
result.put("version", application.version);
|
|
350
|
-
result.put("files", generateList(application.files, JSONConstructor::generateFile, context));
|
|
332
|
+
// To JSON
|
|
351
333
|
|
|
334
|
+
static JSONObject generateDocumentReaderScenario(DocumentReaderScenario input) {
|
|
335
|
+
JSONObject result = new JSONObject();
|
|
336
|
+
if (input == null) return result;
|
|
337
|
+
try {
|
|
338
|
+
result.put("uvTorch", input.uvTorch);
|
|
339
|
+
result.put("seriesProcessMode", input.seriesProcessMode);
|
|
340
|
+
result.put("name", input.name);
|
|
341
|
+
result.put("caption", input.caption);
|
|
342
|
+
result.put("description", input.description);
|
|
343
|
+
} catch (JSONException e) {
|
|
344
|
+
e.printStackTrace();
|
|
345
|
+
}
|
|
352
346
|
return result;
|
|
353
347
|
}
|
|
354
348
|
|
|
355
|
-
static
|
|
349
|
+
static JSONObject generateDocumentReaderScenarioFull(DocumentReaderScenarioFull input) {
|
|
356
350
|
JSONObject result = new JSONObject();
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
result.put("
|
|
368
|
-
|
|
369
|
-
result.put("
|
|
370
|
-
|
|
351
|
+
if (input == null) return result;
|
|
352
|
+
try {
|
|
353
|
+
result.put("uvTorch", input.uvTorch);
|
|
354
|
+
result.put("frameOrientation", input.frameOrientation);
|
|
355
|
+
result.put("faceExt", input.faceExt);
|
|
356
|
+
result.put("multiPageOff", input.multiPageOff);
|
|
357
|
+
result.put("seriesProcessMode", input.seriesProcessMode);
|
|
358
|
+
result.put("frameKWHLandscape", input.frameKWHLandscape);
|
|
359
|
+
result.put("frameKWHPortrait", input.frameKWHPortrait);
|
|
360
|
+
result.put("frameKWHDoublePageSpreadPortrait", input.frameKWHDoublePageSpreadPortrait);
|
|
361
|
+
result.put("frameKWHDoublePageSpreadLandscape", input.frameKWHDoublePageSpreadLandscape);
|
|
362
|
+
result.put("name", input.name);
|
|
363
|
+
result.put("caption", input.caption);
|
|
364
|
+
result.put("description", input.description);
|
|
365
|
+
result.put("manualCrop", input.manualCrop);
|
|
366
|
+
} catch (JSONException e) {
|
|
367
|
+
e.printStackTrace();
|
|
368
|
+
}
|
|
371
369
|
return result;
|
|
372
370
|
}
|
|
373
371
|
|
|
374
|
-
static
|
|
372
|
+
static JSONObject generateFaceMetaData(FaceMetaData input) {
|
|
375
373
|
JSONObject result = new JSONObject();
|
|
376
|
-
if (
|
|
377
|
-
|
|
374
|
+
if (input == null) return result;
|
|
375
|
+
try {
|
|
376
|
+
result.put("ID", input.ID);
|
|
377
|
+
result.put("rollAngle", input.rollAngle);
|
|
378
|
+
result.put("bounds", generateBounds(input.bounds));
|
|
379
|
+
} catch (JSONException e) {
|
|
380
|
+
e.printStackTrace();
|
|
381
|
+
}
|
|
378
382
|
return result;
|
|
379
383
|
}
|
|
380
384
|
|
|
381
|
-
static
|
|
385
|
+
static JSONObject generateBounds(Bounds input) {
|
|
382
386
|
JSONObject result = new JSONObject();
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
387
|
+
if (input == null) return result;
|
|
388
|
+
try {
|
|
389
|
+
result.put("x", input.x);
|
|
390
|
+
result.put("y", input.y);
|
|
391
|
+
result.put("width", input.width);
|
|
392
|
+
result.put("height", input.height);
|
|
393
|
+
} catch (JSONException e) {
|
|
394
|
+
e.printStackTrace();
|
|
395
|
+
}
|
|
386
396
|
return result;
|
|
387
397
|
}
|
|
388
398
|
|
|
389
|
-
static
|
|
399
|
+
static JSONObject generateRect(Rect input) {
|
|
390
400
|
JSONObject result = new JSONObject();
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
401
|
+
if (input == null) return result;
|
|
402
|
+
try {
|
|
403
|
+
result.put("bottom", input.bottom);
|
|
404
|
+
result.put("top", input.top);
|
|
405
|
+
result.put("left", input.left);
|
|
406
|
+
result.put("right", input.right);
|
|
407
|
+
} catch (JSONException e) {
|
|
408
|
+
e.printStackTrace();
|
|
409
|
+
}
|
|
396
410
|
return result;
|
|
397
411
|
}
|
|
398
412
|
|
|
399
|
-
static
|
|
413
|
+
static JSONObject generateDocReaderFieldRect(DocReaderFieldRect input) {
|
|
400
414
|
JSONObject result = new JSONObject();
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
result.put("aTQB", cardProperties.aTQB);
|
|
411
|
-
result.put("aTR", cardProperties.aTR);
|
|
412
|
-
result.put("baudrate1", cardProperties.baudrate1);
|
|
413
|
-
result.put("baudrate2", cardProperties.baudrate2);
|
|
414
|
-
result.put("uID", cardProperties.uID);
|
|
415
|
-
|
|
415
|
+
if (input == null) return result;
|
|
416
|
+
try {
|
|
417
|
+
result.put("bottom", input.bottom);
|
|
418
|
+
result.put("top", input.top);
|
|
419
|
+
result.put("left", input.left);
|
|
420
|
+
result.put("right", input.right);
|
|
421
|
+
} catch (JSONException e) {
|
|
422
|
+
e.printStackTrace();
|
|
423
|
+
}
|
|
416
424
|
return result;
|
|
417
425
|
}
|
|
418
426
|
|
|
419
|
-
static
|
|
427
|
+
static JSONObject generateDocumentReaderGraphicField(DocumentReaderGraphicField input, Context context) {
|
|
420
428
|
JSONObject result = new JSONObject();
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
429
|
+
if (input == null) return result;
|
|
430
|
+
try {
|
|
431
|
+
result.put("sourceType", input.sourceType);
|
|
432
|
+
result.put("fieldType", input.fieldType);
|
|
433
|
+
result.put("lightType", input.light);
|
|
434
|
+
result.put("pageIndex", input.pageIndex);
|
|
435
|
+
result.put("fieldName", eGraphicFieldType.getTranslation(context, input.fieldType));
|
|
436
|
+
result.put("lightName", eRPRM_Lights.getTranslation(context, input.light));
|
|
437
|
+
result.put("value", input.imageBase64());
|
|
438
|
+
result.put("fieldRect", generateDocReaderFieldRect(input.boundRect));
|
|
439
|
+
} catch (JSONException e) {
|
|
440
|
+
e.printStackTrace();
|
|
441
|
+
}
|
|
427
442
|
return result;
|
|
428
443
|
}
|
|
429
444
|
|
|
430
|
-
static
|
|
445
|
+
static JSONObject generateDocumentReaderGraphicResult(DocumentReaderGraphicResult input, Context context) {
|
|
431
446
|
JSONObject result = new JSONObject();
|
|
432
|
-
if (
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
447
|
+
if (input == null) return result;
|
|
448
|
+
try {
|
|
449
|
+
result.put("fields", generateList(input.fields, JSONConstructor::generateDocumentReaderGraphicField, context));
|
|
450
|
+
} catch (JSONException e) {
|
|
451
|
+
e.printStackTrace();
|
|
452
|
+
}
|
|
436
453
|
return result;
|
|
437
454
|
}
|
|
438
455
|
|
|
439
|
-
static
|
|
456
|
+
static JSONObject generateDocumentReaderValue(DocumentReaderValue input) {
|
|
440
457
|
JSONObject result = new JSONObject();
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
458
|
+
if (input == null) return result;
|
|
459
|
+
try {
|
|
460
|
+
result.put("pageIndex", input.pageIndex);
|
|
461
|
+
result.put("sourceType", input.sourceType);
|
|
462
|
+
result.put("validity", input.validity);
|
|
463
|
+
result.put("probability", input.probability);
|
|
464
|
+
result.put("value", input.value);
|
|
465
|
+
result.put("originalValue", input.originalValue);
|
|
466
|
+
result.put("boundRect", generateRect(input.boundRect));
|
|
467
|
+
result.put("comparison", generateMap(input.comparison));
|
|
468
|
+
} catch (JSONException e) {
|
|
469
|
+
e.printStackTrace();
|
|
470
|
+
}
|
|
444
471
|
return result;
|
|
445
472
|
}
|
|
446
473
|
|
|
447
|
-
static
|
|
474
|
+
static JSONObject generateDocumentReaderTextField(DocumentReaderTextField input, Context context) {
|
|
448
475
|
JSONObject result = new JSONObject();
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
result.put("subject", generateAuthority(certificateChain.subject, context));
|
|
462
|
-
if (certificateChain.issuer != null)
|
|
463
|
-
result.put("issuer", generateAuthority(certificateChain.issuer, context));
|
|
464
|
-
if (certificateChain.validity != null)
|
|
465
|
-
result.put("validity", generateValidity(certificateChain.validity));
|
|
466
|
-
|
|
476
|
+
if (input == null) return result;
|
|
477
|
+
try {
|
|
478
|
+
result.put("fieldType", input.fieldType);
|
|
479
|
+
result.put("lcid", input.lcid);
|
|
480
|
+
result.put("status", input.status);
|
|
481
|
+
result.put("lcidName", input.getLcidName(context));
|
|
482
|
+
result.put("fieldName", input.getFieldName(context));
|
|
483
|
+
result.put("value", generateDocumentReaderValue(input.value()));
|
|
484
|
+
result.put("values", generateList(input.values, JSONConstructor::generateDocumentReaderValue));
|
|
485
|
+
} catch (JSONException e) {
|
|
486
|
+
e.printStackTrace();
|
|
487
|
+
}
|
|
467
488
|
return result;
|
|
468
489
|
}
|
|
469
490
|
|
|
470
|
-
static
|
|
491
|
+
static JSONObject generateDocumentReaderTextResult(DocumentReaderTextResult input, Context context) {
|
|
471
492
|
JSONObject result = new JSONObject();
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
493
|
+
if (input == null) return result;
|
|
494
|
+
try {
|
|
495
|
+
result.put("status", input.status);
|
|
496
|
+
result.put("fields", generateList(input.fields, JSONConstructor::generateDocumentReaderTextField, context));
|
|
497
|
+
} catch (JSONException e) {
|
|
498
|
+
e.printStackTrace();
|
|
499
|
+
}
|
|
478
500
|
return result;
|
|
479
501
|
}
|
|
480
502
|
|
|
481
|
-
static
|
|
503
|
+
static JSONObject generateCoordinate(Coordinate input) {
|
|
482
504
|
JSONObject result = new JSONObject();
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
result.put("
|
|
487
|
-
|
|
505
|
+
if (input == null) return result;
|
|
506
|
+
try {
|
|
507
|
+
result.put("x", input.x);
|
|
508
|
+
result.put("y", input.y);
|
|
509
|
+
} catch (JSONException e) {
|
|
510
|
+
e.printStackTrace();
|
|
511
|
+
}
|
|
488
512
|
return result;
|
|
489
513
|
}
|
|
490
514
|
|
|
491
|
-
static
|
|
515
|
+
static JSONObject generateElementPosition(ElementPosition input) {
|
|
492
516
|
JSONObject result = new JSONObject();
|
|
493
|
-
if (
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
result.put("
|
|
497
|
-
|
|
517
|
+
if (input == null) return result;
|
|
518
|
+
try {
|
|
519
|
+
result.put("docFormat", input.docFormat);
|
|
520
|
+
result.put("width", input.width);
|
|
521
|
+
result.put("height", input.height);
|
|
522
|
+
result.put("dpi", input.dpi);
|
|
523
|
+
result.put("pageIndex", input.pageIndex);
|
|
524
|
+
result.put("inverse", input.inverse);
|
|
525
|
+
result.put("perspectiveTr", input.perspectiveTr);
|
|
526
|
+
result.put("objArea", input.objArea);
|
|
527
|
+
result.put("objIntAngleDev", input.objIntAngleDev);
|
|
528
|
+
result.put("resultStatus", input.resultStatus);
|
|
529
|
+
result.put("angle", input.angle);
|
|
530
|
+
result.put("center", generateCoordinate(input.center));
|
|
531
|
+
result.put("leftTop", generateCoordinate(input.leftTop));
|
|
532
|
+
result.put("leftBottom", generateCoordinate(input.leftBottom));
|
|
533
|
+
result.put("rightTop", generateCoordinate(input.rightTop));
|
|
534
|
+
result.put("rightBottom", generateCoordinate(input.rightBottom));
|
|
535
|
+
} catch (JSONException e) {
|
|
536
|
+
e.printStackTrace();
|
|
537
|
+
}
|
|
498
538
|
return result;
|
|
499
539
|
}
|
|
500
540
|
|
|
501
|
-
static
|
|
541
|
+
static JSONObject generateImageQuality(ImageQuality input) {
|
|
502
542
|
JSONObject result = new JSONObject();
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
if (signerInfo.signature != null)
|
|
512
|
-
result.put("signature", generateValue(signerInfo.signature));
|
|
513
|
-
if (signerInfo.serialNumber != null)
|
|
514
|
-
result.put("serialNumber", generateValue(signerInfo.serialNumber));
|
|
515
|
-
if (signerInfo.subjectKeyIdentifier != null)
|
|
516
|
-
result.put("subjectKeyIdentifier", generateValue(signerInfo.subjectKeyIdentifier));
|
|
517
|
-
if (signerInfo.issuer != null)
|
|
518
|
-
result.put("issuer", generateAuthority(signerInfo.issuer, context));
|
|
519
|
-
|
|
543
|
+
if (input == null) return result;
|
|
544
|
+
try {
|
|
545
|
+
result.put("featureType", input.featureType);
|
|
546
|
+
result.put("result", input.result);
|
|
547
|
+
result.put("type", input.type);
|
|
548
|
+
} catch (JSONException e) {
|
|
549
|
+
e.printStackTrace();
|
|
550
|
+
}
|
|
520
551
|
return result;
|
|
521
552
|
}
|
|
522
553
|
|
|
523
|
-
static
|
|
554
|
+
static JSONObject generateImageQualityGroup(ImageQualityGroup input) {
|
|
524
555
|
JSONObject result = new JSONObject();
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
556
|
+
if (input == null) return result;
|
|
557
|
+
try {
|
|
558
|
+
result.put("count", input.count);
|
|
559
|
+
result.put("result", input.result);
|
|
560
|
+
result.put("imageQualityList", generateList(input.imageQualityList, JSONConstructor::generateImageQuality));
|
|
561
|
+
result.put("pageIndex", input.pageIndex);
|
|
562
|
+
} catch (JSONException e) {
|
|
563
|
+
e.printStackTrace();
|
|
564
|
+
}
|
|
528
565
|
return result;
|
|
529
566
|
}
|
|
530
567
|
|
|
531
|
-
static
|
|
568
|
+
static JSONObject generateDocumentReaderDocumentType(DocumentReaderDocumentType input) {
|
|
532
569
|
JSONObject result = new JSONObject();
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
result.put("
|
|
541
|
-
|
|
570
|
+
if (input == null) return result;
|
|
571
|
+
try {
|
|
572
|
+
result.put("pageIndex", input.pageIndex);
|
|
573
|
+
result.put("documentID", input.documentID);
|
|
574
|
+
result.put("dType", input.dType);
|
|
575
|
+
result.put("dFormat", input.dFormat);
|
|
576
|
+
result.put("dMRZ", input.dMRZ);
|
|
577
|
+
result.put("name", input.name);
|
|
578
|
+
result.put("ICAOCode", input.ICAOCode);
|
|
579
|
+
result.put("dDescription", input.dDescription);
|
|
580
|
+
result.put("dYear", input.dYear);
|
|
581
|
+
result.put("dCountryName", input.dCountryName);
|
|
582
|
+
result.put("FDSID", generateIntArray(input.FDSID));
|
|
583
|
+
} catch (JSONException e) {
|
|
584
|
+
e.printStackTrace();
|
|
585
|
+
}
|
|
542
586
|
return result;
|
|
543
587
|
}
|
|
544
588
|
|
|
545
|
-
static
|
|
589
|
+
static JSONObject generateDocumentReaderNotification(DocumentReaderNotification input) {
|
|
546
590
|
JSONObject result = new JSONObject();
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
result.put("boundRect", generateRect(documentReaderValue.boundRect));
|
|
556
|
-
|
|
591
|
+
if (input == null) return result;
|
|
592
|
+
try {
|
|
593
|
+
result.put("code", input.code & 0xFFFF0000);
|
|
594
|
+
result.put("number", input.code & 0x0000FFFF);
|
|
595
|
+
result.put("value", input.value);
|
|
596
|
+
} catch (JSONException e) {
|
|
597
|
+
e.printStackTrace();
|
|
598
|
+
}
|
|
557
599
|
return result;
|
|
558
600
|
}
|
|
559
601
|
|
|
560
|
-
static
|
|
602
|
+
static JSONObject generateAccessControlProcedureType(AccessControlProcedureType input) {
|
|
561
603
|
JSONObject result = new JSONObject();
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
604
|
+
if (input == null) return result;
|
|
605
|
+
try {
|
|
606
|
+
result.put("activeOptionIdx", input.activeOptionIdx);
|
|
607
|
+
result.put("type", input.type);
|
|
608
|
+
result.put("status", input.status);
|
|
609
|
+
result.put("notifications", generateList(input.notifications));
|
|
610
|
+
} catch (JSONException e) {
|
|
611
|
+
e.printStackTrace();
|
|
612
|
+
}
|
|
567
613
|
return result;
|
|
568
614
|
}
|
|
569
615
|
|
|
570
|
-
static
|
|
616
|
+
static JSONObject generateFileData(FileData input) {
|
|
571
617
|
JSONObject result = new JSONObject();
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
618
|
+
if (input == null) return result;
|
|
619
|
+
try {
|
|
620
|
+
result.put("length", input.length);
|
|
621
|
+
result.put("type", input.type);
|
|
622
|
+
result.put("status", input.status);
|
|
623
|
+
result.put("data", input.data);
|
|
624
|
+
} catch (JSONException e) {
|
|
625
|
+
e.printStackTrace();
|
|
626
|
+
}
|
|
575
627
|
return result;
|
|
576
628
|
}
|
|
577
629
|
|
|
578
|
-
static
|
|
630
|
+
static JSONObject generateCertificateData(CertificateData input) {
|
|
579
631
|
JSONObject result = new JSONObject();
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
632
|
+
if (input == null) return result;
|
|
633
|
+
try {
|
|
634
|
+
result.put("length", input.length);
|
|
635
|
+
result.put("data", input.data);
|
|
636
|
+
} catch (JSONException e) {
|
|
637
|
+
e.printStackTrace();
|
|
638
|
+
}
|
|
583
639
|
return result;
|
|
584
640
|
}
|
|
585
641
|
|
|
586
|
-
static
|
|
642
|
+
static JSONObject generateSecurityObjectCertificates(SecurityObjectCertificates input) {
|
|
587
643
|
JSONObject result = new JSONObject();
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
644
|
+
if (input == null) return result;
|
|
645
|
+
try {
|
|
646
|
+
result.put("securityObject", generateCertificateData(input.securityObject));
|
|
647
|
+
} catch (JSONException e) {
|
|
648
|
+
e.printStackTrace();
|
|
649
|
+
}
|
|
594
650
|
return result;
|
|
595
651
|
}
|
|
596
652
|
|
|
597
|
-
static
|
|
653
|
+
static JSONObject generateFile(File input) {
|
|
598
654
|
JSONObject result = new JSONObject();
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
655
|
+
if (input == null) return result;
|
|
656
|
+
try {
|
|
657
|
+
result.put("readingTime", input.readingTime);
|
|
658
|
+
result.put("type", input.type);
|
|
659
|
+
result.put("pAStatus", input.pAStatus);
|
|
660
|
+
result.put("readingStatus", input.readingStatus);
|
|
661
|
+
result.put("fileID", input.fileID);
|
|
662
|
+
result.put("fileData", generateFileData(input.fileData));
|
|
663
|
+
result.put("certificates", generateSecurityObjectCertificates(input.certificates));
|
|
664
|
+
result.put("docFieldsText", generateList(input.docFieldsText));
|
|
665
|
+
result.put("docFieldsGraphics", generateList(input.docFieldsGraphics));
|
|
666
|
+
result.put("docFieldsOriginals", generateList(input.docFieldsOriginals));
|
|
667
|
+
result.put("notifications", generateList(input.notifications));
|
|
668
|
+
} catch (JSONException e) {
|
|
669
|
+
e.printStackTrace();
|
|
670
|
+
}
|
|
605
671
|
return result;
|
|
606
672
|
}
|
|
607
673
|
|
|
608
|
-
static
|
|
609
|
-
|
|
674
|
+
static JSONObject generateApplication(Application input) {
|
|
675
|
+
JSONObject result = new JSONObject();
|
|
676
|
+
if (input == null) return result;
|
|
677
|
+
try {
|
|
678
|
+
result.put("type", input.type);
|
|
679
|
+
result.put("status", input.status);
|
|
680
|
+
result.put("applicationID", input.applicationID);
|
|
681
|
+
result.put("dataHashAlgorithm", input.dataHashAlgorithm);
|
|
682
|
+
result.put("unicodeVersion", input.unicodeVersion);
|
|
683
|
+
result.put("version", input.version);
|
|
684
|
+
result.put("files", generateList(input.files, JSONConstructor::generateFile));
|
|
685
|
+
} catch (JSONException e) {
|
|
686
|
+
e.printStackTrace();
|
|
687
|
+
}
|
|
688
|
+
return result;
|
|
610
689
|
}
|
|
611
690
|
|
|
612
|
-
static
|
|
691
|
+
static JSONObject generateValue(Value input) {
|
|
613
692
|
JSONObject result = new JSONObject();
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
result.put("
|
|
619
|
-
|
|
620
|
-
result.put("
|
|
621
|
-
|
|
693
|
+
if (input == null) return result;
|
|
694
|
+
try {
|
|
695
|
+
result.put("length", input.length);
|
|
696
|
+
result.put("type", input.type);
|
|
697
|
+
result.put("status", input.status);
|
|
698
|
+
result.put("data", input.data);
|
|
699
|
+
result.put("format", input.format);
|
|
700
|
+
} catch (JSONException e) {
|
|
701
|
+
e.printStackTrace();
|
|
702
|
+
}
|
|
622
703
|
return result;
|
|
623
704
|
}
|
|
624
705
|
|
|
625
|
-
static
|
|
706
|
+
static JSONObject generateAttribute(Attribute input) {
|
|
626
707
|
JSONObject result = new JSONObject();
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
708
|
+
if (input == null) return result;
|
|
709
|
+
try {
|
|
710
|
+
result.put("type", input.type);
|
|
711
|
+
result.put("value", generateValue(input.value));
|
|
712
|
+
} catch (JSONException e) {
|
|
713
|
+
e.printStackTrace();
|
|
714
|
+
}
|
|
631
715
|
return result;
|
|
632
716
|
}
|
|
633
717
|
|
|
634
|
-
static JSONObject
|
|
718
|
+
static JSONObject generateAuthority(Authority input) {
|
|
635
719
|
JSONObject result = new JSONObject();
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
720
|
+
if (input == null) return result;
|
|
721
|
+
try {
|
|
722
|
+
result.put("data", input.data);
|
|
723
|
+
result.put("friendlyName", generateValue(input.friendlyName));
|
|
724
|
+
result.put("attributes", generateList(input.attributes, JSONConstructor::generateAttribute));
|
|
725
|
+
} catch (JSONException e) {
|
|
726
|
+
e.printStackTrace();
|
|
727
|
+
}
|
|
640
728
|
return result;
|
|
641
729
|
}
|
|
642
730
|
|
|
643
|
-
static
|
|
731
|
+
static JSONObject generateExtension(Extension input) {
|
|
644
732
|
JSONObject result = new JSONObject();
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
733
|
+
if (input == null) return result;
|
|
734
|
+
try {
|
|
735
|
+
result.put("data", input.data);
|
|
736
|
+
result.put("type", input.type);
|
|
737
|
+
} catch (JSONException e) {
|
|
738
|
+
e.printStackTrace();
|
|
739
|
+
}
|
|
650
740
|
return result;
|
|
651
741
|
}
|
|
652
742
|
|
|
653
|
-
static
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
743
|
+
static JSONObject generateValidity(Validity input) {
|
|
744
|
+
JSONObject result = new JSONObject();
|
|
745
|
+
if (input == null) return result;
|
|
746
|
+
try {
|
|
747
|
+
result.put("notAfter", generateValue(input.notAfter));
|
|
748
|
+
result.put("notBefore", generateValue(input.notBefore));
|
|
749
|
+
} catch (JSONException e) {
|
|
750
|
+
e.printStackTrace();
|
|
751
|
+
}
|
|
658
752
|
return result;
|
|
659
753
|
}
|
|
660
754
|
|
|
661
|
-
static
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
755
|
+
static JSONObject generateCertificateChain(CertificateChain input) {
|
|
756
|
+
JSONObject result = new JSONObject();
|
|
757
|
+
if (input == null) return result;
|
|
758
|
+
try {
|
|
759
|
+
result.put("origin", input.origin);
|
|
760
|
+
result.put("type", input.type);
|
|
761
|
+
result.put("version", input.version);
|
|
762
|
+
result.put("paStatus", input.paStatus);
|
|
763
|
+
result.put("serialNumber", input.serialNumber);
|
|
764
|
+
result.put("signatureAlgorithm", input.signatureAlgorithm);
|
|
765
|
+
result.put("subjectPKAlgorithm", input.subjectPKAlgorithm);
|
|
766
|
+
result.put("fileName", generateValue(input.fileName));
|
|
767
|
+
result.put("validity", generateValidity(input.validity));
|
|
768
|
+
result.put("issuer", generateAuthority(input.issuer));
|
|
769
|
+
result.put("subject", generateAuthority(input.subject));
|
|
770
|
+
result.put("notifications", generateList(input.notifications));
|
|
771
|
+
result.put("extensions", generateList(input.extensions, JSONConstructor::generateExtension));
|
|
772
|
+
} catch (JSONException e) {
|
|
773
|
+
e.printStackTrace();
|
|
774
|
+
}
|
|
666
775
|
return result;
|
|
667
776
|
}
|
|
668
777
|
|
|
669
|
-
static JSONObject
|
|
778
|
+
static JSONObject generateSignerInfo(SignerInfo input) {
|
|
670
779
|
JSONObject result = new JSONObject();
|
|
780
|
+
if (input == null) return result;
|
|
671
781
|
try {
|
|
672
|
-
result.put("
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
break;
|
|
687
|
-
}
|
|
688
|
-
result.put("error", generateThrowable(error, context));
|
|
689
|
-
} catch (JSONException ignored) {
|
|
782
|
+
result.put("version", input.version);
|
|
783
|
+
result.put("paStatus", input.paStatus);
|
|
784
|
+
result.put("dataToHash", input.dataToHash);
|
|
785
|
+
result.put("digestAlgorithm", input.digestAlgorithm);
|
|
786
|
+
result.put("signatureAlgorithm", input.signatureAlgorithm);
|
|
787
|
+
result.put("serialNumber", generateValue(input.serialNumber));
|
|
788
|
+
result.put("signature", generateValue(input.signature));
|
|
789
|
+
result.put("subjectKeyIdentifier", generateValue(input.subjectKeyIdentifier));
|
|
790
|
+
result.put("issuer", generateAuthority(input.issuer));
|
|
791
|
+
result.put("notifications", generateList(input.notifications));
|
|
792
|
+
result.put("signedAttributes", generateList(input.signedAttributes, JSONConstructor::generateExtension));
|
|
793
|
+
result.put("certificateChain", generateList(input.certificateChain, JSONConstructor::generateCertificateChain));
|
|
794
|
+
} catch (JSONException e) {
|
|
795
|
+
e.printStackTrace();
|
|
690
796
|
}
|
|
691
|
-
|
|
692
797
|
return result;
|
|
693
798
|
}
|
|
694
799
|
|
|
695
|
-
static JSONObject
|
|
800
|
+
static JSONObject generateSecurityObject(SecurityObject input) {
|
|
696
801
|
JSONObject result = new JSONObject();
|
|
697
|
-
if (
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
802
|
+
if (input == null) return result;
|
|
803
|
+
try {
|
|
804
|
+
result.put("fileReference", input.fileReference);
|
|
805
|
+
result.put("version", input.version);
|
|
806
|
+
result.put("objectType", input.objectType);
|
|
807
|
+
result.put("notifications", generateList(input.notifications));
|
|
808
|
+
result.put("signerInfos", generateList(input.signerInfos, JSONConstructor::generateSignerInfo));
|
|
809
|
+
} catch (JSONException e) {
|
|
810
|
+
e.printStackTrace();
|
|
811
|
+
}
|
|
704
812
|
return result;
|
|
705
813
|
}
|
|
706
814
|
|
|
707
|
-
static JSONObject
|
|
815
|
+
static JSONObject generateCardProperties(CardProperties input) {
|
|
708
816
|
JSONObject result = new JSONObject();
|
|
709
|
-
if (
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
817
|
+
if (input == null) return result;
|
|
818
|
+
try {
|
|
819
|
+
result.put("aTQA", input.aTQA);
|
|
820
|
+
result.put("bitRateR", input.bitRateR);
|
|
821
|
+
result.put("bitRateS", input.bitRateS);
|
|
822
|
+
result.put("chipTypeA", input.chipTypeA);
|
|
823
|
+
result.put("mifareMemory", input.mifareMemory);
|
|
824
|
+
result.put("rfidType", input.rfidType);
|
|
825
|
+
result.put("sAK", input.sAK);
|
|
826
|
+
result.put("support4", input.support4);
|
|
827
|
+
result.put("supportMifare", input.supportMifare);
|
|
828
|
+
result.put("aTQB", input.aTQB);
|
|
829
|
+
result.put("aTR", input.aTR);
|
|
830
|
+
result.put("baudrate1", input.baudrate1);
|
|
831
|
+
result.put("baudrate2", input.baudrate2);
|
|
832
|
+
result.put("uID", input.uID);
|
|
833
|
+
} catch (JSONException e) {
|
|
834
|
+
e.printStackTrace();
|
|
835
|
+
}
|
|
718
836
|
return result;
|
|
719
837
|
}
|
|
720
838
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
result
|
|
839
|
+
static JSONObject generateRFIDSessionData(RFIDSessionData input) {
|
|
840
|
+
JSONObject result = new JSONObject();
|
|
841
|
+
if (input == null) return result;
|
|
842
|
+
try {
|
|
843
|
+
result.put("totalBytesReceived", input.totalBytesReceived);
|
|
844
|
+
result.put("totalBytesSent", input.totalBytesSent);
|
|
845
|
+
result.put("status", input.status);
|
|
846
|
+
result.put("extLeSupport", input.extLeSupport);
|
|
847
|
+
result.put("processTime", input.processTime);
|
|
848
|
+
result.put("cardProperties", generateCardProperties(input.cardProperties));
|
|
849
|
+
result.put("sessionDataStatus", generateRFIDSessionDataStatus(input.sessionDataStatus));
|
|
850
|
+
result.put("accessControls", generateList(input.accessControls, JSONConstructor::generateAccessControlProcedureType));
|
|
851
|
+
result.put("applications", generateList(input.applications, JSONConstructor::generateApplication));
|
|
852
|
+
result.put("securityObjects", generateList(input.securityObjects, JSONConstructor::generateSecurityObject));
|
|
853
|
+
} catch (JSONException e) {
|
|
854
|
+
e.printStackTrace();
|
|
855
|
+
}
|
|
731
856
|
return result;
|
|
732
857
|
}
|
|
733
858
|
|
|
734
|
-
static
|
|
735
|
-
|
|
736
|
-
|
|
859
|
+
static JSONObject generateDocumentReaderAuthenticityCheck(DocumentReaderAuthenticityCheck input, Context context) {
|
|
860
|
+
JSONObject result = new JSONObject();
|
|
861
|
+
if (input == null) return result;
|
|
862
|
+
try {
|
|
863
|
+
result.put("type", input.type);
|
|
864
|
+
result.put("status", input.getStatus());
|
|
865
|
+
result.put("typeName", input.getTypeName(context));
|
|
866
|
+
result.put("pageIndex", input.pageIndex);
|
|
867
|
+
result.put("elements", generateList(input.elements, JSONConstructor::generateDocumentReaderAuthenticityElement, context));
|
|
868
|
+
} catch (JSONException e) {
|
|
869
|
+
e.printStackTrace();
|
|
870
|
+
}
|
|
871
|
+
return result;
|
|
737
872
|
}
|
|
738
873
|
|
|
739
|
-
static
|
|
740
|
-
|
|
874
|
+
static JSONObject generatePDF417Info(PDF417Info input) {
|
|
875
|
+
JSONObject result = new JSONObject();
|
|
876
|
+
if (input == null) return result;
|
|
877
|
+
try {
|
|
878
|
+
result.put("errorLevel", input.errorLevel);
|
|
879
|
+
result.put("columns", input.columns);
|
|
880
|
+
result.put("rows", input.rows);
|
|
881
|
+
} catch (JSONException e) {
|
|
882
|
+
e.printStackTrace();
|
|
883
|
+
}
|
|
884
|
+
return result;
|
|
885
|
+
}
|
|
741
886
|
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
887
|
+
static JSONObject generateRFIDSessionDataStatus(RFIDSessionDataStatus input) {
|
|
888
|
+
JSONObject result = new JSONObject();
|
|
889
|
+
if (input == null) return result;
|
|
890
|
+
try {
|
|
891
|
+
result.put("AA", input.AA);
|
|
892
|
+
result.put("BAC", input.BAC);
|
|
893
|
+
result.put("CA", input.CA);
|
|
894
|
+
result.put("PA", input.PA);
|
|
895
|
+
result.put("PACE", input.PACE);
|
|
896
|
+
result.put("TA", input.TA);
|
|
897
|
+
result.put("overallStatus", input.overallStatus);
|
|
898
|
+
} catch (JSONException e) {
|
|
899
|
+
e.printStackTrace();
|
|
747
900
|
}
|
|
901
|
+
return result;
|
|
902
|
+
}
|
|
748
903
|
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
904
|
+
static JSONObject generateDocumentReaderBarcodeResult(DocumentReaderBarcodeResult input) {
|
|
905
|
+
JSONObject result = new JSONObject();
|
|
906
|
+
if (input == null) return result;
|
|
907
|
+
try {
|
|
908
|
+
result.put("fields", generateList(input.fields, JSONConstructor::generateDocumentReaderBarcodeField));
|
|
909
|
+
} catch (JSONException e) {
|
|
910
|
+
e.printStackTrace();
|
|
753
911
|
}
|
|
912
|
+
return result;
|
|
913
|
+
}
|
|
754
914
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
915
|
+
static JSONObject generateDocumentReaderBarcodeField(DocumentReaderBarcodeField input) {
|
|
916
|
+
JSONObject result = new JSONObject();
|
|
917
|
+
if (input == null) return result;
|
|
918
|
+
try {
|
|
919
|
+
result.put("barcodeType", input.barcodeType);
|
|
920
|
+
result.put("status", input.status);
|
|
921
|
+
result.put("pageIndex", input.pageIndex);
|
|
922
|
+
result.put("pdf417Info", generatePDF417Info(input.pdf417Info));
|
|
923
|
+
result.put("data", generateByteArray(input.data));
|
|
924
|
+
} catch (JSONException e) {
|
|
925
|
+
e.printStackTrace();
|
|
926
|
+
}
|
|
927
|
+
return result;
|
|
759
928
|
}
|
|
760
929
|
|
|
761
|
-
static
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
930
|
+
static JSONObject generateDocumentReaderAuthenticityResult(DocumentReaderAuthenticityResult input, Context context) {
|
|
931
|
+
JSONObject result = new JSONObject();
|
|
932
|
+
if (input == null) return result;
|
|
933
|
+
try {
|
|
934
|
+
result.put("status", input.getStatus());
|
|
935
|
+
result.put("checks", generateList(input.checks, JSONConstructor::generateDocumentReaderAuthenticityCheck, context));
|
|
936
|
+
} catch (JSONException e) {
|
|
937
|
+
e.printStackTrace();
|
|
938
|
+
}
|
|
939
|
+
return result;
|
|
765
940
|
}
|
|
766
941
|
|
|
767
|
-
static
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
942
|
+
static JSONObject generateDocumentReaderAuthenticityElement(DocumentReaderAuthenticityElement input, Context context) {
|
|
943
|
+
JSONObject result = new JSONObject();
|
|
944
|
+
if (input == null) return result;
|
|
945
|
+
try {
|
|
946
|
+
result.put("status", input.status);
|
|
947
|
+
result.put("elementType", input.elementType);
|
|
948
|
+
result.put("elementDiagnose", input.elementDiagnose);
|
|
949
|
+
result.put("elementTypeName", input.getElementTypeName(context));
|
|
950
|
+
result.put("elementDiagnoseName", input.getElementDiagnoseName(context));
|
|
951
|
+
} catch (JSONException e) {
|
|
952
|
+
e.printStackTrace();
|
|
953
|
+
}
|
|
954
|
+
return result;
|
|
955
|
+
}
|
|
771
956
|
|
|
957
|
+
static JSONObject generateDocumentReaderException(DocumentReaderException input) {
|
|
958
|
+
JSONObject result = new JSONObject();
|
|
959
|
+
if (input == null) return result;
|
|
960
|
+
try {
|
|
961
|
+
result.put("errorCode", input.getErrorCode());
|
|
962
|
+
result.put("localizedMessage", input.getLocalizedMessage());
|
|
963
|
+
result.put("message", input.getMessage());
|
|
964
|
+
result.put("string", input.toString());
|
|
965
|
+
result.put("stackTrace", generateArray(input.getStackTrace(), JSONConstructor::generateStackTraceElement));
|
|
966
|
+
} catch (JSONException e) {
|
|
967
|
+
e.printStackTrace();
|
|
968
|
+
}
|
|
772
969
|
return result;
|
|
773
970
|
}
|
|
774
971
|
|
|
775
|
-
static
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
972
|
+
static JSONObject generateThrowable(Throwable input) {
|
|
973
|
+
JSONObject result = new JSONObject();
|
|
974
|
+
if (input == null) return result;
|
|
975
|
+
try {
|
|
976
|
+
result.put("localizedMessage", input.getLocalizedMessage());
|
|
977
|
+
result.put("message", input.getMessage());
|
|
978
|
+
result.put("string", input.toString());
|
|
979
|
+
result.put("stackTrace", generateArray(input.getStackTrace(), JSONConstructor::generateStackTraceElement));
|
|
980
|
+
} catch (JSONException e) {
|
|
981
|
+
e.printStackTrace();
|
|
982
|
+
}
|
|
983
|
+
return result;
|
|
984
|
+
}
|
|
779
985
|
|
|
986
|
+
static JSONObject generateStackTraceElement(StackTraceElement input) {
|
|
987
|
+
JSONObject result = new JSONObject();
|
|
988
|
+
if (input == null) return result;
|
|
989
|
+
try {
|
|
990
|
+
result.put("lineNumber", input.getLineNumber());
|
|
991
|
+
result.put("isNativeMethod", input.isNativeMethod());
|
|
992
|
+
result.put("className", input.getClassName());
|
|
993
|
+
result.put("fileName", input.getFileName());
|
|
994
|
+
result.put("methodName", input.getMethodName());
|
|
995
|
+
result.put("string", input.toString());
|
|
996
|
+
} catch (JSONException e) {
|
|
997
|
+
e.printStackTrace();
|
|
998
|
+
}
|
|
780
999
|
return result;
|
|
781
1000
|
}
|
|
782
1001
|
|
|
783
|
-
static
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
1002
|
+
static JSONObject generatePAResourcesIssuer(PAResourcesIssuer input) {
|
|
1003
|
+
JSONObject result = new JSONObject();
|
|
1004
|
+
if (input == null) return result;
|
|
1005
|
+
try {
|
|
1006
|
+
result.put("data", generateByteArray(input.data));
|
|
1007
|
+
result.put("friendlyName", input.friendlyName);
|
|
1008
|
+
result.put("attributes", generateArray(input.attributes, JSONConstructor::generatePAAttribute));
|
|
1009
|
+
} catch (JSONException e) {
|
|
1010
|
+
e.printStackTrace();
|
|
1011
|
+
}
|
|
1012
|
+
return result;
|
|
1013
|
+
}
|
|
787
1014
|
|
|
1015
|
+
static JSONObject generatePAAttribute(PAAttribute input) {
|
|
1016
|
+
JSONObject result = new JSONObject();
|
|
1017
|
+
if (input == null) return result;
|
|
1018
|
+
try {
|
|
1019
|
+
result.put("type", input.type);
|
|
1020
|
+
result.put("value", input.value);
|
|
1021
|
+
} catch (JSONException e) {
|
|
1022
|
+
e.printStackTrace();
|
|
1023
|
+
}
|
|
788
1024
|
return result;
|
|
789
1025
|
}
|
|
790
1026
|
|
|
791
|
-
static
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
1027
|
+
static JSONObject generateTAChallenge(TAChallenge input) {
|
|
1028
|
+
JSONObject result = new JSONObject();
|
|
1029
|
+
if (input == null) return result;
|
|
1030
|
+
try {
|
|
1031
|
+
result.put("data", generateByteArray(input.data));
|
|
1032
|
+
result.put("auxPCD", input.auxPCD);
|
|
1033
|
+
result.put("challengePICC", input.challengePICC);
|
|
1034
|
+
result.put("hashPK", input.hashPK);
|
|
1035
|
+
result.put("idPICC", input.idPICC);
|
|
1036
|
+
} catch (JSONException e) {
|
|
1037
|
+
e.printStackTrace();
|
|
1038
|
+
}
|
|
1039
|
+
return result;
|
|
1040
|
+
}
|
|
795
1041
|
|
|
1042
|
+
static JSONObject generateDocumentReaderResults(DocumentReaderResults input, Context context) {
|
|
1043
|
+
JSONObject result = new JSONObject();
|
|
1044
|
+
if (input == null) return result;
|
|
1045
|
+
try {
|
|
1046
|
+
result.put("chipPage", input.chipPage);
|
|
1047
|
+
result.put("overallResult", input.getOverallResult());
|
|
1048
|
+
result.put("processingFinishedStatus", input.processingFinishedStatus);
|
|
1049
|
+
result.put("elapsedTime", input.elapsedTime);
|
|
1050
|
+
result.put("elapsedTimeRFID", input.elapsedTimeRFID);
|
|
1051
|
+
result.put("morePagesAvailable", input.morePagesAvailable);
|
|
1052
|
+
result.put("rfidResult", input.rfidResult);
|
|
1053
|
+
result.put("highResolution", input.highResolution);
|
|
1054
|
+
result.put("graphicResult", generateDocumentReaderGraphicResult(input.graphicResult, context));
|
|
1055
|
+
result.put("textResult", generateDocumentReaderTextResult(input.textResult, context));
|
|
1056
|
+
result.put("documentPosition", generateList(input.documentPosition, JSONConstructor::generateElementPosition));
|
|
1057
|
+
result.put("barcodePosition", generateList(input.barcodePosition, JSONConstructor::generateElementPosition));
|
|
1058
|
+
result.put("mrzPosition", generateList(input.mrzPosition, JSONConstructor::generateElementPosition));
|
|
1059
|
+
result.put("imageQuality", generateList(input.imageQuality, JSONConstructor::generateImageQualityGroup));
|
|
1060
|
+
result.put("rawResult", input.rawResult);
|
|
1061
|
+
result.put("documentReaderNotification", generateDocumentReaderNotification(input.documentReaderNotification));
|
|
1062
|
+
result.put("rfidSessionData", generateRFIDSessionData(input.rfidSessionData));
|
|
1063
|
+
result.put("authenticityResult", generateDocumentReaderAuthenticityResult(input.authenticityResult, context));
|
|
1064
|
+
result.put("barcodeResult", generateDocumentReaderBarcodeResult(input.barcodeResult));
|
|
1065
|
+
result.put("documentType", generateList(input.documentType, JSONConstructor::generateDocumentReaderDocumentType));
|
|
1066
|
+
} catch (JSONException e) {
|
|
1067
|
+
e.printStackTrace();
|
|
1068
|
+
}
|
|
796
1069
|
return result;
|
|
797
1070
|
}
|
|
798
1071
|
|
|
799
|
-
|
|
800
|
-
FaceMetaData result = new FaceMetaData();
|
|
801
|
-
result.ID = object.getInt("ID");
|
|
802
|
-
result.rollAngle = object.getInt("rollAngle");
|
|
803
|
-
result.bounds = boundsFromJson(object.getJSONObject("bounds"));
|
|
1072
|
+
// From JSON
|
|
804
1073
|
|
|
805
|
-
|
|
1074
|
+
static DocumentReaderScenario DocumentReaderScenarioFromJSON(JSONObject input) {
|
|
1075
|
+
try {
|
|
1076
|
+
DocumentReaderScenario result = new DocumentReaderScenario();
|
|
1077
|
+
if (input.has("uvTorch"))
|
|
1078
|
+
result.uvTorch = input.getBoolean("uvTorch");
|
|
1079
|
+
if (input.has("seriesProcessMode"))
|
|
1080
|
+
result.seriesProcessMode = input.getBoolean("seriesProcessMode");
|
|
1081
|
+
if (input.has("name"))
|
|
1082
|
+
result.name = input.getString("name");
|
|
1083
|
+
if (input.has("caption"))
|
|
1084
|
+
result.caption = input.getString("caption");
|
|
1085
|
+
if (input.has("description"))
|
|
1086
|
+
result.description = input.getString("description");
|
|
1087
|
+
return result;
|
|
1088
|
+
} catch (JSONException e) {
|
|
1089
|
+
e.printStackTrace();
|
|
1090
|
+
}
|
|
1091
|
+
return null;
|
|
806
1092
|
}
|
|
807
1093
|
|
|
808
|
-
static
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
1094
|
+
static DocumentReaderScenarioFull DocumentReaderScenarioFullFromJSON(JSONObject input) {
|
|
1095
|
+
try {
|
|
1096
|
+
DocumentReaderScenarioFull result = new DocumentReaderScenarioFull();
|
|
1097
|
+
if (input.has("uvTorch"))
|
|
1098
|
+
result.uvTorch = input.getBoolean("uvTorch");
|
|
1099
|
+
if (input.has("frameOrientation"))
|
|
1100
|
+
result.frameOrientation = input.getInt("frameOrientation");
|
|
1101
|
+
if (input.has("faceExt"))
|
|
1102
|
+
result.faceExt = input.getBoolean("faceExt");
|
|
1103
|
+
if (input.has("multiPageOff"))
|
|
1104
|
+
result.multiPageOff = input.getInt("multiPageOff");
|
|
1105
|
+
if (input.has("seriesProcessMode"))
|
|
1106
|
+
result.seriesProcessMode = input.getBoolean("seriesProcessMode");
|
|
1107
|
+
if (input.has("frameKWHLandscape"))
|
|
1108
|
+
result.frameKWHLandscape = input.getDouble("frameKWHLandscape");
|
|
1109
|
+
if (input.has("frameKWHPortrait"))
|
|
1110
|
+
result.frameKWHPortrait = input.getDouble("frameKWHPortrait");
|
|
1111
|
+
if (input.has("frameKWHDoublePageSpreadPortrait"))
|
|
1112
|
+
result.frameKWHDoublePageSpreadPortrait = input.getDouble("frameKWHDoublePageSpreadPortrait");
|
|
1113
|
+
if (input.has("frameKWHDoublePageSpreadLandscape"))
|
|
1114
|
+
result.frameKWHDoublePageSpreadLandscape = input.getDouble("frameKWHDoublePageSpreadLandscape");
|
|
1115
|
+
if (input.has("name"))
|
|
1116
|
+
result.name = input.getString("name");
|
|
1117
|
+
if (input.has("caption"))
|
|
1118
|
+
result.caption = input.getString("caption");
|
|
1119
|
+
if (input.has("description"))
|
|
1120
|
+
result.description = input.getString("description");
|
|
1121
|
+
if (input.has("manualCrop"))
|
|
1122
|
+
result.manualCrop = input.getBoolean("manualCrop");
|
|
1123
|
+
return result;
|
|
1124
|
+
} catch (JSONException e) {
|
|
1125
|
+
e.printStackTrace();
|
|
1126
|
+
}
|
|
1127
|
+
return null;
|
|
1128
|
+
}
|
|
814
1129
|
|
|
815
|
-
|
|
1130
|
+
static FaceMetaData FaceMetaDataFromJSON(JSONObject input) {
|
|
1131
|
+
try {
|
|
1132
|
+
FaceMetaData result = new FaceMetaData();
|
|
1133
|
+
if (input.has("ID"))
|
|
1134
|
+
result.ID = input.getInt("ID");
|
|
1135
|
+
if (input.has("rollAngle"))
|
|
1136
|
+
result.rollAngle = input.getInt("rollAngle");
|
|
1137
|
+
if (input.has("bounds"))
|
|
1138
|
+
result.bounds = BoundsFromJSON(input.getJSONObject("bounds"));
|
|
1139
|
+
return result;
|
|
1140
|
+
} catch (JSONException e) {
|
|
1141
|
+
e.printStackTrace();
|
|
1142
|
+
}
|
|
1143
|
+
return null;
|
|
816
1144
|
}
|
|
817
1145
|
|
|
818
|
-
static
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
1146
|
+
static Bounds BoundsFromJSON(JSONObject input) {
|
|
1147
|
+
try {
|
|
1148
|
+
Bounds result = new Bounds();
|
|
1149
|
+
if (input.has("x"))
|
|
1150
|
+
result.x = input.getInt("x");
|
|
1151
|
+
if (input.has("y"))
|
|
1152
|
+
result.y = input.getInt("y");
|
|
1153
|
+
if (input.has("width"))
|
|
1154
|
+
result.width = input.getInt("width");
|
|
1155
|
+
if (input.has("height"))
|
|
1156
|
+
result.height = input.getInt("height");
|
|
1157
|
+
return result;
|
|
1158
|
+
} catch (JSONException e) {
|
|
1159
|
+
e.printStackTrace();
|
|
1160
|
+
}
|
|
1161
|
+
return null;
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
static Rect RectFromJSON(JSONObject input) {
|
|
1165
|
+
try {
|
|
1166
|
+
Rect result = new Rect();
|
|
1167
|
+
if (input.has("bottom"))
|
|
1168
|
+
result.bottom = input.getInt("bottom");
|
|
1169
|
+
if (input.has("top"))
|
|
1170
|
+
result.top = input.getInt("top");
|
|
1171
|
+
if (input.has("left"))
|
|
1172
|
+
result.left = input.getInt("left");
|
|
1173
|
+
if (input.has("right"))
|
|
1174
|
+
result.right = input.getInt("right");
|
|
1175
|
+
return result;
|
|
1176
|
+
} catch (JSONException e) {
|
|
1177
|
+
e.printStackTrace();
|
|
1178
|
+
}
|
|
1179
|
+
return null;
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
static DocReaderFieldRect DocReaderFieldRectFromJSON(JSONObject input) {
|
|
1183
|
+
try {
|
|
1184
|
+
DocReaderFieldRect result = new DocReaderFieldRect();
|
|
1185
|
+
if (input.has("bottom"))
|
|
1186
|
+
result.bottom = input.getInt("bottom");
|
|
1187
|
+
if (input.has("top"))
|
|
1188
|
+
result.top = input.getInt("top");
|
|
1189
|
+
if (input.has("left"))
|
|
1190
|
+
result.left = input.getInt("left");
|
|
1191
|
+
if (input.has("right"))
|
|
1192
|
+
result.right = input.getInt("right");
|
|
1193
|
+
return result;
|
|
1194
|
+
} catch (JSONException e) {
|
|
1195
|
+
e.printStackTrace();
|
|
1196
|
+
}
|
|
1197
|
+
return null;
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
static DocumentReaderGraphicField DocumentReaderGraphicFieldFromJSON(JSONObject input) {
|
|
1201
|
+
try {
|
|
1202
|
+
DocumentReaderGraphicField result = new DocumentReaderGraphicField();
|
|
1203
|
+
if (input.has("sourceType"))
|
|
1204
|
+
result.sourceType = input.getInt("sourceType");
|
|
1205
|
+
if (input.has("fieldType"))
|
|
1206
|
+
result.fieldType = input.getInt("fieldType");
|
|
1207
|
+
if (input.has("lightType"))
|
|
1208
|
+
result.light = input.getInt("lightType");
|
|
1209
|
+
if (input.has("pageIndex"))
|
|
1210
|
+
result.pageIndex = input.getInt("pageIndex");
|
|
1211
|
+
if (input.has("fieldRect"))
|
|
1212
|
+
result.boundRect = DocReaderFieldRectFromJSON(input.getJSONObject("fieldRect"));
|
|
1213
|
+
return result;
|
|
1214
|
+
} catch (JSONException e) {
|
|
1215
|
+
e.printStackTrace();
|
|
1216
|
+
}
|
|
1217
|
+
return null;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
static DocumentReaderGraphicResult DocumentReaderGraphicResultFromJSON(JSONObject input) {
|
|
1221
|
+
try {
|
|
1222
|
+
DocumentReaderGraphicResult result = new DocumentReaderGraphicResult();
|
|
1223
|
+
if (input.has("fields")){
|
|
1224
|
+
JSONArray jsonArray_fields = input.getJSONArray("fields");
|
|
1225
|
+
List<DocumentReaderGraphicField> fields = new ArrayList<>();
|
|
1226
|
+
for (int i = 0; i < jsonArray_fields.length(); i++)
|
|
1227
|
+
fields.add(DocumentReaderGraphicFieldFromJSON(jsonArray_fields.getJSONObject(i)));
|
|
1228
|
+
result.fields = fields;
|
|
1229
|
+
}
|
|
1230
|
+
return result;
|
|
1231
|
+
} catch (JSONException e) {
|
|
1232
|
+
e.printStackTrace();
|
|
1233
|
+
}
|
|
1234
|
+
return null;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
static DocumentReaderValue DocumentReaderValueFromJSON(JSONObject input) {
|
|
1238
|
+
try {
|
|
1239
|
+
DocumentReaderValue result = new DocumentReaderValue();
|
|
1240
|
+
if (input.has("pageIndex"))
|
|
1241
|
+
result.pageIndex = input.getInt("pageIndex");
|
|
1242
|
+
if (input.has("sourceType"))
|
|
1243
|
+
result.sourceType = input.getInt("sourceType");
|
|
1244
|
+
if (input.has("validity"))
|
|
1245
|
+
result.validity = input.getInt("validity");
|
|
1246
|
+
if (input.has("probability"))
|
|
1247
|
+
result.probability = input.getInt("probability");
|
|
1248
|
+
if (input.has("value"))
|
|
1249
|
+
result.value = input.getString("value");
|
|
1250
|
+
if (input.has("originalValue"))
|
|
1251
|
+
result.originalValue = input.getString("originalValue");
|
|
1252
|
+
if (input.has("boundRect"))
|
|
1253
|
+
result.boundRect = RectFromJSON(input.getJSONObject("boundRect"));
|
|
1254
|
+
return result;
|
|
1255
|
+
} catch (JSONException e) {
|
|
1256
|
+
e.printStackTrace();
|
|
1257
|
+
}
|
|
1258
|
+
return null;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
static DocumentReaderTextField DocumentReaderTextFieldFromJSON(JSONObject input) {
|
|
1262
|
+
try {
|
|
1263
|
+
DocumentReaderTextField result = new DocumentReaderTextField();
|
|
1264
|
+
if (input.has("fieldType"))
|
|
1265
|
+
result.fieldType = input.getInt("fieldType");
|
|
1266
|
+
if (input.has("lcid"))
|
|
1267
|
+
result.lcid = input.getInt("lcid");
|
|
1268
|
+
if (input.has("status"))
|
|
1269
|
+
result.status = input.getInt("status");
|
|
1270
|
+
if (input.has("values")){
|
|
1271
|
+
JSONArray jsonArray_values = input.getJSONArray("values");
|
|
1272
|
+
List<DocumentReaderValue> values = new ArrayList<>();
|
|
1273
|
+
for (int i = 0; i < jsonArray_values.length(); i++)
|
|
1274
|
+
values.add(DocumentReaderValueFromJSON(jsonArray_values.getJSONObject(i)));
|
|
1275
|
+
result.values = values;
|
|
1276
|
+
}
|
|
1277
|
+
return result;
|
|
1278
|
+
} catch (JSONException e) {
|
|
1279
|
+
e.printStackTrace();
|
|
1280
|
+
}
|
|
1281
|
+
return null;
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
static DocumentReaderTextResult DocumentReaderTextResultFromJSON(JSONObject input) {
|
|
1285
|
+
try {
|
|
1286
|
+
DocumentReaderTextResult result = new DocumentReaderTextResult();
|
|
1287
|
+
if (input.has("status"))
|
|
1288
|
+
result.status = input.getInt("status");
|
|
1289
|
+
if (input.has("fields")){
|
|
1290
|
+
JSONArray jsonArray_fields = input.getJSONArray("fields");
|
|
1291
|
+
List<DocumentReaderTextField> fields = new ArrayList<>();
|
|
1292
|
+
for (int i = 0; i < jsonArray_fields.length(); i++)
|
|
1293
|
+
fields.add(DocumentReaderTextFieldFromJSON(jsonArray_fields.getJSONObject(i)));
|
|
1294
|
+
result.fields = fields;
|
|
1295
|
+
}
|
|
1296
|
+
return result;
|
|
1297
|
+
} catch (JSONException e) {
|
|
1298
|
+
e.printStackTrace();
|
|
1299
|
+
}
|
|
1300
|
+
return null;
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
static Coordinate CoordinateFromJSON(JSONObject input) {
|
|
1304
|
+
try {
|
|
1305
|
+
Coordinate result = new Coordinate();
|
|
1306
|
+
if (input.has("x"))
|
|
1307
|
+
result.x = input.getInt("x");
|
|
1308
|
+
if (input.has("y"))
|
|
1309
|
+
result.y = input.getInt("y");
|
|
1310
|
+
return result;
|
|
1311
|
+
} catch (JSONException e) {
|
|
1312
|
+
e.printStackTrace();
|
|
1313
|
+
}
|
|
1314
|
+
return null;
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
static ElementPosition ElementPositionFromJSON(JSONObject input) {
|
|
1318
|
+
try {
|
|
1319
|
+
ElementPosition result = new ElementPosition();
|
|
1320
|
+
if (input.has("docFormat"))
|
|
1321
|
+
result.docFormat = input.getInt("docFormat");
|
|
1322
|
+
if (input.has("width"))
|
|
1323
|
+
result.width = input.getInt("width");
|
|
1324
|
+
if (input.has("height"))
|
|
1325
|
+
result.height = input.getInt("height");
|
|
1326
|
+
if (input.has("dpi"))
|
|
1327
|
+
result.dpi = input.getInt("dpi");
|
|
1328
|
+
if (input.has("pageIndex"))
|
|
1329
|
+
result.pageIndex = input.getInt("pageIndex");
|
|
1330
|
+
if (input.has("inverse"))
|
|
1331
|
+
result.inverse = input.getInt("inverse");
|
|
1332
|
+
if (input.has("perspectiveTr"))
|
|
1333
|
+
result.perspectiveTr = input.getInt("perspectiveTr");
|
|
1334
|
+
if (input.has("objArea"))
|
|
1335
|
+
result.objArea = input.getInt("objArea");
|
|
1336
|
+
if (input.has("objIntAngleDev"))
|
|
1337
|
+
result.objIntAngleDev = input.getInt("objIntAngleDev");
|
|
1338
|
+
if (input.has("resultStatus"))
|
|
1339
|
+
result.resultStatus = input.getInt("resultStatus");
|
|
1340
|
+
if (input.has("angle"))
|
|
1341
|
+
result.angle = input.getDouble("angle");
|
|
1342
|
+
if (input.has("center"))
|
|
1343
|
+
result.center = CoordinateFromJSON(input.getJSONObject("center"));
|
|
1344
|
+
if (input.has("leftTop"))
|
|
1345
|
+
result.leftTop = CoordinateFromJSON(input.getJSONObject("leftTop"));
|
|
1346
|
+
if (input.has("leftBottom"))
|
|
1347
|
+
result.leftBottom = CoordinateFromJSON(input.getJSONObject("leftBottom"));
|
|
1348
|
+
if (input.has("rightTop"))
|
|
1349
|
+
result.rightTop = CoordinateFromJSON(input.getJSONObject("rightTop"));
|
|
1350
|
+
if (input.has("rightBottom"))
|
|
1351
|
+
result.rightBottom = CoordinateFromJSON(input.getJSONObject("rightBottom"));
|
|
1352
|
+
return result;
|
|
1353
|
+
} catch (JSONException e) {
|
|
1354
|
+
e.printStackTrace();
|
|
1355
|
+
}
|
|
1356
|
+
return null;
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
static ImageQuality ImageQualityFromJSON(JSONObject input) {
|
|
1360
|
+
try {
|
|
1361
|
+
ImageQuality result = new ImageQuality();
|
|
1362
|
+
if (input.has("featureType"))
|
|
1363
|
+
result.featureType = input.getInt("featureType");
|
|
1364
|
+
if (input.has("result"))
|
|
1365
|
+
result.result = input.getInt("result");
|
|
1366
|
+
if (input.has("type"))
|
|
1367
|
+
result.type = input.getInt("type");
|
|
1368
|
+
return result;
|
|
1369
|
+
} catch (JSONException e) {
|
|
1370
|
+
e.printStackTrace();
|
|
1371
|
+
}
|
|
1372
|
+
return null;
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
static ImageQualityGroup ImageQualityGroupFromJSON(JSONObject input) {
|
|
1376
|
+
try {
|
|
1377
|
+
ImageQualityGroup result = new ImageQualityGroup();
|
|
1378
|
+
if (input.has("count"))
|
|
1379
|
+
result.count = input.getInt("count");
|
|
1380
|
+
if (input.has("result"))
|
|
1381
|
+
result.result = input.getInt("result");
|
|
1382
|
+
if (input.has("imageQualityList")){
|
|
1383
|
+
JSONArray jsonArray_imageQualityList = input.getJSONArray("imageQualityList");
|
|
1384
|
+
List<ImageQuality> imageQualityList = new ArrayList<>();
|
|
1385
|
+
for (int i = 0; i < jsonArray_imageQualityList.length(); i++)
|
|
1386
|
+
imageQualityList.add(ImageQualityFromJSON(jsonArray_imageQualityList.getJSONObject(i)));
|
|
1387
|
+
result.imageQualityList = imageQualityList;
|
|
1388
|
+
}
|
|
1389
|
+
if (input.has("pageIndex"))
|
|
1390
|
+
result.pageIndex = input.getInt("pageIndex");
|
|
1391
|
+
return result;
|
|
1392
|
+
} catch (JSONException e) {
|
|
1393
|
+
e.printStackTrace();
|
|
1394
|
+
}
|
|
1395
|
+
return null;
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
static DocumentReaderDocumentType DocumentReaderDocumentTypeFromJSON(JSONObject input) {
|
|
1399
|
+
try {
|
|
1400
|
+
DocumentReaderDocumentType result = new DocumentReaderDocumentType();
|
|
1401
|
+
if (input.has("pageIndex"))
|
|
1402
|
+
result.pageIndex = input.getInt("pageIndex");
|
|
1403
|
+
if (input.has("documentID"))
|
|
1404
|
+
result.documentID = input.getInt("documentID");
|
|
1405
|
+
if (input.has("dType"))
|
|
1406
|
+
result.dType = input.getInt("dType");
|
|
1407
|
+
if (input.has("dFormat"))
|
|
1408
|
+
result.dFormat = input.getInt("dFormat");
|
|
1409
|
+
if (input.has("dMRZ"))
|
|
1410
|
+
result.dMRZ = input.getBoolean("dMRZ");
|
|
1411
|
+
if (input.has("name"))
|
|
1412
|
+
result.name = input.getString("name");
|
|
1413
|
+
if (input.has("ICAOCode"))
|
|
1414
|
+
result.ICAOCode = input.getString("ICAOCode");
|
|
1415
|
+
if (input.has("dDescription"))
|
|
1416
|
+
result.dDescription = input.getString("dDescription");
|
|
1417
|
+
if (input.has("dYear"))
|
|
1418
|
+
result.dYear = input.getString("dYear");
|
|
1419
|
+
if (input.has("dCountryName"))
|
|
1420
|
+
result.dCountryName = input.getString("dCountryName");
|
|
1421
|
+
if (input.has("FDSID")){
|
|
1422
|
+
JSONArray jsonArray_FDSID = input.getJSONArray("FDSID");
|
|
1423
|
+
int[] FDSID = new int[jsonArray_FDSID.length()];
|
|
1424
|
+
for (int i = 0; i < jsonArray_FDSID.length(); i++)
|
|
1425
|
+
FDSID[i] = jsonArray_FDSID.getInt(i);
|
|
1426
|
+
result.FDSID = FDSID;
|
|
1427
|
+
}
|
|
1428
|
+
return result;
|
|
1429
|
+
} catch (JSONException e) {
|
|
1430
|
+
e.printStackTrace();
|
|
1431
|
+
}
|
|
1432
|
+
return null;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
static AccessControlProcedureType AccessControlProcedureTypeFromJSON(JSONObject input) {
|
|
1436
|
+
try {
|
|
1437
|
+
AccessControlProcedureType result = new AccessControlProcedureType();
|
|
1438
|
+
if (input.has("activeOptionIdx"))
|
|
1439
|
+
result.activeOptionIdx = input.getInt("activeOptionIdx");
|
|
1440
|
+
if (input.has("type"))
|
|
1441
|
+
result.type = input.getInt("type");
|
|
1442
|
+
if (input.has("status"))
|
|
1443
|
+
result.status = input.getInt("status");
|
|
1444
|
+
if (input.has("notifications")){
|
|
1445
|
+
JSONArray jsonArray_notifications = input.getJSONArray("notifications");
|
|
1446
|
+
List<Long> notifications = new ArrayList<>();
|
|
1447
|
+
for (int i = 0; i < jsonArray_notifications.length(); i++)
|
|
1448
|
+
notifications.add(jsonArray_notifications.getLong(i));
|
|
1449
|
+
result.notifications = notifications;
|
|
1450
|
+
}
|
|
1451
|
+
return result;
|
|
1452
|
+
} catch (JSONException e) {
|
|
1453
|
+
e.printStackTrace();
|
|
1454
|
+
}
|
|
1455
|
+
return null;
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
static FileData FileDataFromJSON(JSONObject input) {
|
|
1459
|
+
try {
|
|
1460
|
+
FileData result = new FileData();
|
|
1461
|
+
if (input.has("length"))
|
|
1462
|
+
result.length = input.getInt("length");
|
|
1463
|
+
if (input.has("type"))
|
|
1464
|
+
result.type = input.getInt("type");
|
|
1465
|
+
if (input.has("status"))
|
|
1466
|
+
result.status = input.getInt("status");
|
|
1467
|
+
if (input.has("data"))
|
|
1468
|
+
result.data = input.getString("data");
|
|
1469
|
+
return result;
|
|
1470
|
+
} catch (JSONException e) {
|
|
1471
|
+
e.printStackTrace();
|
|
1472
|
+
}
|
|
1473
|
+
return null;
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
static CertificateData CertificateDataFromJSON(JSONObject input) {
|
|
1477
|
+
try {
|
|
1478
|
+
CertificateData result = new CertificateData();
|
|
1479
|
+
if (input.has("length"))
|
|
1480
|
+
result.length = input.getInt("length");
|
|
1481
|
+
if (input.has("data"))
|
|
1482
|
+
result.data = input.getString("data");
|
|
1483
|
+
return result;
|
|
1484
|
+
} catch (JSONException e) {
|
|
1485
|
+
e.printStackTrace();
|
|
1486
|
+
}
|
|
1487
|
+
return null;
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
static SecurityObjectCertificates SecurityObjectCertificatesFromJSON(JSONObject input) {
|
|
1491
|
+
try {
|
|
1492
|
+
SecurityObjectCertificates result = new SecurityObjectCertificates();
|
|
1493
|
+
if (input.has("securityObject"))
|
|
1494
|
+
result.securityObject = CertificateDataFromJSON(input.getJSONObject("securityObject"));
|
|
1495
|
+
return result;
|
|
1496
|
+
} catch (JSONException e) {
|
|
1497
|
+
e.printStackTrace();
|
|
1498
|
+
}
|
|
1499
|
+
return null;
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
static File FileFromJSON(JSONObject input) {
|
|
1503
|
+
try {
|
|
1504
|
+
File result = new File();
|
|
1505
|
+
if (input.has("readingTime"))
|
|
1506
|
+
result.readingTime = input.getInt("readingTime");
|
|
1507
|
+
if (input.has("type"))
|
|
1508
|
+
result.type = input.getInt("type");
|
|
1509
|
+
if (input.has("pAStatus"))
|
|
1510
|
+
result.pAStatus = input.getInt("pAStatus");
|
|
1511
|
+
if (input.has("readingStatus"))
|
|
1512
|
+
result.readingStatus = input.getInt("readingStatus");
|
|
1513
|
+
if (input.has("fileID"))
|
|
1514
|
+
result.fileID = input.getString("fileID");
|
|
1515
|
+
if (input.has("fileData"))
|
|
1516
|
+
result.fileData = FileDataFromJSON(input.getJSONObject("fileData"));
|
|
1517
|
+
if (input.has("certificates"))
|
|
1518
|
+
result.certificates = SecurityObjectCertificatesFromJSON(input.getJSONObject("certificates"));
|
|
1519
|
+
if (input.has("docFieldsText")){
|
|
1520
|
+
JSONArray jsonArray_docFieldsText = input.getJSONArray("docFieldsText");
|
|
1521
|
+
List<Integer> docFieldsText = new ArrayList<>();
|
|
1522
|
+
for (int i = 0; i < jsonArray_docFieldsText.length(); i++)
|
|
1523
|
+
docFieldsText.add(jsonArray_docFieldsText.getInt(i));
|
|
1524
|
+
result.docFieldsText = docFieldsText;
|
|
1525
|
+
}
|
|
1526
|
+
if (input.has("docFieldsGraphics")){
|
|
1527
|
+
JSONArray jsonArray_docFieldsGraphics = input.getJSONArray("docFieldsGraphics");
|
|
1528
|
+
List<Integer> docFieldsGraphics = new ArrayList<>();
|
|
1529
|
+
for (int i = 0; i < jsonArray_docFieldsGraphics.length(); i++)
|
|
1530
|
+
docFieldsGraphics.add(jsonArray_docFieldsGraphics.getInt(i));
|
|
1531
|
+
result.docFieldsGraphics = docFieldsGraphics;
|
|
1532
|
+
}
|
|
1533
|
+
if (input.has("docFieldsOriginals")){
|
|
1534
|
+
JSONArray jsonArray_docFieldsOriginals = input.getJSONArray("docFieldsOriginals");
|
|
1535
|
+
List<Integer> docFieldsOriginals = new ArrayList<>();
|
|
1536
|
+
for (int i = 0; i < jsonArray_docFieldsOriginals.length(); i++)
|
|
1537
|
+
docFieldsOriginals.add(jsonArray_docFieldsOriginals.getInt(i));
|
|
1538
|
+
result.docFieldsOriginals = docFieldsOriginals;
|
|
1539
|
+
}
|
|
1540
|
+
if (input.has("notifications")){
|
|
1541
|
+
JSONArray jsonArray_notifications = input.getJSONArray("notifications");
|
|
1542
|
+
List<Long> notifications = new ArrayList<>();
|
|
1543
|
+
for (int i = 0; i < jsonArray_notifications.length(); i++)
|
|
1544
|
+
notifications.add(jsonArray_notifications.getLong(i));
|
|
1545
|
+
result.notifications = notifications;
|
|
1546
|
+
}
|
|
1547
|
+
return result;
|
|
1548
|
+
} catch (JSONException e) {
|
|
1549
|
+
e.printStackTrace();
|
|
1550
|
+
}
|
|
1551
|
+
return null;
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
static Application ApplicationFromJSON(JSONObject input) {
|
|
1555
|
+
try {
|
|
1556
|
+
Application result = new Application();
|
|
1557
|
+
if (input.has("type"))
|
|
1558
|
+
result.type = input.getInt("type");
|
|
1559
|
+
if (input.has("status"))
|
|
1560
|
+
result.status = input.getInt("status");
|
|
1561
|
+
if (input.has("applicationID"))
|
|
1562
|
+
result.applicationID = input.getString("applicationID");
|
|
1563
|
+
if (input.has("dataHashAlgorithm"))
|
|
1564
|
+
result.dataHashAlgorithm = input.getString("dataHashAlgorithm");
|
|
1565
|
+
if (input.has("unicodeVersion"))
|
|
1566
|
+
result.unicodeVersion = input.getString("unicodeVersion");
|
|
1567
|
+
if (input.has("version"))
|
|
1568
|
+
result.version = input.getString("version");
|
|
1569
|
+
if (input.has("files")){
|
|
1570
|
+
JSONArray jsonArray_files = input.getJSONArray("files");
|
|
1571
|
+
List<File> files = new ArrayList<>();
|
|
1572
|
+
for (int i = 0; i < jsonArray_files.length(); i++)
|
|
1573
|
+
files.add(FileFromJSON(jsonArray_files.getJSONObject(i)));
|
|
1574
|
+
result.files = files;
|
|
1575
|
+
}
|
|
1576
|
+
return result;
|
|
1577
|
+
} catch (JSONException e) {
|
|
1578
|
+
e.printStackTrace();
|
|
1579
|
+
}
|
|
1580
|
+
return null;
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
static Value ValueFromJSON(JSONObject input) {
|
|
1584
|
+
try {
|
|
1585
|
+
Value result = new Value();
|
|
1586
|
+
if (input.has("length"))
|
|
1587
|
+
result.length = input.getInt("length");
|
|
1588
|
+
if (input.has("type"))
|
|
1589
|
+
result.type = input.getInt("type");
|
|
1590
|
+
if (input.has("status"))
|
|
1591
|
+
result.status = input.getInt("status");
|
|
1592
|
+
if (input.has("data"))
|
|
1593
|
+
result.data = input.getString("data");
|
|
1594
|
+
if (input.has("format"))
|
|
1595
|
+
result.format = input.getString("format");
|
|
1596
|
+
return result;
|
|
1597
|
+
} catch (JSONException e) {
|
|
1598
|
+
e.printStackTrace();
|
|
1599
|
+
}
|
|
1600
|
+
return null;
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
static Attribute AttributeFromJSON(JSONObject input) {
|
|
1604
|
+
try {
|
|
1605
|
+
Attribute result = new Attribute();
|
|
1606
|
+
if (input.has("type"))
|
|
1607
|
+
result.type = input.getString("type");
|
|
1608
|
+
if (input.has("value"))
|
|
1609
|
+
result.value = ValueFromJSON(input.getJSONObject("value"));
|
|
1610
|
+
return result;
|
|
1611
|
+
} catch (JSONException e) {
|
|
1612
|
+
e.printStackTrace();
|
|
1613
|
+
}
|
|
1614
|
+
return null;
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
static Authority AuthorityFromJSON(JSONObject input) {
|
|
1618
|
+
try {
|
|
1619
|
+
Authority result = new Authority();
|
|
1620
|
+
if (input.has("data"))
|
|
1621
|
+
result.data = input.getString("data");
|
|
1622
|
+
if (input.has("friendlyName"))
|
|
1623
|
+
result.friendlyName = ValueFromJSON(input.getJSONObject("friendlyName"));
|
|
1624
|
+
if (input.has("attributes")){
|
|
1625
|
+
JSONArray jsonArray_attributes = input.getJSONArray("attributes");
|
|
1626
|
+
List<Attribute> attributes = new ArrayList<>();
|
|
1627
|
+
for (int i = 0; i < jsonArray_attributes.length(); i++)
|
|
1628
|
+
attributes.add(AttributeFromJSON(jsonArray_attributes.getJSONObject(i)));
|
|
1629
|
+
result.attributes = attributes;
|
|
1630
|
+
}
|
|
1631
|
+
return result;
|
|
1632
|
+
} catch (JSONException e) {
|
|
1633
|
+
e.printStackTrace();
|
|
1634
|
+
}
|
|
1635
|
+
return null;
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
static Extension ExtensionFromJSON(JSONObject input) {
|
|
1639
|
+
try {
|
|
1640
|
+
Extension result = new Extension();
|
|
1641
|
+
if (input.has("data"))
|
|
1642
|
+
result.data = input.getString("data");
|
|
1643
|
+
if (input.has("type"))
|
|
1644
|
+
result.type = input.getString("type");
|
|
1645
|
+
return result;
|
|
1646
|
+
} catch (JSONException e) {
|
|
1647
|
+
e.printStackTrace();
|
|
1648
|
+
}
|
|
1649
|
+
return null;
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
static Validity ValidityFromJSON(JSONObject input) {
|
|
1653
|
+
try {
|
|
1654
|
+
Validity result = new Validity();
|
|
1655
|
+
if (input.has("notAfter"))
|
|
1656
|
+
result.notAfter = ValueFromJSON(input.getJSONObject("notAfter"));
|
|
1657
|
+
if (input.has("notBefore"))
|
|
1658
|
+
result.notBefore = ValueFromJSON(input.getJSONObject("notBefore"));
|
|
1659
|
+
return result;
|
|
1660
|
+
} catch (JSONException e) {
|
|
1661
|
+
e.printStackTrace();
|
|
1662
|
+
}
|
|
1663
|
+
return null;
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
static CertificateChain CertificateChainFromJSON(JSONObject input) {
|
|
1667
|
+
try {
|
|
1668
|
+
CertificateChain result = new CertificateChain();
|
|
1669
|
+
if (input.has("origin"))
|
|
1670
|
+
result.origin = input.getInt("origin");
|
|
1671
|
+
if (input.has("type"))
|
|
1672
|
+
result.type = input.getInt("type");
|
|
1673
|
+
if (input.has("version"))
|
|
1674
|
+
result.version = input.getInt("version");
|
|
1675
|
+
if (input.has("paStatus"))
|
|
1676
|
+
result.paStatus = input.getInt("paStatus");
|
|
1677
|
+
if (input.has("serialNumber"))
|
|
1678
|
+
result.serialNumber = input.getString("serialNumber");
|
|
1679
|
+
if (input.has("signatureAlgorithm"))
|
|
1680
|
+
result.signatureAlgorithm = input.getString("signatureAlgorithm");
|
|
1681
|
+
if (input.has("subjectPKAlgorithm"))
|
|
1682
|
+
result.subjectPKAlgorithm = input.getString("subjectPKAlgorithm");
|
|
1683
|
+
if (input.has("fileName"))
|
|
1684
|
+
result.fileName = ValueFromJSON(input.getJSONObject("fileName"));
|
|
1685
|
+
if (input.has("validity"))
|
|
1686
|
+
result.validity = ValidityFromJSON(input.getJSONObject("validity"));
|
|
1687
|
+
if (input.has("issuer"))
|
|
1688
|
+
result.issuer = AuthorityFromJSON(input.getJSONObject("issuer"));
|
|
1689
|
+
if (input.has("subject"))
|
|
1690
|
+
result.subject = AuthorityFromJSON(input.getJSONObject("subject"));
|
|
1691
|
+
if (input.has("notifications")){
|
|
1692
|
+
JSONArray jsonArray_notifications = input.getJSONArray("notifications");
|
|
1693
|
+
List<Long> notifications = new ArrayList<>();
|
|
1694
|
+
for (int i = 0; i < jsonArray_notifications.length(); i++)
|
|
1695
|
+
notifications.add(jsonArray_notifications.getLong(i));
|
|
1696
|
+
result.notifications = notifications;
|
|
1697
|
+
}
|
|
1698
|
+
if (input.has("extensions")){
|
|
1699
|
+
JSONArray jsonArray_extensions = input.getJSONArray("extensions");
|
|
1700
|
+
List<Extension> extensions = new ArrayList<>();
|
|
1701
|
+
for (int i = 0; i < jsonArray_extensions.length(); i++)
|
|
1702
|
+
extensions.add(ExtensionFromJSON(jsonArray_extensions.getJSONObject(i)));
|
|
1703
|
+
result.extensions = extensions;
|
|
1704
|
+
}
|
|
1705
|
+
return result;
|
|
1706
|
+
} catch (JSONException e) {
|
|
1707
|
+
e.printStackTrace();
|
|
1708
|
+
}
|
|
1709
|
+
return null;
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
static SignerInfo SignerInfoFromJSON(JSONObject input) {
|
|
1713
|
+
try {
|
|
1714
|
+
SignerInfo result = new SignerInfo();
|
|
1715
|
+
if (input.has("version"))
|
|
1716
|
+
result.version = input.getInt("version");
|
|
1717
|
+
if (input.has("paStatus"))
|
|
1718
|
+
result.paStatus = input.getInt("paStatus");
|
|
1719
|
+
if (input.has("dataToHash"))
|
|
1720
|
+
result.dataToHash = input.getString("dataToHash");
|
|
1721
|
+
if (input.has("digestAlgorithm"))
|
|
1722
|
+
result.digestAlgorithm = input.getString("digestAlgorithm");
|
|
1723
|
+
if (input.has("signatureAlgorithm"))
|
|
1724
|
+
result.signatureAlgorithm = input.getString("signatureAlgorithm");
|
|
1725
|
+
if (input.has("serialNumber"))
|
|
1726
|
+
result.serialNumber = ValueFromJSON(input.getJSONObject("serialNumber"));
|
|
1727
|
+
if (input.has("signature"))
|
|
1728
|
+
result.signature = ValueFromJSON(input.getJSONObject("signature"));
|
|
1729
|
+
if (input.has("subjectKeyIdentifier"))
|
|
1730
|
+
result.subjectKeyIdentifier = ValueFromJSON(input.getJSONObject("subjectKeyIdentifier"));
|
|
1731
|
+
if (input.has("issuer"))
|
|
1732
|
+
result.issuer = AuthorityFromJSON(input.getJSONObject("issuer"));
|
|
1733
|
+
if (input.has("notifications")){
|
|
1734
|
+
JSONArray jsonArray_notifications = input.getJSONArray("notifications");
|
|
1735
|
+
List<Long> notifications = new ArrayList<>();
|
|
1736
|
+
for (int i = 0; i < jsonArray_notifications.length(); i++)
|
|
1737
|
+
notifications.add(jsonArray_notifications.getLong(i));
|
|
1738
|
+
result.notifications = notifications;
|
|
1739
|
+
}
|
|
1740
|
+
if (input.has("signedAttributes")){
|
|
1741
|
+
JSONArray jsonArray_signedAttributes = input.getJSONArray("signedAttributes");
|
|
1742
|
+
List<Extension> signedAttributes = new ArrayList<>();
|
|
1743
|
+
for (int i = 0; i < jsonArray_signedAttributes.length(); i++)
|
|
1744
|
+
signedAttributes.add(ExtensionFromJSON(jsonArray_signedAttributes.getJSONObject(i)));
|
|
1745
|
+
result.signedAttributes = signedAttributes;
|
|
1746
|
+
}
|
|
1747
|
+
if (input.has("certificateChain")){
|
|
1748
|
+
JSONArray jsonArray_certificateChain = input.getJSONArray("certificateChain");
|
|
1749
|
+
List<CertificateChain> certificateChain = new ArrayList<>();
|
|
1750
|
+
for (int i = 0; i < jsonArray_certificateChain.length(); i++)
|
|
1751
|
+
certificateChain.add(CertificateChainFromJSON(jsonArray_certificateChain.getJSONObject(i)));
|
|
1752
|
+
result.certificateChain = certificateChain;
|
|
1753
|
+
}
|
|
1754
|
+
return result;
|
|
1755
|
+
} catch (JSONException e) {
|
|
1756
|
+
e.printStackTrace();
|
|
1757
|
+
}
|
|
1758
|
+
return null;
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
static SecurityObject SecurityObjectFromJSON(JSONObject input) {
|
|
1762
|
+
try {
|
|
1763
|
+
SecurityObject result = new SecurityObject();
|
|
1764
|
+
if (input.has("fileReference"))
|
|
1765
|
+
result.fileReference = input.getInt("fileReference");
|
|
1766
|
+
if (input.has("version"))
|
|
1767
|
+
result.version = input.getInt("version");
|
|
1768
|
+
if (input.has("objectType"))
|
|
1769
|
+
result.objectType = input.getString("objectType");
|
|
1770
|
+
if (input.has("notifications")){
|
|
1771
|
+
JSONArray jsonArray_notifications = input.getJSONArray("notifications");
|
|
1772
|
+
List<Long> notifications = new ArrayList<>();
|
|
1773
|
+
for (int i = 0; i < jsonArray_notifications.length(); i++)
|
|
1774
|
+
notifications.add(jsonArray_notifications.getLong(i));
|
|
1775
|
+
result.notifications = notifications;
|
|
1776
|
+
}
|
|
1777
|
+
if (input.has("signerInfos")){
|
|
1778
|
+
JSONArray jsonArray_signerInfos = input.getJSONArray("signerInfos");
|
|
1779
|
+
List<SignerInfo> signerInfos = new ArrayList<>();
|
|
1780
|
+
for (int i = 0; i < jsonArray_signerInfos.length(); i++)
|
|
1781
|
+
signerInfos.add(SignerInfoFromJSON(jsonArray_signerInfos.getJSONObject(i)));
|
|
1782
|
+
result.signerInfos = signerInfos;
|
|
1783
|
+
}
|
|
1784
|
+
return result;
|
|
1785
|
+
} catch (JSONException e) {
|
|
1786
|
+
e.printStackTrace();
|
|
1787
|
+
}
|
|
1788
|
+
return null;
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
static CardProperties CardPropertiesFromJSON(JSONObject input) {
|
|
1792
|
+
try {
|
|
1793
|
+
CardProperties result = new CardProperties();
|
|
1794
|
+
if (input.has("aTQA"))
|
|
1795
|
+
result.aTQA = input.getInt("aTQA");
|
|
1796
|
+
if (input.has("bitRateR"))
|
|
1797
|
+
result.bitRateR = input.getInt("bitRateR");
|
|
1798
|
+
if (input.has("bitRateS"))
|
|
1799
|
+
result.bitRateS = input.getInt("bitRateS");
|
|
1800
|
+
if (input.has("chipTypeA"))
|
|
1801
|
+
result.chipTypeA = input.getInt("chipTypeA");
|
|
1802
|
+
if (input.has("mifareMemory"))
|
|
1803
|
+
result.mifareMemory = input.getInt("mifareMemory");
|
|
1804
|
+
if (input.has("rfidType"))
|
|
1805
|
+
result.rfidType = input.getInt("rfidType");
|
|
1806
|
+
if (input.has("sAK"))
|
|
1807
|
+
result.sAK = input.getInt("sAK");
|
|
1808
|
+
if (input.has("support4"))
|
|
1809
|
+
result.support4 = input.getBoolean("support4");
|
|
1810
|
+
if (input.has("supportMifare"))
|
|
1811
|
+
result.supportMifare = input.getBoolean("supportMifare");
|
|
1812
|
+
if (input.has("aTQB"))
|
|
1813
|
+
result.aTQB = input.getString("aTQB");
|
|
1814
|
+
if (input.has("aTR"))
|
|
1815
|
+
result.aTR = input.getString("aTR");
|
|
1816
|
+
if (input.has("baudrate1"))
|
|
1817
|
+
result.baudrate1 = input.getString("baudrate1");
|
|
1818
|
+
if (input.has("baudrate2"))
|
|
1819
|
+
result.baudrate2 = input.getString("baudrate2");
|
|
1820
|
+
if (input.has("uID"))
|
|
1821
|
+
result.uID = input.getString("uID");
|
|
1822
|
+
return result;
|
|
1823
|
+
} catch (JSONException e) {
|
|
1824
|
+
e.printStackTrace();
|
|
1825
|
+
}
|
|
1826
|
+
return null;
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
static RFIDSessionData RFIDSessionDataFromJSON(JSONObject input) {
|
|
1830
|
+
try {
|
|
1831
|
+
RFIDSessionData result = new RFIDSessionData();
|
|
1832
|
+
if (input.has("totalBytesReceived"))
|
|
1833
|
+
result.totalBytesReceived = input.getInt("totalBytesReceived");
|
|
1834
|
+
if (input.has("totalBytesSent"))
|
|
1835
|
+
result.totalBytesSent = input.getInt("totalBytesSent");
|
|
1836
|
+
if (input.has("status"))
|
|
1837
|
+
result.status = input.getInt("status");
|
|
1838
|
+
if (input.has("extLeSupport"))
|
|
1839
|
+
result.extLeSupport = input.getInt("extLeSupport");
|
|
1840
|
+
if (input.has("processTime"))
|
|
1841
|
+
result.processTime = input.getInt("processTime");
|
|
1842
|
+
if (input.has("cardProperties"))
|
|
1843
|
+
result.cardProperties = CardPropertiesFromJSON(input.getJSONObject("cardProperties"));
|
|
1844
|
+
if (input.has("sessionDataStatus"))
|
|
1845
|
+
result.sessionDataStatus = RFIDSessionDataStatusFromJSON(input.getJSONObject("sessionDataStatus"));
|
|
1846
|
+
if (input.has("accessControls")){
|
|
1847
|
+
JSONArray jsonArray_accessControls = input.getJSONArray("accessControls");
|
|
1848
|
+
List<AccessControlProcedureType> accessControls = new ArrayList<>();
|
|
1849
|
+
for (int i = 0; i < jsonArray_accessControls.length(); i++)
|
|
1850
|
+
accessControls.add(AccessControlProcedureTypeFromJSON(jsonArray_accessControls.getJSONObject(i)));
|
|
1851
|
+
result.accessControls = accessControls;
|
|
1852
|
+
}
|
|
1853
|
+
if (input.has("applications")){
|
|
1854
|
+
JSONArray jsonArray_applications = input.getJSONArray("applications");
|
|
1855
|
+
List<Application> applications = new ArrayList<>();
|
|
1856
|
+
for (int i = 0; i < jsonArray_applications.length(); i++)
|
|
1857
|
+
applications.add(ApplicationFromJSON(jsonArray_applications.getJSONObject(i)));
|
|
1858
|
+
result.applications = applications;
|
|
1859
|
+
}
|
|
1860
|
+
if (input.has("securityObjects")){
|
|
1861
|
+
JSONArray jsonArray_securityObjects = input.getJSONArray("securityObjects");
|
|
1862
|
+
List<SecurityObject> securityObjects = new ArrayList<>();
|
|
1863
|
+
for (int i = 0; i < jsonArray_securityObjects.length(); i++)
|
|
1864
|
+
securityObjects.add(SecurityObjectFromJSON(jsonArray_securityObjects.getJSONObject(i)));
|
|
1865
|
+
result.securityObjects = securityObjects;
|
|
1866
|
+
}
|
|
1867
|
+
return result;
|
|
1868
|
+
} catch (JSONException e) {
|
|
1869
|
+
e.printStackTrace();
|
|
1870
|
+
}
|
|
1871
|
+
return null;
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
static DocumentReaderAuthenticityCheck DocumentReaderAuthenticityCheckFromJSON(JSONObject input) {
|
|
1875
|
+
try {
|
|
1876
|
+
DocumentReaderAuthenticityCheck result = new DocumentReaderAuthenticityCheck();
|
|
1877
|
+
if (input.has("type"))
|
|
1878
|
+
result.type = input.getInt("type");
|
|
1879
|
+
if (input.has("pageIndex"))
|
|
1880
|
+
result.pageIndex = input.getInt("pageIndex");
|
|
1881
|
+
if (input.has("elements")){
|
|
1882
|
+
JSONArray jsonArray_elements = input.getJSONArray("elements");
|
|
1883
|
+
List<DocumentReaderAuthenticityElement> elements = new ArrayList<>();
|
|
1884
|
+
for (int i = 0; i < jsonArray_elements.length(); i++)
|
|
1885
|
+
elements.add(DocumentReaderAuthenticityElementFromJSON(jsonArray_elements.getJSONObject(i)));
|
|
1886
|
+
result.elements = elements;
|
|
1887
|
+
}
|
|
1888
|
+
return result;
|
|
1889
|
+
} catch (JSONException e) {
|
|
1890
|
+
e.printStackTrace();
|
|
1891
|
+
}
|
|
1892
|
+
return null;
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
static PDF417Info PDF417InfoFromJSON(JSONObject input) {
|
|
1896
|
+
try {
|
|
1897
|
+
PDF417Info result = new PDF417Info();
|
|
1898
|
+
if (input.has("errorLevel"))
|
|
1899
|
+
result.errorLevel = input.getInt("errorLevel");
|
|
1900
|
+
if (input.has("columns"))
|
|
1901
|
+
result.columns = input.getInt("columns");
|
|
1902
|
+
if (input.has("rows"))
|
|
1903
|
+
result.rows = input.getInt("rows");
|
|
1904
|
+
return result;
|
|
1905
|
+
} catch (JSONException e) {
|
|
1906
|
+
e.printStackTrace();
|
|
1907
|
+
}
|
|
1908
|
+
return null;
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
static RFIDSessionDataStatus RFIDSessionDataStatusFromJSON(JSONObject input) {
|
|
1912
|
+
try {
|
|
1913
|
+
RFIDSessionDataStatus result = new RFIDSessionDataStatus();
|
|
1914
|
+
if (input.has("AA"))
|
|
1915
|
+
result.AA = input.getInt("AA");
|
|
1916
|
+
if (input.has("BAC"))
|
|
1917
|
+
result.BAC = input.getInt("BAC");
|
|
1918
|
+
if (input.has("CA"))
|
|
1919
|
+
result.CA = input.getInt("CA");
|
|
1920
|
+
if (input.has("PA"))
|
|
1921
|
+
result.PA = input.getInt("PA");
|
|
1922
|
+
if (input.has("PACE"))
|
|
1923
|
+
result.PACE = input.getInt("PACE");
|
|
1924
|
+
if (input.has("TA"))
|
|
1925
|
+
result.TA = input.getInt("TA");
|
|
1926
|
+
if (input.has("overallStatus"))
|
|
1927
|
+
result.overallStatus = input.getInt("overallStatus");
|
|
1928
|
+
return result;
|
|
1929
|
+
} catch (JSONException e) {
|
|
1930
|
+
e.printStackTrace();
|
|
1931
|
+
}
|
|
1932
|
+
return null;
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1935
|
+
static DocumentReaderBarcodeResult DocumentReaderBarcodeResultFromJSON(JSONObject input) {
|
|
1936
|
+
try {
|
|
1937
|
+
DocumentReaderBarcodeResult result = new DocumentReaderBarcodeResult();
|
|
1938
|
+
if (input.has("fields")){
|
|
1939
|
+
JSONArray jsonArray_fields = input.getJSONArray("fields");
|
|
1940
|
+
List<DocumentReaderBarcodeField> fields = new ArrayList<>();
|
|
1941
|
+
for (int i = 0; i < jsonArray_fields.length(); i++)
|
|
1942
|
+
fields.add(DocumentReaderBarcodeFieldFromJSON(jsonArray_fields.getJSONObject(i)));
|
|
1943
|
+
result.fields = fields;
|
|
1944
|
+
}
|
|
1945
|
+
return result;
|
|
1946
|
+
} catch (JSONException e) {
|
|
1947
|
+
e.printStackTrace();
|
|
1948
|
+
}
|
|
1949
|
+
return null;
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
static DocumentReaderBarcodeField DocumentReaderBarcodeFieldFromJSON(JSONObject input) {
|
|
1953
|
+
try {
|
|
1954
|
+
DocumentReaderBarcodeField result = new DocumentReaderBarcodeField();
|
|
1955
|
+
if (input.has("barcodeType"))
|
|
1956
|
+
result.barcodeType = input.getInt("barcodeType");
|
|
1957
|
+
if (input.has("status"))
|
|
1958
|
+
result.status = input.getInt("status");
|
|
1959
|
+
if (input.has("pageIndex"))
|
|
1960
|
+
result.pageIndex = input.getInt("pageIndex");
|
|
1961
|
+
if (input.has("pdf417Info"))
|
|
1962
|
+
result.pdf417Info = PDF417InfoFromJSON(input.getJSONObject("pdf417Info"));
|
|
1963
|
+
if (input.has("data")){
|
|
1964
|
+
JSONArray jsonArray_data = input.getJSONArray("data");
|
|
1965
|
+
byte[] data = new byte[jsonArray_data.length()];
|
|
1966
|
+
for (int i = 0; i < jsonArray_data.length(); i++)
|
|
1967
|
+
data[i] = (byte) jsonArray_data.get(i);
|
|
1968
|
+
result.data = data;
|
|
1969
|
+
}
|
|
1970
|
+
return result;
|
|
1971
|
+
} catch (JSONException e) {
|
|
1972
|
+
e.printStackTrace();
|
|
1973
|
+
}
|
|
1974
|
+
return null;
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
static DocumentReaderAuthenticityResult DocumentReaderAuthenticityResultFromJSON(JSONObject input) {
|
|
1978
|
+
try {
|
|
1979
|
+
DocumentReaderAuthenticityResult result = new DocumentReaderAuthenticityResult();
|
|
1980
|
+
if (input.has("checks")){
|
|
1981
|
+
JSONArray jsonArray_checks = input.getJSONArray("checks");
|
|
1982
|
+
List<DocumentReaderAuthenticityCheck> checks = new ArrayList<>();
|
|
1983
|
+
for (int i = 0; i < jsonArray_checks.length(); i++)
|
|
1984
|
+
checks.add(DocumentReaderAuthenticityCheckFromJSON(jsonArray_checks.getJSONObject(i)));
|
|
1985
|
+
result.checks = checks;
|
|
1986
|
+
}
|
|
1987
|
+
return result;
|
|
1988
|
+
} catch (JSONException e) {
|
|
1989
|
+
e.printStackTrace();
|
|
1990
|
+
}
|
|
1991
|
+
return null;
|
|
1992
|
+
}
|
|
1993
|
+
|
|
1994
|
+
static DocumentReaderAuthenticityElement DocumentReaderAuthenticityElementFromJSON(JSONObject input) {
|
|
1995
|
+
try {
|
|
1996
|
+
DocumentReaderAuthenticityElement result = new DocumentReaderAuthenticityElement();
|
|
1997
|
+
if (input.has("status"))
|
|
1998
|
+
result.status = input.getInt("status");
|
|
1999
|
+
if (input.has("elementType"))
|
|
2000
|
+
result.elementType = input.getInt("elementType");
|
|
2001
|
+
if (input.has("elementDiagnose"))
|
|
2002
|
+
result.elementDiagnose = input.getInt("elementDiagnose");
|
|
2003
|
+
return result;
|
|
2004
|
+
} catch (JSONException e) {
|
|
2005
|
+
e.printStackTrace();
|
|
2006
|
+
}
|
|
2007
|
+
return null;
|
|
2008
|
+
}
|
|
2009
|
+
|
|
2010
|
+
static PAResourcesIssuer PAResourcesIssuerFromJSON(JSONObject input) {
|
|
2011
|
+
try {
|
|
2012
|
+
PAResourcesIssuer result = new PAResourcesIssuer();
|
|
2013
|
+
if (input.has("data")){
|
|
2014
|
+
JSONArray jsonArray_data = input.getJSONArray("data");
|
|
2015
|
+
byte[] data = new byte[jsonArray_data.length()];
|
|
2016
|
+
for (int i = 0; i < jsonArray_data.length(); i++)
|
|
2017
|
+
data[i] = (byte) jsonArray_data.get(i);
|
|
2018
|
+
result.data = data;
|
|
2019
|
+
}
|
|
2020
|
+
if (input.has("friendlyName"))
|
|
2021
|
+
result.friendlyName = input.getString("friendlyName");
|
|
2022
|
+
if (input.has("attributes")){
|
|
2023
|
+
JSONArray jsonArray_attributes = input.getJSONArray("attributes");
|
|
2024
|
+
PAAttribute[] attributes = new PAAttribute[jsonArray_attributes.length()];
|
|
2025
|
+
for (int i = 0; i < jsonArray_attributes.length(); i++)
|
|
2026
|
+
attributes[i] = PAAttributeFromJSON(jsonArray_attributes.getJSONObject(i));
|
|
2027
|
+
result.attributes = attributes;
|
|
2028
|
+
}
|
|
2029
|
+
return result;
|
|
2030
|
+
} catch (JSONException e) {
|
|
2031
|
+
e.printStackTrace();
|
|
2032
|
+
}
|
|
2033
|
+
return null;
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
static PAAttribute PAAttributeFromJSON(JSONObject input) {
|
|
2037
|
+
try {
|
|
2038
|
+
PAAttribute result = new PAAttribute();
|
|
2039
|
+
if (input.has("type"))
|
|
2040
|
+
result.type = input.getString("type");
|
|
2041
|
+
if (input.has("value"))
|
|
2042
|
+
result.value = input.getString("value");
|
|
2043
|
+
return result;
|
|
2044
|
+
} catch (JSONException e) {
|
|
2045
|
+
e.printStackTrace();
|
|
2046
|
+
}
|
|
2047
|
+
return null;
|
|
2048
|
+
}
|
|
2049
|
+
|
|
2050
|
+
static TAChallenge TAChallengeFromJSON(JSONObject input) {
|
|
2051
|
+
try {
|
|
2052
|
+
TAChallenge result = new TAChallenge();
|
|
2053
|
+
if (input.has("data")){
|
|
2054
|
+
JSONArray jsonArray_data = input.getJSONArray("data");
|
|
2055
|
+
byte[] data = new byte[jsonArray_data.length()];
|
|
2056
|
+
for (int i = 0; i < jsonArray_data.length(); i++)
|
|
2057
|
+
data[i] = (byte) jsonArray_data.get(i);
|
|
2058
|
+
result.data = data;
|
|
2059
|
+
}
|
|
2060
|
+
if (input.has("auxPCD"))
|
|
2061
|
+
result.auxPCD = input.getString("auxPCD");
|
|
2062
|
+
if (input.has("challengePICC"))
|
|
2063
|
+
result.challengePICC = input.getString("challengePICC");
|
|
2064
|
+
if (input.has("hashPK"))
|
|
2065
|
+
result.hashPK = input.getString("hashPK");
|
|
2066
|
+
if (input.has("idPICC"))
|
|
2067
|
+
result.idPICC = input.getString("idPICC");
|
|
2068
|
+
return result;
|
|
2069
|
+
} catch (JSONException e) {
|
|
2070
|
+
e.printStackTrace();
|
|
2071
|
+
}
|
|
2072
|
+
return null;
|
|
2073
|
+
}
|
|
2074
|
+
|
|
2075
|
+
static DocumentReaderResults DocumentReaderResultsFromJSON(JSONObject input) {
|
|
2076
|
+
try {
|
|
2077
|
+
DocumentReaderResults result = new DocumentReaderResults();
|
|
2078
|
+
if (input.has("chipPage"))
|
|
2079
|
+
result.chipPage = input.getInt("chipPage");
|
|
2080
|
+
if (input.has("processingFinishedStatus"))
|
|
2081
|
+
result.processingFinishedStatus = input.getInt("processingFinishedStatus");
|
|
2082
|
+
if (input.has("elapsedTime"))
|
|
2083
|
+
result.elapsedTime = input.getInt("elapsedTime");
|
|
2084
|
+
if (input.has("elapsedTimeRFID"))
|
|
2085
|
+
result.elapsedTimeRFID = input.getInt("elapsedTimeRFID");
|
|
2086
|
+
if (input.has("morePagesAvailable"))
|
|
2087
|
+
result.morePagesAvailable = input.getInt("morePagesAvailable");
|
|
2088
|
+
if (input.has("rfidResult"))
|
|
2089
|
+
result.rfidResult = input.getInt("rfidResult");
|
|
2090
|
+
if (input.has("highResolution"))
|
|
2091
|
+
result.highResolution = input.getBoolean("highResolution");
|
|
2092
|
+
if (input.has("graphicResult"))
|
|
2093
|
+
result.graphicResult = DocumentReaderGraphicResultFromJSON(input.getJSONObject("graphicResult"));
|
|
2094
|
+
if (input.has("textResult"))
|
|
2095
|
+
result.textResult = DocumentReaderTextResultFromJSON(input.getJSONObject("textResult"));
|
|
2096
|
+
if (input.has("documentPosition")){
|
|
2097
|
+
JSONArray jsonArray_documentPosition = input.getJSONArray("documentPosition");
|
|
2098
|
+
List<ElementPosition> documentPosition = new ArrayList<>();
|
|
2099
|
+
for (int i = 0; i < jsonArray_documentPosition.length(); i++)
|
|
2100
|
+
documentPosition.add(ElementPositionFromJSON(jsonArray_documentPosition.getJSONObject(i)));
|
|
2101
|
+
result.documentPosition = documentPosition;
|
|
2102
|
+
}
|
|
2103
|
+
if (input.has("barcodePosition")){
|
|
2104
|
+
JSONArray jsonArray_barcodePosition = input.getJSONArray("barcodePosition");
|
|
2105
|
+
List<ElementPosition> barcodePosition = new ArrayList<>();
|
|
2106
|
+
for (int i = 0; i < jsonArray_barcodePosition.length(); i++)
|
|
2107
|
+
barcodePosition.add(ElementPositionFromJSON(jsonArray_barcodePosition.getJSONObject(i)));
|
|
2108
|
+
result.barcodePosition = barcodePosition;
|
|
2109
|
+
}
|
|
2110
|
+
if (input.has("mrzPosition")){
|
|
2111
|
+
JSONArray jsonArray_mrzPosition = input.getJSONArray("mrzPosition");
|
|
2112
|
+
List<ElementPosition> mrzPosition = new ArrayList<>();
|
|
2113
|
+
for (int i = 0; i < jsonArray_mrzPosition.length(); i++)
|
|
2114
|
+
mrzPosition.add(ElementPositionFromJSON(jsonArray_mrzPosition.getJSONObject(i)));
|
|
2115
|
+
result.mrzPosition = mrzPosition;
|
|
2116
|
+
}
|
|
2117
|
+
if (input.has("imageQuality")){
|
|
2118
|
+
JSONArray jsonArray_imageQuality = input.getJSONArray("imageQuality");
|
|
2119
|
+
List<ImageQualityGroup> imageQuality = new ArrayList<>();
|
|
2120
|
+
for (int i = 0; i < jsonArray_imageQuality.length(); i++)
|
|
2121
|
+
imageQuality.add(ImageQualityGroupFromJSON(jsonArray_imageQuality.getJSONObject(i)));
|
|
2122
|
+
result.imageQuality = imageQuality;
|
|
2123
|
+
}
|
|
2124
|
+
if (input.has("rawResult"))
|
|
2125
|
+
result.rawResult = input.getString("rawResult");
|
|
2126
|
+
if (input.has("documentReaderNotification"))
|
|
2127
|
+
result.documentReaderNotification = DocumentReaderNotificationFromJSON(input.getJSONObject("documentReaderNotification"));
|
|
2128
|
+
if (input.has("rfidSessionData"))
|
|
2129
|
+
result.rfidSessionData = RFIDSessionDataFromJSON(input.getJSONObject("rfidSessionData"));
|
|
2130
|
+
if (input.has("authenticityResult"))
|
|
2131
|
+
result.authenticityResult = DocumentReaderAuthenticityResultFromJSON(input.getJSONObject("authenticityResult"));
|
|
2132
|
+
if (input.has("barcodeResult"))
|
|
2133
|
+
result.barcodeResult = DocumentReaderBarcodeResultFromJSON(input.getJSONObject("barcodeResult"));
|
|
2134
|
+
if (input.has("documentType")){
|
|
2135
|
+
JSONArray jsonArray_documentType = input.getJSONArray("documentType");
|
|
2136
|
+
List<DocumentReaderDocumentType> documentType = new ArrayList<>();
|
|
2137
|
+
for (int i = 0; i < jsonArray_documentType.length(); i++)
|
|
2138
|
+
documentType.add(DocumentReaderDocumentTypeFromJSON(jsonArray_documentType.getJSONObject(i)));
|
|
2139
|
+
result.documentType = documentType;
|
|
2140
|
+
}
|
|
2141
|
+
return result;
|
|
2142
|
+
} catch (JSONException e) {
|
|
2143
|
+
e.printStackTrace();
|
|
2144
|
+
}
|
|
2145
|
+
return null;
|
|
823
2146
|
}
|
|
824
2147
|
}
|