1 package org.average.nfcauthcr;
3 import java.util.ArrayList;
5 import android.os.Bundle;
6 import android.app.Activity;
7 import android.app.AlertDialog;
8 import android.app.PendingIntent;
9 import android.content.DialogInterface;
10 import android.content.Intent;
11 import android.content.IntentFilter;
12 import android.content.SharedPreferences;
13 import android.nfc.NfcAdapter;
14 import android.nfc.Tag;
15 import android.nfc.TagLostException;
16 import android.nfc.tech.IsoDep;
17 import android.preference.PreferenceManager;
18 import android.util.Log;
19 import android.widget.Toast;
21 import org.average.nfcauthcr.NfcCRdispatch;
23 public class QueryCrToken extends Activity {
25 private final String TAG = getClass().getName();
27 private NfcCRdispatch dispatch = new NfcCRdispatch((Activity)this);
28 private SharedPreferences prefs;
31 protected void onCreate(Bundle savedInstanceState) {
32 super.onCreate(savedInstanceState);
33 Log.v(TAG, "onCreate get prefs");
34 prefs = PreferenceManager.getDefaultSharedPreferences(this);
38 protected void onResume() {
40 Log.v(TAG, "Starting the work");
42 new AlertDialog.Builder(this)
43 .setTitle(R.string.challenging)
44 .setMessage(R.string.swipe)
46 new DialogInterface.OnCancelListener() {
47 public void onCancel(DialogInterface dialog) {
54 Intent intent = getIntent();
55 ArrayList<String> challenge =
56 intent.getStringArrayListExtra("challenge");
57 int slot = prefs.getInt("slot_number", -1);
58 intent.putExtra("yubikey_neo_slot", slot);
59 setResult(RESULT_CANCELED);
60 if (challenge != null) {
61 dispatch.onResume(challenge);
63 Log.e(TAG, "Challenge missing in the Intent");
69 protected void onPause() {
71 Log.v(TAG, "Finished the work");
76 public void onNewIntent(Intent newintent) {
77 Log.v(TAG, "NFC Intent arrived");
79 ArrayList<String> response = dispatch.onNewIntent(newintent);
80 if (response != null) {
81 Intent masterintent = getIntent();
82 masterintent.putExtra("response", response);
83 setResult(RESULT_OK, masterintent);