[PATCH 0/4] Introducing external NFC devices as storage for tokens
by Petter Arvidsson
Hi (again) everyone,
(As you might have noticed my previous patches got eaten by the mailer
daemon :-) I have now split my patches in to additional commits and I
hope they will be accepted by the system. I also agree with Nathaniel
that they are way easier to follow now as well. For convenience I also
include the original cover letter below.)
My name is Petter and I am working for the Swedish company Fidesm
AB. We are building a platform for managing Secure Elements (such as
NFC cards) via the network. One of the first services that can be
deliverd via our platform is an OTP application developed by Yubico
(https://github.com/Yubico/ykneo-oath). To enable us to use this
application to store our OTP credentials we wanted to integrate it
into a good OTP Android App. This patch enables any supported external
NFC token to be used with FreeOTP. Currently the only two tokens using
ths protocol that we know of are the Fidesmo Card and the Yubico
Yubikey. I am more than willing to add support for any other device
which is using the same protocol.
The strategy taken to integrate this into FreeOTP was first to
generalize the TokenPersistence and Token classes to accomodate both
internal and external tokens. This is the first commit/patch. On top
of this the NFC functionality was built. To manage the NFC tag
efficiently (i.e. not to have the user tap it more than neccessary),
we decided to handle it only in the main activity. This required the
other activities to return their results rather than manage the
TokenPersistence directly. This is a very common pattern in Android
and we believe that end result was actually quite nice, clearly
separating managing the tokens from the other activities.
If you want to try it out you will require an external NFC
token. Please let me know if you want a Fidesmo Card and I can provide
instructions on how to get one for free. As earlier stated it can also
be tested with a Yubikey from Yubico.
I hope you like the implementation and that you have some good feedack
for me on what needs to be changed and improved!
Please beware that I am a bit new to git send-email, so let me know if
you want any changes to how the patches were generated.
Best regards,
Petter
Petter Arvidsson (4):
Change Token to Internal token
Add interfaces for Token and TokenPersistence
Add External tokens
Extend app to utilize new external tokens
app/build.gradle | 6 +
app/src/main/AndroidManifest.xml | 9 +-
.../freeotp/BaseReorderableAdapter.java | 97 ++++---
.../fedorahosted/freeotp/ExternalMainActivity.java | 142 +++++++++
.../org/fedorahosted/freeotp/ExternalToken.java | 130 +++++++++
.../freeotp/ExternalTokenPersistence.java | 129 +++++++++
.../fedorahosted/freeotp/InternalMainActivity.java | 126 ++++++++
.../org/fedorahosted/freeotp/InternalToken.java | 318 +++++++++++++++++++++
.../freeotp/InternalTokenPersistence.java | 140 +++++++++
.../org/fedorahosted/freeotp/MainActivity.java | 83 +++---
.../java/org/fedorahosted/freeotp/NfcHelpers.java | 60 ++++
.../main/java/org/fedorahosted/freeotp/Token.java | 277 +-----------------
.../org/fedorahosted/freeotp/TokenAdapter.java | 62 ++--
.../org/fedorahosted/freeotp/TokenPersistence.java | 131 ++-------
.../org/fedorahosted/freeotp/add/AddActivity.java | 10 +-
.../org/fedorahosted/freeotp/add/BaseActivity.java | 7 +
.../org/fedorahosted/freeotp/add/ScanActivity.java | 23 +-
.../fedorahosted/freeotp/edit/BaseActivity.java | 22 --
.../fedorahosted/freeotp/edit/DeleteActivity.java | 19 +-
.../fedorahosted/freeotp/edit/EditActivity.java | 46 +--
app/src/main/res/layout/main.xml | 4 +-
app/src/main/res/menu/editable_token.xml | 33 +++
app/src/main/res/menu/token.xml | 6 -
app/src/main/res/values/strings.xml | 16 +-
24 files changed, 1339 insertions(+), 557 deletions(-)
create mode 100644 app/src/main/java/org/fedorahosted/freeotp/ExternalMainActivity.java
create mode 100644 app/src/main/java/org/fedorahosted/freeotp/ExternalToken.java
create mode 100644 app/src/main/java/org/fedorahosted/freeotp/ExternalTokenPersistence.java
create mode 100644 app/src/main/java/org/fedorahosted/freeotp/InternalMainActivity.java
create mode 100644 app/src/main/java/org/fedorahosted/freeotp/InternalToken.java
create mode 100644 app/src/main/java/org/fedorahosted/freeotp/InternalTokenPersistence.java
create mode 100644 app/src/main/java/org/fedorahosted/freeotp/NfcHelpers.java
create mode 100644 app/src/main/java/org/fedorahosted/freeotp/add/BaseActivity.java
delete mode 100644 app/src/main/java/org/fedorahosted/freeotp/edit/BaseActivity.java
create mode 100644 app/src/main/res/menu/editable_token.xml
--
1.9.1
8 years, 10 months
Turn off automatic clipboard copy of code?
by Peter
Because my devotion to open source, I'm thrilled to have recently
switched to FreeOTP from Google Authenticator.
Being truly open source, FreeOTP appears to be a far better
alternative than Google Authenticator. But I do have one concern: when
I generate a code (on Android 4.4.4.) it not only displays the code
but also copies it to the clipboard. Is it possible to turn off the
copying to clipboard functionality?
The reason I ask is that I recently read this article which I found disturbing:
http://arstechnica.com/security/2014/11/using-a-password-manager-on-andro...
Hence, I'm being very careful with what I copy to my clipboard on my
phone and would love to disable that specific funtion on FreeOTP. Is
that possible?
Or, being new to the app, perhaps I'm doing something wrong and there
is a way for me to view the code without copying it at all?
Any guidance appreciated.
Many thanks,
Peter
8 years, 11 months
[PATCH 2/2] Material design for Lollipop
by zhaofeng@zhaofeng.li
This patch adds Material Design theme for SDK 21+ devices.
Colours in styles.xml are taken from the launcher icon.
---
.../main/java/org/fedorahosted/freeotp/MainActivity.java | 5 +++++
app/src/main/res/values-v21/styles.xml | 14 ++++++++++++++
2 files changed, 19 insertions(+)
create mode 100644 app/src/main/res/values-v21/styles.xml
diff --git a/app/src/main/java/org/fedorahosted/freeotp/MainActivity.java b/app/src/main/java/org/fedorahosted/freeotp/MainActivity.java
index f1cc81b..69a0c08 100644
--- a/app/src/main/java/org/fedorahosted/freeotp/MainActivity.java
+++ b/app/src/main/java/org/fedorahosted/freeotp/MainActivity.java
@@ -44,10 +44,12 @@ import android.content.Intent;
import android.database.DataSetObserver;
import android.net.Uri;
import android.os.Bundle;
+import android.os.Build;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.View;
+import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.GridView;
@@ -78,6 +80,9 @@ public class MainActivity extends Activity implements OnMenuItemClickListener {
}
};
mTokenAdapter.registerDataSetObserver(mDataSetObserver);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Lollipop
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+ }
}
@Override
diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml
new file mode 100644
index 0000000..22960a6
--- /dev/null
+++ b/app/src/main/res/values-v21/styles.xml
@@ -0,0 +1,14 @@
+<resources>
+
+ <!--
+ Base application theme for API 21+. This theme completely replaces
+ AppBaseTheme from BOTH res/values/styles.xml and
+ res/values-v14/styles.xml on API 21+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Material.Light.DarkActionBar">
+ <item name="android:colorPrimary">#1788f5</item>
+ <item name="android:colorPrimaryDark">#1852ef</item>
+ <item name="android:colorAccent">#1852ef</item>
+ </style>
+
+</resources>
--
1.9.1
8 years, 11 months
[PATCH 1/2] Target SDK 21 (Lollipop)
by zhaofeng@zhaofeng.li
---
app/build.gradle | 4 ++--
app/src/main/AndroidManifest.xml | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/build.gradle b/app/build.gradle
index 0faef46..748f7dd 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -7,6 +7,6 @@ dependencies {
}
android {
- compileSdkVersion 19
- buildToolsVersion "20.0.0"
+ compileSdkVersion 21
+ buildToolsVersion "21.1.1"
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index fd6c7a5..0412299 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,7 +26,7 @@
<uses-sdk
android:minSdkVersion="14"
- android:targetSdkVersion="19" />
+ android:targetSdkVersion="21" />
<supports-screens
android:smallScreens="true"
--
1.9.1
8 years, 11 months
[PATCH 1/1] Use storage access framework to select image on kitkat
by Ruben Roy
>From 9cd1ed5b539a2a14a13e19312c669afa2ace73d8 Mon Sep 17 00:00:00 2001
From: Ruben Roy <rubenroy2005(a)gmail.com>
Date: Sat, 22 Nov 2014 01:40:22 +0530
Subject: [PATCH] Use storage access framework to select image on kitkat
---
.../org/fedorahosted/freeotp/add/AddActivity.java | 18 ++++++++++++++--
.../fedorahosted/freeotp/edit/EditActivity.java | 24 ++++++++++++++++++----
2 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/app/src/main/java/org/fedorahosted/freeotp/add/AddActivity.java
b/app/src/main/java/org/fedorahosted/freeotp/add/AddActivity.java
index 6c6d3dd..9cebba7 100644
--- a/app/src/main/java/org/fedorahosted/freeotp/add/AddActivity.java
+++ b/app/src/main/java/org/fedorahosted/freeotp/add/AddActivity.java
@@ -30,6 +30,7 @@ import org.fedorahosted.freeotp.TokenPersistence;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
+import android.os.Build;
import android.os.Bundle;
import android.text.TextWatcher;
import android.view.View;
@@ -92,8 +93,17 @@ public class AddActivity extends Activity
implements View.OnClickListener, Compo
public void onClick(View view) {
switch (view.getId()) {
case R.id.image:
- startActivityForResult(new Intent(Intent.ACTION_PICK,
-
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI), 0);
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+ Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
+ intent.addCategory(Intent.CATEGORY_OPENABLE);
+ intent.setType("image/*");
+ startActivityForResult(intent,0);
+
+ }
+ else {
+ startActivityForResult(new Intent(Intent.ACTION_PICK,
+
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI), 0);
+ }
break;
case R.id.cancel:
@@ -148,6 +158,10 @@ public class AddActivity extends Activity
implements View.OnClickListener, Compo
if (resultCode == RESULT_OK) {
mImageURL = data.getData();
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+ final int takeFlags = data.getFlags() &
Intent.FLAG_GRANT_READ_URI_PERMISSION;
+
getContentResolver().takePersistableUriPermission(mImageURL,
takeFlags);
+ }
Picasso.with(this)
.load(mImageURL)
.placeholder(R.drawable.logo)
diff --git a/app/src/main/java/org/fedorahosted/freeotp/edit/EditActivity.java
b/app/src/main/java/org/fedorahosted/freeotp/edit/EditActivity.java
index 575d1ad..a9550ff 100644
--- a/app/src/main/java/org/fedorahosted/freeotp/edit/EditActivity.java
+++ b/app/src/main/java/org/fedorahosted/freeotp/edit/EditActivity.java
@@ -26,6 +26,7 @@ import org.fedorahosted.freeotp.TokenPersistence;
import android.content.Intent;
import android.net.Uri;
+import android.os.Build;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
@@ -112,8 +113,14 @@ public class EditActivity extends BaseActivity
implements TextWatcher, View.OnCl
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
super.onActivityResult(requestCode, resultCode, data);
- if (resultCode == RESULT_OK)
- showImage(data.getData());
+ if (resultCode == RESULT_OK) {
+ Uri uri = data.getData();
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+ final int takeFlags = data.getFlags() &
Intent.FLAG_GRANT_READ_URI_PERMISSION;
+
getContentResolver().takePersistableUriPermission(uri, takeFlags);
+ }
+ showImage(uri);
+ }
}
@Override
@@ -138,8 +145,17 @@ public class EditActivity extends BaseActivity
implements TextWatcher, View.OnCl
public void onClick(View v) {
switch (v.getId()) {
case R.id.image:
- startActivityForResult(new Intent(Intent.ACTION_PICK,
-
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI), 0);
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+ Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
+ intent.addCategory(Intent.CATEGORY_OPENABLE);
+ intent.setType("image/*");
+ startActivityForResult(intent,0);
+
+ }
+ else {
+ startActivityForResult(new Intent(Intent.ACTION_PICK,
+
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI), 0);
+ }
break;
case R.id.restore:
--
1.9.3
8 years, 12 months