Skip to content

Commit

Permalink
Merge pull request #102 from Onegini/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Robert Szuba authored Nov 17, 2017
2 parents 5aaf4bc + dd2b43d commit f665941
Show file tree
Hide file tree
Showing 31 changed files with 432 additions and 110 deletions.
40 changes: 19 additions & 21 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ allprojects {
mavenCentral()
// REQUIRED: Google's new Maven repo is required for the latest
// support library that is compatible with Android 8.0
maven {
url 'https://maven.google.com'
}
google()
if (project.hasProperty('artifactory_user') && project.hasProperty('artifactory_password')) {
maven {
url "https://repo.onegini.com/artifactory/public"
Expand All @@ -43,8 +41,8 @@ allprojects {
}

android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
compileSdkVersion 26
buildToolsVersion '26.0.2'

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -54,9 +52,9 @@ android {
defaultConfig {
applicationId "com.onegini.mobile.exampleapp"
minSdkVersion 16
targetSdkVersion 25
versionCode 10
versionName "4.0.0-BETA"
targetSdkVersion 26
versionCode 11
versionName "4.0.0"
multiDexEnabled true
}
buildTypes {
Expand All @@ -78,33 +76,33 @@ android {

dependencies {
// Onegini SDK
compile('com.onegini.mobile.sdk.android:onegini-sdk:8.0.0-BETA@aar') {
api('com.onegini.mobile.sdk.android:onegini-sdk:8.0.0@aar') {
transitive = true
}

// Rest Client
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
implementation 'com.squareup.retrofit:retrofit:1.9.0'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
// we have to use this wrapper for Retrofit 1 + OkHttp 3 usage
compile 'com.jakewharton.retrofit:retrofit1-okhttp3-client:1.1.0'
implementation 'com.jakewharton.retrofit:retrofit1-okhttp3-client:1.1.0'

// Google Support
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'

// Google Play Services availability check
compile 'com.google.android.gms:play-services-base:11.0.2'
implementation 'com.google.android.gms:play-services-base:11.6.0'
//Firebase Cloud Messaging (FCM)
compile "com.google.firebase:firebase-messaging:11.0.2"
implementation "com.google.firebase:firebase-messaging:11.6.0"
// Support for multidex
compile 'com.android.support:multidex:1.0.1'
implementation 'com.android.support:multidex:1.0.2'
// DI for views
compile 'com.jakewharton:butterknife:8.8.1'
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
// RxJava
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.2.3'
implementation 'io.reactivex:rxandroid:1.2.1'
implementation 'io.reactivex:rxjava:1.2.3'
}

//according to google documentation, this plugin has to be applied at the end of the file
Expand Down
20 changes: 15 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<uses-permission android:name="org.fidoalliance.uaf.permissions.FIDO_CLIENT"/>

<application
android:name="android.support.multidex.MultiDexApplication"
android:name=".ExampleApplication"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand Down Expand Up @@ -62,10 +62,6 @@
android:name=".view.activity.FingerprintActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait"/>
<activity
android:name=".view.activity.MobileAuthenticationFingerprintActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait"/>
<activity
android:name=".view.activity.FidoActivity"
android:screenOrientation="portrait"
Expand All @@ -88,18 +84,32 @@
<activity
android:name=".view.activity.MobileAuthenticationActivity"
android:launchMode="singleTask"
android:taskAffinity=""
android:excludeFromRecents="true"
android:screenOrientation="portrait"/>
<activity
android:name=".view.activity.MobileAuthenticationPinActivity"
android:launchMode="singleTask"
android:taskAffinity=""
android:excludeFromRecents="true"
android:screenOrientation="portrait"/>
<activity
android:name=".view.activity.MobileAuthenticationFingerprintActivity"
android:launchMode="singleTask"
android:taskAffinity=""
android:excludeFromRecents="true"
android:screenOrientation="portrait"/>
<activity
android:name=".view.activity.MobileAuthenticationFidoActivity"
android:launchMode="singleTask"
android:taskAffinity=""
android:excludeFromRecents="true"
android:screenOrientation="portrait"/>
<activity
android:name=".view.activity.MobileAuthenticationCustomActivity"
android:launchMode="singleTask"
android:taskAffinity=""
android:excludeFromRecents="true"
android:screenOrientation="portrait"/>
<activity
android:name=".view.activity.DevicesListActivity"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2016-2017 Onegini B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.onegini.mobile.exampleapp;

import android.support.multidex.MultiDexApplication;
import com.onegini.mobile.exampleapp.view.helper.AppLifecycleListener;

public class ExampleApplication extends MultiDexApplication {

@Override
public void onCreate () {
super.onCreate();
registerActivityLifecycleCallbacks(new AppLifecycleListener());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class OneginiConfigModel implements OneginiClientConfigModel {
private final String appIdentifier = "ExampleApp";
private final String appPlatform = "android";
private final String redirectionUri = "oneginiexample://loginsuccess";
private final String appVersion = "4.0.0-BETA";
private final String appVersion = "4.0.0";
private final String baseURL = "https://demo-msp.onegini.com";
private final String resourceBaseURL = "https://demo-msp.onegini.com/resources";
private final String keystoreHash = "910638c3e6c17ec9ab2a74969abab06b34470d29c21d8ad8a65af243a1ccb69f";
Expand Down Expand Up @@ -75,11 +75,6 @@ public String getDeviceName() {
return Build.BRAND + " " + Build.MODEL;
}

@Override
public boolean shouldGetIdToken() {
return false;
}

@Override
public String toString() {
return "ConfigModel{" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private static OneginiClient buildSDK(final Context context) {
// handlers for optional functionalities
.setFingerprintAuthenticatioRequestHandler(new FingerprintAuthenticationRequestHandler(applicationContext))
.setFidoAuthenticationRequestHandler(new FidoAuthenticationRequestHandler(applicationContext))
.setCustomAuthenticationRequestHandler(new BasicCustomAuthenticationRequestHandler(context))
.setCustomAuthenticationRequestHandler(new BasicCustomAuthenticationRequestHandler(applicationContext))
.setMobileAuthWithPushRequestHandler(new MobileAuthenticationRequestHandler(applicationContext))
.setMobileAuthWithPushPinRequestHandler(new MobileAuthenticationPinRequestHandler(applicationContext))
.setMobileAuthWithPushFingerprintRequestHandler(new MobileAuthenticationFingerprintRequestHandler(applicationContext))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ public OneginiCustomAuthAuthenticationAction getAuthenticationAction() {

@Override
public String getId() {
return "EXPERIMENTAL_CUSTOM_AUTHENTICATOR_ID";
return "EXPERIMENTAL_CA_ID";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2016-2017 Onegini B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.onegini.mobile.exampleapp.model;

import java.util.concurrent.atomic.AtomicInteger;

public class NotificationId {

private static final AtomicInteger integer = new AtomicInteger((int) System.currentTimeMillis());

public static int getId() {
return integer.getAndIncrement();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public class FCMListenerService extends FirebaseMessagingService {

private static final String TAG = FCMListenerService.class.getSimpleName();


@Override
public void onMessageReceived(final RemoteMessage message) {
if (message != null) {
Expand Down Expand Up @@ -113,7 +112,9 @@ private void showToast(final String errorDescription) {

private void removeUserProfiles(final Set<UserProfile> removedUserProfiles, final RemoteMessage extras) {
final DeregistrationUtil deregistrationUtil = new DeregistrationUtil(this);
removedUserProfiles.forEach(deregistrationUtil::onUserDeregistered);
for (UserProfile removedUserProfile : removedUserProfiles) {
deregistrationUtil.onUserDeregistered(removedUserProfile);
}
handleMobileAuthenticationRequest(extras);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright (c) 2016-2017 Onegini B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.onegini.mobile.exampleapp.network.fcm;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.support.v4.app.NotificationCompat;
import com.onegini.mobile.exampleapp.R;
import com.onegini.mobile.exampleapp.model.NotificationId;
import com.onegini.mobile.exampleapp.view.helper.AppLifecycleListener;

public class NotificationHelper {

private static final String CHANNEL_ID = "transactions";

private final Context context;

public NotificationHelper(final Context context) {
this.context = context;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
registerNotificationChannel();
}
}

public void handleIntent(final Intent intent, final String message) {
if (AppLifecycleListener.isAppInForeground()) {
context.startActivity(intent);
} else {
showNotification(intent, message);
}
}

private void showNotification(final Intent intent, final String message) {
final NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("Confirm the transaction")
.setContentText(message)
.setContentIntent(getPendingIntent(intent))
.setPriority(NotificationCompat.PRIORITY_MAX)
.setAutoCancel(true);

getManager().notify(NotificationId.getId(), builder.build());
}

@RequiresApi(api = Build.VERSION_CODES.O)
private void registerNotificationChannel() {
final NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, "Transactions", NotificationManager.IMPORTANCE_HIGH);
notificationChannel.setDescription("Onegini SDK");
notificationChannel.enableLights(true);
notificationChannel.setLightColor(Color.BLUE);
notificationChannel.enableVibration(true);
notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);

getManager().createNotificationChannel(notificationChannel);
}

private NotificationManager getManager() {
return (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
}

private PendingIntent getPendingIntent(final Intent intent) {
return PendingIntent.getActivity(context, 0, intent, 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.onegini.mobile.exampleapp.view.action;

import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;

import android.content.Context;
import android.content.Intent;
import com.onegini.mobile.exampleapp.view.activity.BasicAuthenticatorAuthenticationActivity;
Expand All @@ -37,6 +39,7 @@ public void finishAuthentication(final OneginiCustomAuthAuthenticationCallback c
CALLBACK = callback;

final Intent intent = new Intent(context, BasicAuthenticatorAuthenticationActivity.class);
intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.onegini.mobile.exampleapp.view.action;

import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;

import android.content.Context;
import android.content.Intent;
import com.onegini.mobile.exampleapp.view.activity.BasicAuthenticatorDeregistrationActivity;
Expand All @@ -37,6 +39,7 @@ public void finishDeregistration(final OneginiCustomAuthDeregistrationCallback c
CALLBACK = callback;

final Intent intent = new Intent(context, BasicAuthenticatorDeregistrationActivity.class);
intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.onegini.mobile.exampleapp.view.action;

import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;

import android.content.Context;
import android.content.Intent;
import com.onegini.mobile.exampleapp.view.activity.BasicAuthenticatorRegistrationActivity;
Expand All @@ -37,6 +39,7 @@ public void finishRegistration(final OneginiCustomAuthRegistrationCallback callb
CALLBACK = callback;

final Intent intent = new Intent(context, BasicAuthenticatorRegistrationActivity.class);
intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
}
Loading

0 comments on commit f665941

Please sign in to comment.