Commit 693661bd authored by Sli's avatar Sli

Ajout d'une rétrocompatibilité avec l'ancien format d'eticket

parent 195475c9
......@@ -130,16 +130,24 @@ public class Read_QR_Code extends ActionBarActivity implements View.OnClickListe
public void validateTicket(String result) {
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 nbrPlaceTot = Integer.parseInt(str[3]);
String keyTicket = str[4];
int nbrPlaceTot;
String keyTicket;
Boolean idFound = false;
// For fallback with old format
if (str.length < 5){
keyTicket = str[3];
nbrPlaceTot = Integer.parseInt(str[2]);
} else {
keyTicket = str[4];
nbrPlaceTot = Integer.parseInt(str[3]);
}
// Reset to default number of place
_nbrPlace.setText("1", TextView.BufferType.EDITABLE);
if (nbrPlaceTicket < nbrPlaceSelect) {
if (nbrPlaceTot < nbrPlaceSelect) {
display(getString(R.string.nbPlaceOversize), false);
return;
}
......@@ -149,9 +157,12 @@ public class Read_QR_Code extends ActionBarActivity implements View.OnClickListe
Key_List key = itr.next();
if (key.getId() == idTicket) {
// generate HMAC in hex
String hmac = hmacDigest(str[0]+" "+str[1]+" "+str[2] +" "+str[3], key.getKey(),
"HmacSHA1");
// generate HMAC in hex considering old format (fallback)
String toHmac = str[0]+" "+str[1]+" "+str[2];
if (str.length > 4){
toHmac += " "+str[3];
}
String hmac = hmacDigest(toHmac, key.getKey(), "HmacSHA1");
if(keyTicket.toUpperCase().equals(hmac.substring(0, 8).toUpperCase())) {
// Ticket is valid
......
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