Commit 8223fc1f authored by djamel's avatar djamel

utilise le nouveau format (id client, id produit, id transaction) pour dechiffrer le code billet

parent f662c4dd
...@@ -129,14 +129,17 @@ public class Read_QR_Code extends ActionBarActivity implements View.OnClickListe ...@@ -129,14 +129,17 @@ public class Read_QR_Code extends ActionBarActivity implements View.OnClickListe
public void validateTicket(String result) { public void validateTicket(String result) {
final String str[] = result.split(" "); final String str[] = result.split(" ");
int idTicket = Integer.parseInt(str[1]);
int nbrPlaceTicket = Integer.parseInt(str[2]);
int nbrPlaceSelect = Integer.parseInt(_nbrPlace.getText().toString()); int nbrPlaceSelect = Integer.parseInt(_nbrPlace.getText().toString());
int nbrPlaceTot = Integer.parseInt(str[2]); int nbrPlaceTot = Integer.parseInt(str[3]);
String keyTicket = str[4];
Boolean idFound = false; Boolean idFound = false;
// Reset to default number of place // Reset to default number of place
_nbrPlace.setText("1", TextView.BufferType.EDITABLE); _nbrPlace.setText("1", TextView.BufferType.EDITABLE);
if (Integer.parseInt(str[2]) < nbrPlaceSelect) { if (nbrPlaceTicket < nbrPlaceSelect) {
display(getString(R.string.nbPlaceOversize), false); display(getString(R.string.nbPlaceOversize), false);
return; return;
} }
...@@ -145,19 +148,20 @@ public class Read_QR_Code extends ActionBarActivity implements View.OnClickListe ...@@ -145,19 +148,20 @@ public class Read_QR_Code extends ActionBarActivity implements View.OnClickListe
while (itr.hasNext()) { while (itr.hasNext()) {
Key_List key = itr.next(); Key_List key = itr.next();
if (key.getId() == Integer.parseInt(str[1])) { if (key.getId() == idTicket) {
// generate HMAC in hex // generate HMAC in hex
String hmac = hmacDigest(str[0]+" "+str[1]+" "+str[2], key.getKey(), "HmacSHA1"); String hmac = hmacDigest(str[0]+" "+str[1]+" "+str[2] +" "+str[3], key.getKey(),
"HmacSHA1");
if(str[3].equals(hmac.substring(0, 8).toUpperCase())) { if(keyTicket.equals(hmac.substring(0, 8).toUpperCase())) {
// Ticket is valid // Ticket is valid
idFound = true; idFound = true;
if (key.getIs_child()) { if (key.getIs_child()) {
showChildDialog(Read_QR_Code.this, str[3], nbrPlaceTot, nbrPlaceSelect); showChildDialog(Read_QR_Code.this, keyTicket, nbrPlaceTot, nbrPlaceSelect);
} }
else { else {
sendRequest(str[3], nbrPlaceTot, nbrPlaceSelect); sendRequest(keyTicket, nbrPlaceTot, nbrPlaceSelect);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment