Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
futurae-public
futurae-android-sdk
Commits
a8101b7f
Commit
a8101b7f
authored
Nov 18, 2020
by
Claudio Marforio
Browse files
Update SDK to version 1.2.0, which adds offline QR Code functionality. Update Demo App and README
parent
7f111082
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
FuturaeDemo/app/build.gradle
View file @
a8101b7f
...
@@ -48,7 +48,7 @@ dependencies {
...
@@ -48,7 +48,7 @@ dependencies {
implementation
'com.google.firebase:firebase-core:16.0.7'
implementation
'com.google.firebase:firebase-core:16.0.7'
implementation
'com.google.firebase:firebase-messaging:17.4.0'
implementation
'com.google.firebase:firebase-messaging:17.4.0'
implementation
(
'com.futurae.sdk:futuraekit:1.
1.1
'
)
implementation
(
'com.futurae.sdk:futuraekit:1.
2.0
'
)
// Use these if you are NOT using Maven
// Use these if you are NOT using Maven
// implementation 'com.squareup.retrofit2:retrofit:2.4.0'
// implementation 'com.squareup.retrofit2:retrofit:2.4.0'
...
...
FuturaeDemo/app/src/main/java/com/futurae/futuraedemo/ui/FTRQRCodeActivity.java
View file @
a8101b7f
...
@@ -50,6 +50,8 @@ public class FTRQRCodeActivity extends AppCompatActivity implements QRCapturable
...
@@ -50,6 +50,8 @@ public class FTRQRCodeActivity extends AppCompatActivity implements QRCapturable
public
static
final
int
RESULT_BARCODE
=
10000
;
public
static
final
int
RESULT_BARCODE
=
10000
;
public
static
final
int
RESULT_BARCODE_AUTH
=
20000
;
public
static
final
int
RESULT_BARCODE_AUTH
=
20000
;
public
static
final
int
RESULT_BARCODE_OFFLINE
=
30000
;
public
static
final
int
RESULT_BARCODE_GENERIC
=
40000
;
public
static
final
String
PARAM_BARCODE
=
"ftr_barcode"
;
public
static
final
String
PARAM_BARCODE
=
"ftr_barcode"
;
public
static
final
String
PARAM_AUTOFOCUS
=
"ftr_autofocus"
;
public
static
final
String
PARAM_AUTOFOCUS
=
"ftr_autofocus"
;
...
...
FuturaeDemo/app/src/main/java/com/futurae/futuraedemo/ui/MainActivity.java
View file @
a8101b7f
...
@@ -22,6 +22,7 @@ import com.futurae.futuraedemo.R;
...
@@ -22,6 +22,7 @@ import com.futurae.futuraedemo.R;
import
com.futurae.sdk.FuturaeCallback
;
import
com.futurae.sdk.FuturaeCallback
;
import
com.futurae.sdk.FuturaeClient
;
import
com.futurae.sdk.FuturaeClient
;
import
com.futurae.sdk.FuturaeResultCallback
;
import
com.futurae.sdk.FuturaeResultCallback
;
import
com.futurae.sdk.MalformedQRCodeException
;
import
com.futurae.sdk.approve.ApproveSession
;
import
com.futurae.sdk.approve.ApproveSession
;
import
com.futurae.sdk.model.Account
;
import
com.futurae.sdk.model.Account
;
import
com.futurae.sdk.model.ApproveInfo
;
import
com.futurae.sdk.model.ApproveInfo
;
...
@@ -55,6 +56,12 @@ public class MainActivity extends AppCompatActivity {
...
@@ -55,6 +56,12 @@ public class MainActivity extends AppCompatActivity {
case
FTRQRCodeActivity
.
RESULT_BARCODE_AUTH
:
case
FTRQRCodeActivity
.
RESULT_BARCODE_AUTH
:
onAuthQRCodeScanned
(
data
);
onAuthQRCodeScanned
(
data
);
break
;
break
;
case
FTRQRCodeActivity
.
RESULT_BARCODE_OFFLINE
:
onOfflineAuthQRCodeScanned
(
data
);
break
;
case
FTRQRCodeActivity
.
RESULT_BARCODE_GENERIC
:
onQRCodeScanned
(
data
);
break
;
}
}
}
}
}
}
...
@@ -96,17 +103,17 @@ public class MainActivity extends AppCompatActivity {
...
@@ -96,17 +103,17 @@ public class MainActivity extends AppCompatActivity {
String
userId
=
FuturaeClient
.
getUserIdFromUri
(
uriCall
);
String
userId
=
FuturaeClient
.
getUserIdFromUri
(
uriCall
);
String
sessionToken
=
FuturaeClient
.
getSessionTokenFromUri
(
uriCall
);
String
sessionToken
=
FuturaeClient
.
getSessionTokenFromUri
(
uriCall
);
FuturaeClient
.
sharedClient
().
sessionInfoByToken
(
userId
,
sessionToken
,
FuturaeClient
.
sharedClient
().
sessionInfoByToken
(
userId
,
sessionToken
,
new
FuturaeResultCallback
<
SessionInfo
>()
{
new
FuturaeResultCallback
<
SessionInfo
>()
{
@Override
@Override
public
void
success
(
SessionInfo
sessionInfo
)
{
public
void
success
(
SessionInfo
sessionInfo
)
{
showApproveAlertDialog
(
new
ApproveSession
(
sessionInfo
),
true
);
showApproveAlertDialog
(
new
ApproveSession
(
sessionInfo
),
true
);
}
}
@Override
@Override
public
void
failure
(
Throwable
t
)
{
public
void
failure
(
Throwable
t
)
{
Log
.
e
(
TAG
,
"QR Code authentication failed: "
+
t
.
getLocalizedMessage
());
Log
.
e
(
TAG
,
"QR Code authentication failed: "
+
t
.
getLocalizedMessage
());
}
}
});
});
return
;
return
;
}
}
...
@@ -149,13 +156,6 @@ public class MainActivity extends AppCompatActivity {
...
@@ -149,13 +156,6 @@ public class MainActivity extends AppCompatActivity {
});
});
}
}
@OnClick
(
R
.
id
.
main_btn_qr_code_auth
)
protected
void
onQRCodeAuth
()
{
Log
.
i
(
TAG
,
"QR Code factor authentication started"
);
startActivityForResult
(
FTRQRCodeActivity
.
getIntent
(
this
,
true
,
false
),
FTRQRCodeActivity
.
RESULT_BARCODE_AUTH
);
}
@OnClick
(
R
.
id
.
main_btn_totp
)
@OnClick
(
R
.
id
.
main_btn_totp
)
protected
void
onTOTPAuth
()
{
protected
void
onTOTPAuth
()
{
List
<
Account
>
accounts
=
FuturaeClient
.
sharedClient
().
getAccounts
();
List
<
Account
>
accounts
=
FuturaeClient
.
sharedClient
().
getAccounts
();
...
@@ -170,6 +170,26 @@ public class MainActivity extends AppCompatActivity {
...
@@ -170,6 +170,26 @@ public class MainActivity extends AppCompatActivity {
showAlert
(
"TOTP"
,
"Code: "
+
totp
.
getPasscode
()
+
"\nRemaining seconds: "
+
totp
.
getRemainingSecs
());
showAlert
(
"TOTP"
,
"Code: "
+
totp
.
getPasscode
()
+
"\nRemaining seconds: "
+
totp
.
getRemainingSecs
());
}
}
@OnClick
(
R
.
id
.
main_btn_qr_code_auth
)
protected
void
onQRCodeAuth
()
{
Log
.
i
(
TAG
,
"QR Code factor authentication started"
);
startActivityForResult
(
FTRQRCodeActivity
.
getIntent
(
this
,
true
,
false
),
FTRQRCodeActivity
.
RESULT_BARCODE_AUTH
);
}
@OnClick
(
R
.
id
.
main_btn_qr_code_offline_auth
)
protected
void
onOfflineQRCodeAuth
()
{
Log
.
i
(
TAG
,
"Offline QR Code factor authentication started"
);
startActivityForResult
(
FTRQRCodeActivity
.
getIntent
(
this
,
true
,
false
),
FTRQRCodeActivity
.
RESULT_BARCODE_OFFLINE
);
}
@OnClick
(
R
.
id
.
main_btn_qr_code_generic
)
protected
void
onQRCodeGeneric
()
{
Log
.
i
(
TAG
,
"Generic QR Code started"
);
startActivityForResult
(
FTRQRCodeActivity
.
getIntent
(
this
,
true
,
false
),
FTRQRCodeActivity
.
RESULT_BARCODE_GENERIC
);
}
// QRCode callbacks
// QRCode callbacks
private
void
onEnrollQRCodeScanned
(
Intent
data
)
{
private
void
onEnrollQRCodeScanned
(
Intent
data
)
{
// TODO: Handle enrollment response
// TODO: Handle enrollment response
...
@@ -177,38 +197,67 @@ public class MainActivity extends AppCompatActivity {
...
@@ -177,38 +197,67 @@ public class MainActivity extends AppCompatActivity {
Barcode
qrcode
=
data
.
getParcelableExtra
(
FTRQRCodeActivity
.
PARAM_BARCODE
);
Barcode
qrcode
=
data
.
getParcelableExtra
(
FTRQRCodeActivity
.
PARAM_BARCODE
);
Log
.
i
(
TAG
,
"Scanned activation code from the QR code; will enroll device"
);
Log
.
i
(
TAG
,
"Scanned activation code from the QR code; will enroll device"
);
FuturaeClient
.
sharedClient
().
enroll
(
qrcode
.
rawValue
,
FuturaeClient
.
sharedClient
().
enroll
(
qrcode
.
rawValue
,
new
FuturaeCallback
()
{
new
FuturaeCallback
()
{
@Override
@Override
public
void
success
()
{
public
void
success
()
{
Log
.
i
(
TAG
,
"Enrollment successful"
);
Log
.
i
(
TAG
,
"Enrollment successful"
);
showAlert
(
"Success"
,
"Enrollment successful"
);
showAlert
(
"Success"
,
"Enrollment successful"
);
}
}
@Override
@Override
public
void
failure
(
Throwable
throwable
)
{
public
void
failure
(
Throwable
throwable
)
{
Log
.
e
(
TAG
,
"Enrollment failed: "
+
throwable
.
getLocalizedMessage
());
Log
.
e
(
TAG
,
"Enrollment failed: "
+
throwable
.
getLocalizedMessage
());
showAlert
(
"Error"
,
"Enrollment failed"
);
showAlert
(
"Error"
,
"Enrollment failed"
);
}
}
});
});
}
}
private
void
onAuthQRCodeScanned
(
Intent
data
)
{
private
void
onAuthQRCodeScanned
(
Intent
data
)
{
Barcode
qrcode
=
data
.
getParcelableExtra
(
FTRQRCodeActivity
.
PARAM_BARCODE
);
Barcode
qrcode
=
data
.
getParcelableExtra
(
FTRQRCodeActivity
.
PARAM_BARCODE
);
String
userId
=
FuturaeClient
.
getUserIdFromQrcode
(
qrcode
.
rawValue
);
Log
.
i
(
TAG
,
"Scanned online QR Code"
);
String
sessionToken
=
FuturaeClient
.
getSessionTokenFromQrcode
(
qrcode
.
rawValue
);
String
userId
=
null
;
String
sessionToken
=
null
;
try
{
userId
=
FuturaeClient
.
getUserIdFromQrcode
(
qrcode
.
rawValue
);
sessionToken
=
FuturaeClient
.
getSessionTokenFromQrcode
(
qrcode
.
rawValue
);
}
catch
(
MalformedQRCodeException
e
)
{
e
.
printStackTrace
();
return
;
}
FuturaeClient
.
sharedClient
().
sessionInfoByToken
(
userId
,
sessionToken
,
FuturaeClient
.
sharedClient
().
sessionInfoByToken
(
userId
,
sessionToken
,
new
FuturaeResultCallback
<
SessionInfo
>()
{
new
FuturaeResultCallback
<
SessionInfo
>()
{
@Override
@Override
public
void
success
(
SessionInfo
sessionInfo
)
{
public
void
success
(
SessionInfo
sessionInfo
)
{
showApproveAlertDialog
(
new
ApproveSession
(
sessionInfo
),
false
);
showApproveAlertDialog
(
new
ApproveSession
(
sessionInfo
),
false
);
}
}
@Override
@Override
public
void
failure
(
Throwable
t
)
{
public
void
failure
(
Throwable
t
)
{
Log
.
e
(
TAG
,
"QR Code authentication failed: "
+
t
.
getLocalizedMessage
());
Log
.
e
(
TAG
,
"QR Code authentication failed: "
+
t
.
getLocalizedMessage
());
}
}
});
});
}
private
void
onOfflineAuthQRCodeScanned
(
Intent
data
)
{
Barcode
qrcode
=
data
.
getParcelableExtra
(
FTRQRCodeActivity
.
PARAM_BARCODE
);
showOfflineQrcodeDialog
(
qrcode
.
rawValue
);
}
private
void
onQRCodeScanned
(
Intent
data
)
{
Barcode
qrcode
=
data
.
getParcelableExtra
(
FTRQRCodeActivity
.
PARAM_BARCODE
);
Log
.
i
(
TAG
,
"Scanned QR code checking which type it is"
);
switch
(
FuturaeClient
.
getQrcodeType
(
qrcode
.
rawValue
))
{
case
FuturaeClient
.
QR_ENROLL
:
this
.
onEnrollQRCodeScanned
(
data
);
break
;
case
FuturaeClient
.
QR_ONLINE
:
this
.
onAuthQRCodeScanned
(
data
);
break
;
case
FuturaeClient
.
QR_OFFLINE
:
this
.
onOfflineAuthQRCodeScanned
(
data
);
break
;
}
}
}
// Approve dialog
// Approve dialog
...
@@ -269,6 +318,69 @@ public class MainActivity extends AppCompatActivity {
...
@@ -269,6 +318,69 @@ public class MainActivity extends AppCompatActivity {
approveDialog
.
show
();
approveDialog
.
show
();
}
}
void
showOfflineQrcodeSignatureDialog
(
final
String
signature
)
{
// TODO: For demo pusposed, we simply show the signature of the OfflineQRCode
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
"To Approve the transaction, enter: "
+
signature
+
" in the browser"
);
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
this
);
builder
.
setTitle
(
"Confirm Transaction"
);
builder
.
setMessage
(
sb
.
toString
());
builder
.
setPositiveButton
(
"Done"
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
id
)
{
// nothing
}
});
approveDialog
=
builder
.
create
();
approveDialog
.
show
();
}
void
showOfflineQrcodeDialog
(
final
String
qrCode
)
{
// TODO: For demo purposes we simply show an alert
ApproveInfo
[]
extras
=
new
ApproveInfo
[
0
];
try
{
extras
=
FuturaeClient
.
getExtraInfoFromOfflineQrcode
(
qrCode
);
}
catch
(
MalformedQRCodeException
e
)
{
e
.
printStackTrace
();
return
;
}
StringBuffer
sb
=
new
StringBuffer
();
if
(
extras
!=
null
)
{
sb
.
append
(
"\n"
);
for
(
ApproveInfo
info
:
extras
)
{
sb
.
append
(
info
.
getKey
()).
append
(
": "
).
append
(
info
.
getValue
()).
append
(
"\n"
);
}
}
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
this
);
builder
.
setTitle
(
"Approve"
);
builder
.
setMessage
(
"Request Information"
+
sb
.
toString
());
builder
.
setPositiveButton
(
"Approve"
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
id
)
{
String
verificationSignature
=
""
;
try
{
verificationSignature
=
FuturaeClient
.
sharedClient
().
computeVerificationCodeFromQrcode
(
qrCode
);
}
catch
(
MalformedQRCodeException
e
)
{
e
.
printStackTrace
();
}
showOfflineQrcodeSignatureDialog
(
verificationSignature
);
}
});
builder
.
setNegativeButton
(
"Deny"
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
id
)
{
// nothing to do
}
});
approveDialog
=
builder
.
create
();
approveDialog
.
show
();
}
// private
// private
private
void
checkAndAskForPermission
(
final
String
permission
,
final
String
message
,
final
int
requestID
)
{
private
void
checkAndAskForPermission
(
final
String
permission
,
final
String
message
,
final
int
requestID
)
{
final
Activity
activity
=
this
;
final
Activity
activity
=
this
;
...
@@ -353,7 +465,7 @@ public class MainActivity extends AppCompatActivity {
...
@@ -353,7 +465,7 @@ public class MainActivity extends AppCompatActivity {
case
NotificationUtils
.
INTENT_APPROVE_CANCEL_MESSAGE
:
case
NotificationUtils
.
INTENT_APPROVE_CANCEL_MESSAGE
:
if
(
approveDialog
!=
null
&&
approveDialog
.
isShowing
())
{
if
(
approveDialog
!=
null
&&
approveDialog
.
isShowing
())
{
approveDialog
.
dismiss
();
approveDialog
.
dismiss
();
}
}
break
;
break
;
...
...
FuturaeDemo/app/src/main/res/layout/activity_main.xml
View file @
a8101b7f
...
@@ -24,6 +24,14 @@
...
@@ -24,6 +24,14 @@
android:layout_gravity=
"center"
android:layout_gravity=
"center"
android:text=
"@string/main_btn_logout"
/>
android:text=
"@string/main_btn_logout"
/>
<Button
android:id=
"@+id/main_btn_totp"
style=
"@style/AppTheme.Borderless"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:text=
"@string/main_btn_totp"
/>
<Button
<Button
android:id=
"@+id/main_btn_qr_code_auth"
android:id=
"@+id/main_btn_qr_code_auth"
style=
"@style/AppTheme.Borderless"
style=
"@style/AppTheme.Borderless"
...
@@ -34,11 +42,19 @@
...
@@ -34,11 +42,19 @@
/>
/>
<Button
<Button
android:id=
"@+id/main_btn_
totp
"
android:id=
"@+id/main_btn_
qr_code_offline_auth
"
style=
"@style/AppTheme.Borderless"
style=
"@style/AppTheme.Borderless"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_gravity=
"center"
android:text=
"@string/main_btn_totp"
/>
android:text=
"@string/main_btn_qr_code_offline_auth"
/>
<Button
android:id=
"@+id/main_btn_qr_code_generic"
style=
"@style/AppTheme.Borderless"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:text=
"@string/main_btn_qr_code_generic"
/>
</LinearLayout>
</LinearLayout>
FuturaeDemo/app/src/main/res/values/strings.xml
View file @
a8101b7f
...
@@ -4,8 +4,10 @@
...
@@ -4,8 +4,10 @@
<!--MAIN-->
<!--MAIN-->
<string
name=
"main_btn_enroll"
>
Enroll
</string>
<string
name=
"main_btn_enroll"
>
Enroll
</string>
<string
name=
"main_btn_qr_code"
>
Scan to Enroll
</string>
<string
name=
"main_btn_qr_code"
>
Scan to Enroll
</string>
<string
name=
"main_btn_qr_code_auth"
>
QR Code Auth
</string>
<string
name=
"main_btn_totp"
>
TOTP Auth
</string>
<string
name=
"main_btn_totp"
>
TOTP Auth
</string>
<string
name=
"main_btn_qr_code_auth"
>
Online QR Code Auth
</string>
<string
name=
"main_btn_qr_code_offline_auth"
>
Offline QR Code Auth
</string>
<string
name=
"main_btn_qr_code_generic"
>
Scan QR Code
</string>
<!--QR CODE-->
<!--QR CODE-->
<string
name=
"qrcode_title"
>
QR Code
</string>
<string
name=
"qrcode_title"
>
QR Code
</string>
...
...
README.md
View file @
a8101b7f
This diff is collapsed.
Click to expand it.
futuraekit.aar
View file @
a8101b7f
No preview for this file type
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment