-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCore.cs
More file actions
522 lines (508 loc) · 12.5 KB
/
Copy pathCore.cs
File metadata and controls
522 lines (508 loc) · 12.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
using System;
using System.Collections;
using System.Net;
using System.Net.Sockets;
using System.Text;
namespace MorphoAccessDateTimeSync
{
public class Core
{
public ArrayList ErrorValue(byte e)
{
ArrayList arrayList = new ArrayList();
if (e != 0)
{
switch (e)
{
case 157:
arrayList.Add(99);
arrayList.Add("The application is not yet implemented");
return arrayList;
case 188:
arrayList.Add(68);
arrayList.Add("OSM is locked");
return arrayList;
case 189:
arrayList.Add(67);
arrayList.Add("After 10 failed IDs, the OtpGenerate request is locked.");
return arrayList;
case 190:
arrayList.Add(66);
arrayList.Add("After 5 failed enrollments or 5 failed logins, the user enrollment request is locked.");
return arrayList;
case 191:
arrayList.Add(65);
arrayList.Add("After 5 false pin presentations, the OtpSetParameters request is locked.");
return arrayList;
case 196:
arrayList.Add(60);
arrayList.Add("No response from the biometric sensor");
return arrayList;
case 209:
arrayList.Add(47);
arrayList.Add("");
return arrayList;
case 210:
arrayList.Add(46);
arrayList.Add("Pin needed for the first enrolment");
return arrayList;
case 211:
arrayList.Add(45);
arrayList.Add("Identification failed (Status is invalid unless DB error)");
return arrayList;
case 212:
arrayList.Add(44);
arrayList.Add("enrolment failed");
return arrayList;
case 213:
arrayList.Add(43);
arrayList.Add("Re-enrollment not allowed");
return arrayList;
case 214:
arrayList.Add(42);
arrayList.Add("No Hit (or latent or FFD)");
return arrayList;
case 215:
arrayList.Add(41);
arrayList.Add("OTP database is empty: you have to register");
return arrayList;
case 216:
arrayList.Add(40);
arrayList.Add("OTP plus number (sequence number = 0)");
return arrayList;
case 217:
arrayList.Add(39);
arrayList.Add("Not all OTP settings are initialized");
return arrayList;
case 218:
arrayList.Add(38);
arrayList.Add("The finger may be too wet or the scanner is wet");
return arrayList;
case 219:
arrayList.Add(37);
arrayList.Add("Fingerprint detected is false");
return arrayList;
case 221:
arrayList.Add(35);
arrayList.Add("Mutual authentication error");
return arrayList;
case 222:
arrayList.Add(34);
arrayList.Add("Cryptographic error");
return arrayList;
case 223:
arrayList.Add(33);
arrayList.Add("Error while decoding an ASN1 object");
return arrayList;
case 224:
arrayList.Add(32);
arrayList.Add("An anti-error system has occurred Replay");
return arrayList;
case 225:
arrayList.Add(31);
arrayList.Add("The security status is invalid");
return arrayList;
case 226:
arrayList.Add(30);
arrayList.Add("The required certificate does not exist");
return arrayList;
case 227:
arrayList.Add(29);
arrayList.Add("Fingers presented do not match");
return arrayList;
case 228:
arrayList.Add(28);
arrayList.Add("There are two models of the same finger");
return arrayList;
case 229:
arrayList.Add(27);
arrayList.Add("La commande a été annulée");
return arrayList;
case 230:
arrayList.Add(26);
arrayList.Add("L'Identifiant utilisateur requis n'a pas été trouvé dans la base");
return arrayList;
case 231:
arrayList.Add(25);
arrayList.Add("Clés de sécurité ne peut être changé");
return arrayList;
case 232:
arrayList.Add(24);
arrayList.Add("Longuer ou nom du Champ est invalide");
return arrayList;
case 233:
arrayList.Add(23);
arrayList.Add("Champ introuvable");
return arrayList;
case 234:
arrayList.Add(22);
arrayList.Add("Pointeuse ne peut pas être accordée à cause du temps, accorder avec le fuseau horaire");
return arrayList;
case 235:
arrayList.Add(21);
arrayList.Add("Le nombre des champs additionnels est supérieur à 8");
return arrayList;
case 236:
arrayList.Add(20);
arrayList.Add("Une erreur s'est produite durant la configuration des paramétres réseau TCPIP");
return arrayList;
case 237:
arrayList.Add(19);
arrayList.Add("Une erreur s'est produite durant la configuration du Wiegand/Dataclock");
return arrayList;
case 238:
arrayList.Add(18);
arrayList.Add("Une erreur s'est produite durant la configuration du Serial Link");
return arrayList;
case 239:
arrayList.Add(17);
arrayList.Add("Une erreur s'est produite lors de la lecture de la carte");
return arrayList;
case 240:
arrayList.Add(16);
arrayList.Add("La vérification de la signature a échoué");
return arrayList;
case 241:
arrayList.Add(15);
arrayList.Add("Mode adiminstrateur en utilisation");
return arrayList;
case 242:
arrayList.Add(14);
arrayList.Add("La base de données ne peut être crée, il n’y a plus d’espace mémoire suffisant");
return arrayList;
case 243:
arrayList.Add(13);
arrayList.Add("Type flash invalide");
return arrayList;
case 244:
arrayList.Add(12);
arrayList.Add("Une autre commande est en cours d'exécution");
return arrayList;
case 245:
arrayList.Add(11);
arrayList.Add("Une opération biométrique en cours, réessayer plus tard");
return arrayList;
case 246:
arrayList.Add(10);
arrayList.Add("L’identifiant de la base de données est erroné, cette base existe déjà");
return arrayList;
case 247:
arrayList.Add(9);
arrayList.Add("Base introuvable");
return arrayList;
case 248:
arrayList.Add(8);
arrayList.Add("Empreinte existe déjà");
return arrayList;
case 249:
arrayList.Add(7);
arrayList.Add("The protocol used is not valid");
return arrayList;
case 250:
arrayList.Add(6);
arrayList.Add("Le temps de détection de doigt est expiré sans aucune réponse");
return arrayList;
case 251:
arrayList.Add(5);
arrayList.Add("Mauvais identificateur ou longueur non valide");
return arrayList;
case 252:
arrayList.Add(4);
arrayList.Add("Matricule invalide");
return arrayList;
case 253:
arrayList.Add(3);
arrayList.Add("Empreinte n'est pas valide");
return arrayList;
case 254:
arrayList.Add(2);
arrayList.Add("The parameters given are incorrect");
return arrayList;
case 255:
arrayList.Add(1);
arrayList.Add("An error occurred during the execution of the function");
return arrayList;
}
arrayList.Add(0);
arrayList.Add("Success of the operation ");
}
else
{
arrayList.Add(0);
arrayList.Add("The terminal responds correctly");
}
return arrayList;
}
public ArrayList StatusValue(byte e)
{
ArrayList arrayList = new ArrayList();
switch (e)
{
case 0:
arrayList.Add(0);
arrayList.Add("Successful enrollment");
break;
case 1:
arrayList.Add(1);
arrayList.Add("Login");
break;
case 2:
arrayList.Add(2);
arrayList.Add("Closing a session");
break;
default:
arrayList.Add(1000000000000L);
arrayList.Add("an error has occurred...");
break;
}
return arrayList;
}
public ArrayList TypeAction(byte e)
{
ArrayList arrayList = new ArrayList();
switch (e)
{
case 1:
break;
case 2:
break;
default:
if (e != 48)
{
arrayList.Add(1000000000000L);
arrayList.Add("Errorfffff");
}
else
{
arrayList.Add("Identification");
}
break;
}
return arrayList;
}
public int calculEntier(int d, int f, byte[] ms)
{
byte[] value = new byte[0];
byte[] array = new byte[f - d];
int num = 0;
int num2 = ms.Length;
int result;
if (num2 > d)
{
for (int i = f - 1; i > d - 1; i--)
{
array[num] = ms[i];
num++;
}
value = array;
string text = BitConverter.ToString(value);
for (int num3 = text.IndexOf("-"); num3 != -1; num3 = text.IndexOf("-"))
{
text = text.Remove(num3, 1);
}
result = Convert.ToInt32(text, 16);
}
else
{
result = -1;
}
return result;
}
public int calculEntierLog(int d, int f, byte[] ms)
{
byte[] value = new byte[0];
byte[] array = new byte[f - d];
int num = 0;
int num2 = ms.Length;
int result;
if (num2 > d)
{
for (int i = d; i < f; i++)
{
array[num] = ms[i];
num++;
}
value = array;
string text = BitConverter.ToString(value);
for (int num3 = text.IndexOf("-"); num3 != -1; num3 = text.IndexOf("-"))
{
text = text.Remove(num3, 1);
}
result = Convert.ToInt32(text, 16);
}
else
{
result = -1;
}
return result;
}
public string calculString(int d, int f, byte[] ms)
{
byte[] bytes = new byte[0];
byte[] array = new byte[f - d];
int num = 0;
int num2 = ms.Length;
if (num2 > d)
{
for (int i = d; i < f; i++)
{
array[num] = ms[i];
num++;
}
bytes = array;
}
return Encoding.ASCII.GetString(bytes);
}
public string calculStr(int d, int f, byte[] ms)
{
byte[] value = new byte[0];
byte[] array = new byte[f - d];
int num = 0;
int num2 = ms.Length;
if (num2 > d)
{
for (int i = d; i < f; i++)
{
array[num] = ms[i];
num++;
}
value = array;
}
return BitConverter.ToString(value);
}
public byte[] SocketSendReceive(byte[] requete, string ip)
{
try
{
this.ConnectSocket(ip);
}
catch
{
this.erreur = 2;
}
try
{
this.ClientSocket.Send(requete, requete.Length, SocketFlags.None);
}
catch
{
this.stop();
}
return this.ReceiveData();
}
private void ConnectSocket(string Ip)
{
int port = 11010;
IPAddress address = IPAddress.Parse(Ip);
IPEndPoint remoteEP = new IPEndPoint(address, port);
this.ClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
try
{
this.ClientSocket.Connect(remoteEP);
if (this.ClientSocket.Connected)
{
this.Bouclage = true;
this.erreur = 1;
}
}
catch
{
this.erreur = 2;
}
}
public byte[] ReceiveData()
{
byte[] array = new byte[0];
try
{
while (this.Bouclage)
{
if (this.ClientSocket.Connected)
{
if (this.ClientSocket.Poll(10, SelectMode.SelectRead) && this.ClientSocket.Available == 0)
{
this.stop();
}
if (this.ClientSocket.Available > 0)
{
while (this.ClientSocket.Available > 0)
{
try
{
byte[] array2 = new byte[this.ClientSocket.Available];
this.ClientSocket.Receive(array2, array2.Length, SocketFlags.None);
byte[] array3 = new byte[array.Length + array2.Length];
array.CopyTo(array3, 0);
array2.CopyTo(array3, array.Length);
array = array3;
}
catch
{
this.stop();
}
}
}
}
}
}
catch
{
this.stop();
}
return array;
}
public void stop()
{
try
{
this.Bouclage = false;
if (this.ClientSocket != null)
{
while (this.ClientSocket.Connected)
{
this.ClientSocket.Shutdown(SocketShutdown.Both);
this.ClientSocket.Close();
}
}
this.erreur = 2;
}
catch
{
this.erreur = 6;
}
}
public ArrayList Error()
{
ArrayList arrayList = new ArrayList();
switch (this.erreur)
{
case 1:
arrayList.Add(-1);
arrayList.Add("connected, all is well");
return arrayList;
case 2:
arrayList.Add(-2);
arrayList.Add("Connection failure ");
return arrayList;
case 3:
arrayList.Add(-3);
arrayList.Add("Failure to transmit data");
return arrayList;
case 4:
arrayList.Add(-4);
arrayList.Add(">> operation in progress please wait");
return arrayList;
case 6:
arrayList.Add(-6);
arrayList.Add("an error has occurred");
return arrayList;
}
arrayList.Add(-5);
arrayList.Add("Connection failure");
return arrayList;
}
private bool Bouclage = false;
private int erreur;
private Socket ClientSocket = null;
}
}