Commit 3e7ef626 authored by Sli's avatar Sli

Merge branch 'new_key_format' into 'master'

New key format + fallback

See merge request !3
parents 64c0825b 693661bd
No preview for this file type
Development
\ No newline at end of file
<component name="ProjectDictionaryState">
<dictionary name="djamel" />
</component>
\ No newline at end of file
......@@ -27,6 +27,22 @@
</value>
</option>
</component>
<component name="ProjectInspectionProfilesVisibleTreeState">
<entry key="Project Default">
<profile-state>
<expanded-state>
<State>
<id />
</State>
</expanded-state>
<selected-state>
<State>
<id>Android</id>
</State>
</selected-state>
</profile-state>
</entry>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
......@@ -43,4 +59,31 @@
<component name="ProjectType">
<option name="id" value="Android" />
</component>
<component name="masterDetails">
<states>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>Android API 23 Platform</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.3436185" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ScopeChooserConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>
\ No newline at end of file
......@@ -84,6 +84,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/19.1.0/jars" />
......@@ -121,5 +122,6 @@
<orderEntry type="library" exported="" name="appcompat-v7-19.1.0" level="project" />
<orderEntry type="library" exported="" name="android-async-http-1.4.9" level="project" />
<orderEntry type="library" exported="" name="1_android-async-http-1.4.9" level="project" />
<orderEntry type="library" exported="" name="android-android-19" level="project" />
</component>
</module>
\ No newline at end of file
......@@ -3,6 +3,8 @@
package="djamelfel.gala" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<application
android:allowBackup="true"
......@@ -12,7 +14,8 @@
android:theme="@style/AppTheme" >
<activity
android:name=".Read_QR_Code"
android:label="@string/app_name">
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation|screenSize">
</activity>
<activity
android:name=".Login"
......
package djamelfel.gala;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
......@@ -35,6 +37,9 @@ public class Login extends ActionBarActivity implements View.OnClickListener {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifi.setWifiEnabled(true); // true or false to activate/deactivate wifi
_ipAddress = (EditText)findViewById(R.id.text_ipAddress);
_portNumber = (EditText)findViewById(R.id.text_port);
Button validateIPAddress = (Button) findViewById(R.id.button_ipAddress);
......
......@@ -129,14 +129,25 @@ 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 nbrPlaceSelect = Integer.parseInt(_nbrPlace.getText().toString());
int nbrPlaceTot = Integer.parseInt(str[2]);
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 (Integer.parseInt(str[2]) < nbrPlaceSelect) {
if (nbrPlaceTot < nbrPlaceSelect) {
display(getString(R.string.nbPlaceOversize), false);
return;
}
......@@ -145,19 +156,23 @@ public class Read_QR_Code extends ActionBarActivity implements View.OnClickListe
while (itr.hasNext()) {
Key_List key = itr.next();
if (key.getId() == Integer.parseInt(str[1])) {
// generate HMAC in hex
String hmac = hmacDigest(str[0]+" "+str[1]+" "+str[2], key.getKey(), "HmacSHA1");
if (key.getId() == idTicket) {
// 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(str[3].equals(hmac.substring(0, 8).toUpperCase())) {
if(keyTicket.toUpperCase().equals(hmac.substring(0, 8).toUpperCase())) {
// Ticket is valid
idFound = true;
if (key.getIs_child()) {
showChildDialog(Read_QR_Code.this, str[3], nbrPlaceTot, nbrPlaceSelect);
showChildDialog(Read_QR_Code.this, keyTicket, nbrPlaceTot, nbrPlaceSelect);
}
else {
sendRequest(str[3], nbrPlaceTot, nbrPlaceSelect);
sendRequest(keyTicket, nbrPlaceTot, nbrPlaceSelect);
}
}
}
......
......@@ -69,4 +69,13 @@
android:layout_alignParentRight="true"
android:layout_alignParentEnd="false"
android:layout_below="@+id/text_port"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/BackGroundImageView"
android:layout_marginTop="15dp"
android:id="@+id/imageView"
android:layout_below="@+id/button_ipAddress"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
\ No newline at end of file
......@@ -84,4 +84,13 @@
>
</Button>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/BackGroundImageView"
android:layout_marginTop="15dp"
android:id="@+id/imageView"
android:layout_below="@+id/Scanner"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
\ No newline at end of file
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light" />
<style name="BackGroundImageView">
<item name="android:alpha">0.5</item>
<item name="android:scaleType">fitXY</item>
<item name="android:src">@drawable/background</item>
</style>
</resources>
......@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.android.tools.build:gradle:2.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
......
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