From 753591b681e5cd3983abc23a86dd3d5497aa3dcf Mon Sep 17 00:00:00 2001 From: Robert Szuba Date: Thu, 18 Apr 2019 10:54:06 +0200 Subject: [PATCH 1/8] Prepare next development version --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1f6c76a1..c8eaa009 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -31,7 +31,7 @@ allprojects { Before the release please change the url below to: https://repo.onegini.com/artifactory/onegini-sdk Please change it back to https://repo.onegini.com/artifactory/public after the release */ - url "https://repo.onegini.com/artifactory/onegini-sdk" + url "https://repo.onegini.com/artifactory/public" credentials { username artifactory_user password artifactory_password @@ -80,7 +80,7 @@ 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.5.1-SNAPSHOT@aar') { transitive = true } From 523ce8598bb6096bf7bf3545650d69a357b90c7f Mon Sep 17 00:00:00 2001 From: Marcin Paszylk Date: Wed, 22 May 2019 13:40:07 +0200 Subject: [PATCH 2/8] EXAMPLEAND-60 example single sign-on implementation --- .../view/activity/DashboardActivity.java | 31 +++++++++++++++++++ .../main/res/layout/activity_dashboard.xml | 4 +++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 36 insertions(+) diff --git a/app/src/main/java/com/onegini/mobile/exampleapp/view/activity/DashboardActivity.java b/app/src/main/java/com/onegini/mobile/exampleapp/view/activity/DashboardActivity.java index 891dbef4..90693bf6 100644 --- a/app/src/main/java/com/onegini/mobile/exampleapp/view/activity/DashboardActivity.java +++ b/app/src/main/java/com/onegini/mobile/exampleapp/view/activity/DashboardActivity.java @@ -17,6 +17,7 @@ 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; @@ -36,9 +37,11 @@ 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.OneginiSingleSignOnHandler; 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.handlers.error.OneginiSingleSignOnError; import com.onegini.mobile.sdk.android.model.entity.UserProfile; public class DashboardActivity extends AppCompatActivity { @@ -187,6 +190,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().getSingleSignOnUri(targetUri, new OneginiSingleSignOnHandler() { + @Override + public void onSuccess(final Uri uri) { + final Intent intent = new Intent(Intent.ACTION_VIEW, uri); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); + startActivity(intent); + } + + @Override + public void onError(final OneginiSingleSignOnError oneginiSingleSignOnError) { + @OneginiSingleSignOnError.SingleSignOnErrorType int errorType = oneginiSingleSignOnError.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("Single Sign-On error: " + oneginiSingleSignOnError.getMessage()); + } + }); + } private void showToast(final String message) { Toast.makeText(this, message, Toast.LENGTH_SHORT).show(); diff --git a/app/src/main/res/layout/activity_dashboard.xml b/app/src/main/res/layout/activity_dashboard.xml index cd24684e..31239aa2 100644 --- a/app/src/main/res/layout/activity_dashboard.xml +++ b/app/src/main/res/layout/activity_dashboard.xml @@ -75,6 +75,10 @@ android:id="@+id/button_auth_with_otp" style="@style/ButtonStyle" android:text="@string/btn_mobile_auth_with_otp_label"/> +