From: Eugene Crosser Date: Fri, 10 May 2013 13:59:39 +0000 (+0400) Subject: return early if cannot init adapter X-Git-Url: http://www.average.org/gitweb/?p=YkNeoCR.git;a=commitdiff_plain return early if cannot init adapter --- diff --git a/res/values/strings.xml b/res/values/strings.xml index 83cb008..15432f6 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -2,23 +2,21 @@ YkNeo CR

Challenge-Response Provider

using Yubico\'s Yubikey Neo NFC token

-

-You need to set up a slot in the Neo to use with CHAL-HMAC +This application does not do anything itself, it provides a way for other +applications to use the NFC token for encryption and authentication purposes. +

+

+You need to configure one of the slots in the Neo to run in CHAL-HMAC mode, like this:

   ykpersonalize -2 -ochal-resp -ochal-hmac -ohmac-lt64 -oserial-api-visible
 

-This application does not do anything itself, it provides a way for other -applications to use the NFC token for encryption and authentication purposes. -

-

-The slot number used for the above command must be selected below: +The slot number that was used in the above command must be selected below:

]]>
diff --git a/src/org/average/nfcauthcr/NfcCRdispatch.java b/src/org/average/nfcauthcr/NfcCRdispatch.java index d5342f0..3216ef6 100644 --- a/src/org/average/nfcauthcr/NfcCRdispatch.java +++ b/src/org/average/nfcauthcr/NfcCRdispatch.java @@ -55,7 +55,7 @@ public class NfcCRdispatch { return null; } - public void onResume(ArrayList challenge) { + public boolean onResume(ArrayList challenge) { this.challenge = challenge; Intent intent = activity.getIntent(); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); @@ -68,16 +68,17 @@ public class NfcCRdispatch { if (adapter == null) { Toast.makeText(activity, R.string.no_nfc, Toast.LENGTH_LONG).show(); - return; + return false; } if (!adapter.isEnabled()) { Toast.makeText(activity, R.string.nfc_disabled, Toast.LENGTH_LONG).show(); - return; + return false; } adapter.enableForegroundDispatch(activity, tagIntent, new IntentFilter[] {iso}, new String[][] {techs}); + return true; } public void onPause() { diff --git a/src/org/average/nfcauthcr/QueryCrToken.java b/src/org/average/nfcauthcr/QueryCrToken.java index 68a8d0e..f8565c9 100644 --- a/src/org/average/nfcauthcr/QueryCrToken.java +++ b/src/org/average/nfcauthcr/QueryCrToken.java @@ -64,7 +64,10 @@ public class QueryCrToken extends Activity { intent.getStringArrayListExtra("challenge"); intent.putExtra("yubikey_neo_slot", slot); if (challenge != null) { - dispatch.onResume(challenge); + if (!dispatch.onResume(challenge)) { + Log.e(TAG, "Failed to enable fg dispatch"); + finish(); + } } else { Log.e(TAG, "Challenge missing in the Intent"); finish();