Added connection to android scanner; problems with missing crypto providers
parent
291f7d93c0
commit
0dfd2480d2
|
@ -3,6 +3,7 @@ package com.meerkat.laura.fakescannerapp;
|
|||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
@ -35,7 +36,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
SharedPreferences sharedPref;
|
||||
|
||||
Button scanBtn;
|
||||
TextView formatTxt, contentTxt, responseTxt;
|
||||
TextView formatTxt, contentTxt, responseTxt, serverStatus;
|
||||
PollingStationScanner.ScannerClient scannerClient;
|
||||
DigitalSignatureGenerator signer;
|
||||
|
||||
|
@ -63,6 +64,24 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
String pscUrlString = sharedPref.getString(SettingsActivity.PSC_URL, "");
|
||||
|
||||
scannerClient = new ScannerClientAPI(signer);
|
||||
|
||||
serverStatus.setTextColor(Color.BLUE);
|
||||
serverStatus.setText("Connecting to " + pscUrlString);
|
||||
|
||||
PollingStation.ConnectionServerData serverData = PollingStation.ConnectionServerData.newBuilder()
|
||||
.setServerUrl(pscUrlString)
|
||||
.setNonce(0)
|
||||
.build();
|
||||
|
||||
boolean res = scannerClient.connect(serverData);
|
||||
if (res) {
|
||||
serverStatus.setTextColor(Color.GREEN);
|
||||
serverStatus.setText("Connected to " + pscUrlString);
|
||||
} else {
|
||||
serverStatus.setTextColor(Color.RED);
|
||||
serverStatus.setText("Connection failed: " + pscUrlString);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,6 +102,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
formatTxt = (TextView)findViewById(R.id.scan_format);
|
||||
contentTxt = (TextView)findViewById(R.id.scan_content);
|
||||
responseTxt = (TextView)findViewById(R.id.server_response);
|
||||
serverStatus = (TextView) findViewById(R.id.serverStatus);
|
||||
|
||||
|
||||
signer = new ECDSADeterministicSignature();
|
||||
|
|
|
@ -47,5 +47,12 @@
|
|||
android:textIsSelectable="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="44dp" />
|
||||
<TextView
|
||||
android:text="Not Connected"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/serverStatus"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true" android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentLeft="true" android:layout_alignParentStart="true"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -33,6 +33,8 @@ public final class GlobalCryptoSetup {
|
|||
// For now we just check if the java version is at least 8
|
||||
String[] version = System.getProperty("java.version").split("\\.");
|
||||
int major = Integer.parseInt(version[0]);
|
||||
if (version.length < 2)
|
||||
return false;
|
||||
int minor = Integer.parseInt(version[1]);
|
||||
return ((major > 1) || ((major > 0) && (minor > 7)));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue