Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #153

Merged
merged 12 commits into from
Jun 26, 2019
26 changes: 14 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ allprojects {
}

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
compileSdkVersion 28
buildToolsVersion '28.0.3'

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -56,9 +56,9 @@ android {
defaultConfig {
applicationId "com.onegini.mobile.exampleapp"
minSdkVersion 16
targetSdkVersion 27
versionCode 16
versionName "5.5.0"
targetSdkVersion 28
versionCode 17
versionName "5.6.0"
multiDexEnabled true
}
buildTypes {
Expand All @@ -80,19 +80,21 @@ android {

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

// Rest Client
implementation 'com.squareup.retrofit2:adapter-rxjava:2.5.0'

// Google Support
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:support-core-ui:27.1.1'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:support-core-ui:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'

// QR code reader
implementation 'com.google.android.gms:play-services-vision:17.0.2'
Expand All @@ -107,7 +109,7 @@ dependencies {
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
// RxJava
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.6'
implementation 'io.reactivex.rxjava2:rxjava:2.2.9'
}

//according to google documentation, this plugin has to be applied at the end of the file
Expand Down
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 = "5.5.0";
private final String appVersion = "5.6.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
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
package com.onegini.mobile.exampleapp.view.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.widget.TextView;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
Expand All @@ -33,12 +33,15 @@
import com.onegini.mobile.exampleapp.storage.UserStorage;
import com.onegini.mobile.exampleapp.util.DeregistrationUtil;
import com.onegini.mobile.sdk.android.client.OneginiClient;
import com.onegini.mobile.sdk.android.handlers.OneginiAppToWebSingleSignOnHandler;
import com.onegini.mobile.sdk.android.handlers.OneginiDeregisterUserProfileHandler;
import com.onegini.mobile.sdk.android.handlers.OneginiLogoutHandler;
import com.onegini.mobile.sdk.android.handlers.OneginiMobileAuthWithOtpHandler;
import com.onegini.mobile.sdk.android.handlers.error.OneginiAppToWebSingleSignOnError;
import com.onegini.mobile.sdk.android.handlers.error.OneginiDeregistrationError;
import com.onegini.mobile.sdk.android.handlers.error.OneginiLogoutError;
import com.onegini.mobile.sdk.android.handlers.error.OneginiMobileAuthWithOtpError;
import com.onegini.mobile.sdk.android.model.OneginiAppToWebSingleSignOn;
import com.onegini.mobile.sdk.android.model.entity.UserProfile;

public class DashboardActivity extends AppCompatActivity {
Expand Down Expand Up @@ -87,7 +90,6 @@ public void onError(final OneginiMobileAuthWithOtpError oneginiMobileAuthWithOtp
}
}


@SuppressWarnings("unused")
@OnClick(R.id.button_auth_with_otp)
public void mobileAuthWithOtp() {
Expand Down Expand Up @@ -187,6 +189,34 @@ public void startSettingsActivity() {
startActivity(new Intent(this, SettingsActivity.class));
}

@SuppressWarnings("unused")
@OnClick(R.id.button_single_sign_on)
public void startSingleSignOn() {
final Uri targetUri = Uri.parse("https://demo-cim.onegini.com/personal/dashboard");

final OneginiClient oneginiClient = OneginiSDK.getOneginiClient(this);
oneginiClient.getUserClient().getAppToWebSingleSignOn(targetUri, new OneginiAppToWebSingleSignOnHandler() {
@Override
public void onSuccess(final OneginiAppToWebSingleSignOn oneginiAppToWebSingleSignOn) {
final Intent intent = new Intent(Intent.ACTION_VIEW, oneginiAppToWebSingleSignOn.getRedirectUrl());
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
}

@Override
public void onError(final OneginiAppToWebSingleSignOnError oneginiAppToWebSingleSignOnError) {
@OneginiAppToWebSingleSignOnError.AppToWebSingleSignOnErrorType int errorType = oneginiAppToWebSingleSignOnError.getErrorType();
if (errorType == OneginiDeregistrationError.DEVICE_DEREGISTERED) {
// Deregistration failed due to missing device credentials. Register app once again.
new DeregistrationUtil(DashboardActivity.this).onDeviceDeregistered();
}

// other errors don't really require our reaction, but you might consider displaying some message to the user
showToast("App To Web Single Sign-On error: " + oneginiAppToWebSingleSignOnError.getMessage());
}
});
}

private void showToast(final String message) {
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/layout/activity_dashboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
android:id="@+id/button_auth_with_otp"
style="@style/ButtonStyle"
android:text="@string/btn_mobile_auth_with_otp_label"/>
<Button
android:id="@+id/button_single_sign_on"
style="@style/ButtonStyle"
android:text="@string/btn_single_sign_on_label"/>
<Button
android:id="@+id/button_settings"
style="@style/ButtonStyle"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<string name="simple_push_message">Simple push message</string>
<string name="change_pin_finished_successfully">Change PIN action finished successfully</string>
<string name="btn_mobile_auth_with_otp_label">Mobile auth with OTP</string>
<string name="btn_single_sign_on_label">Single Sign-On</string>
<string name="btn_cancel_label">CANCEL</string>
<string name="btn_ok_label">OK</string>
<string name="push_token_is_null_error_message">The push token is null, check if your Firebase configuration in google-services.json file is valid.</string>
Expand Down