diff --git a/build.gradle b/build.gradle index d5c397cb..15eb725e 100644 --- a/build.gradle +++ b/build.gradle @@ -15,6 +15,7 @@ buildscript { customTemplatesFolder = file(projectDir.toString() + "/dokka/templates") } dependencies { + classpath 'com.android.tools.build:gradle:8.2.2' classpath "com.adarshr:gradle-test-logger-plugin:2.0.0" classpath 'com.google.gms:google-services:4.3.15' // NOTE: Do not place your application dependencies here; they belong diff --git a/buildSrc/.gitignore b/buildSrc/.gitignore new file mode 100644 index 00000000..f06dfad6 --- /dev/null +++ b/buildSrc/.gitignore @@ -0,0 +1,2 @@ +.gradle +build \ No newline at end of file diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 00000000..0068e591 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2024 ForgeRock. All rights reserved. + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +plugins { + `kotlin-dsl` +} + +repositories { + google() + mavenCentral() +} + +dependencies { + implementation("com.android.tools.build:gradle-api:8.2.2") +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/AndroidBuildGradlePlugin.kt b/buildSrc/src/main/kotlin/AndroidBuildGradlePlugin.kt new file mode 100644 index 00000000..25625bad --- /dev/null +++ b/buildSrc/src/main/kotlin/AndroidBuildGradlePlugin.kt @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024 ForgeRock. All rights reserved. + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +import com.android.build.api.dsl.LibraryExtension +import org.gradle.api.JavaVersion +import org.gradle.api.Plugin +import org.gradle.api.Project + +class AndroidBuildGradlePlugin : Plugin { + + override fun apply(project: Project) { + project.android().apply { + compileSdk = 34; + defaultConfig { + minSdk = 23 + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + buildTypes { + getByName("release") { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), + ("proguard-rules.pro")) + } + } + testOptions { + targetSdk = 34 + unitTests { + isIncludeAndroidResources = true + isReturnDefaultValues = true + } + unitTests.all { + it.exclude("**/*TestSuite*") + } + } + + buildFeatures { + buildConfig = true + } + + useLibrary("android.test.base") + useLibrary("android.test.mock") + + defaultConfig { + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + } + } + + /** + * Extension function. + */ + private fun Project.android(): LibraryExtension { + return extensions.getByType(LibraryExtension::class.java) + } + + +} \ No newline at end of file diff --git a/config/kdoc.gradle b/config/kdoc.gradle index 04f34b2e..799b9fda 100644 --- a/config/kdoc.gradle +++ b/config/kdoc.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 ForgeRock. All rights reserved. + * Copyright (c) 2023-2024 ForgeRock. All rights reserved. * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. @@ -11,9 +11,6 @@ apply plugin: 'org.jetbrains.dokka' /** * Generate Kdoc, delombok then generate Javadoc */ -configurations { - delombok -} task delombok { def srcJava = 'src/main/java' diff --git a/forgerock-auth-ui/build.gradle b/forgerock-auth-ui/build.gradle index 5e14a144..6860fd6b 100644 --- a/forgerock-auth-ui/build.gradle +++ b/forgerock-auth-ui/build.gradle @@ -41,10 +41,6 @@ android { } -apply from: '../config/kdoc.gradle' -apply from: '../config/publish.gradle' - - dependencies { api project(':forgerock-auth') @@ -62,8 +58,4 @@ dependencies { compileOnly 'com.google.android.gms:play-services-fido:20.0.1' - compileOnly "org.projectlombok:lombok:1.18.28" - delombok "org.projectlombok:lombok:1.18.28" - annotationProcessor 'org.projectlombok:lombok:1.18.28' - } diff --git a/forgerock-auth-ui/src/main/java/org/forgerock/android/auth/ui/AdviceDialogFragment.java b/forgerock-auth-ui/src/main/java/org/forgerock/android/auth/ui/AdviceDialogFragment.java index fc1bb034..ae99866d 100644 --- a/forgerock-auth-ui/src/main/java/org/forgerock/android/auth/ui/AdviceDialogFragment.java +++ b/forgerock-auth-ui/src/main/java/org/forgerock/android/auth/ui/AdviceDialogFragment.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 - 2023 ForgeRock. All rights reserved. + * Copyright (c) 2019 - 2024 ForgeRock. All rights reserved. * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. @@ -29,7 +29,6 @@ import kotlin.Result; import kotlin.Unit; import kotlin.coroutines.Continuation; -import lombok.Setter; /** * Reference implementation of handing Advice with {@link DialogFragment} @@ -41,7 +40,10 @@ public class AdviceDialogFragment extends DialogFragment implements AuthHandler private FRViewModel viewModel; private boolean isCancel = true; - @Setter + public void setListener(Continuation listener) { + this.listener = listener; + } + private Continuation listener; private PolicyAdvice advice; diff --git a/forgerock-auth-ui/src/main/java/org/forgerock/android/auth/ui/FRViewModel.java b/forgerock-auth-ui/src/main/java/org/forgerock/android/auth/ui/FRViewModel.java index 31ee7b1d..f5c18594 100644 --- a/forgerock-auth-ui/src/main/java/org/forgerock/android/auth/ui/FRViewModel.java +++ b/forgerock-auth-ui/src/main/java/org/forgerock/android/auth/ui/FRViewModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 - 2020 ForgeRock. All rights reserved. + * Copyright (c) 2019 - 2024 ForgeRock. All rights reserved. * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. @@ -18,18 +18,26 @@ import org.forgerock.android.auth.NodeListener; import org.forgerock.android.auth.PolicyAdvice; -import lombok.Getter; - /** * {@link ViewModel} Wrapper for {@link FRUser} */ public abstract class FRViewModel extends ViewModel { - @Getter private MutableLiveData> nodeLiveData = new MutableLiveData<>(); - @Getter private MutableLiveData resultLiveData = new MutableLiveData<>(); - @Getter + + public MutableLiveData> getNodeLiveData() { + return nodeLiveData; + } + + public MutableLiveData getResultLiveData() { + return resultLiveData; + } + + public MutableLiveData> getExceptionLiveData() { + return exceptionLiveData; + } + private MutableLiveData> exceptionLiveData = new MutableLiveData<>(); private NodeListener nodeListener; diff --git a/forgerock-auth-ui/src/main/java/org/forgerock/android/auth/ui/SingleLiveEvent.java b/forgerock-auth-ui/src/main/java/org/forgerock/android/auth/ui/SingleLiveEvent.java index 773a9157..79bac3c3 100644 --- a/forgerock-auth-ui/src/main/java/org/forgerock/android/auth/ui/SingleLiveEvent.java +++ b/forgerock-auth-ui/src/main/java/org/forgerock/android/auth/ui/SingleLiveEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 ForgeRock. All rights reserved. + * Copyright (c) 2019 - 2024 ForgeRock. All rights reserved. * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. @@ -7,16 +7,18 @@ package org.forgerock.android.auth.ui; -import lombok.AllArgsConstructor; /** * Event only trigger once after configuration change. */ -@AllArgsConstructor public class SingleLiveEvent { private T value; + public SingleLiveEvent(T value) { + this.value = value; + } + public T getValue() { T result = value; value = null; diff --git a/forgerock-auth/build.gradle b/forgerock-auth/build.gradle deleted file mode 100644 index 0527238c..00000000 --- a/forgerock-auth/build.gradle +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2019 - 2024 ForgeRock. All rights reserved. - * - * This software may be modified and distributed under the terms - * of the MIT license. See the LICENSE file for details. - */ - -apply plugin: 'com.android.library' -apply plugin: "com.adarshr.test-logger" -apply plugin: 'maven-publish' -apply plugin: 'signing' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-parcelize' - -android { - namespace 'org.forgerock.android.auth' - testNamespace 'org.forgerock.android.auth.androidTest' - - compileSdk 34 - useLibrary 'android.test.base' - useLibrary 'android.test.mock' - - defaultConfig { - minSdkVersion 23 - targetSdkVersion 34 - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - manifestPlaceholders = [ - 'appAuthRedirectScheme': 'org.forgerock.demo' - ] - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - - debug { - } - } - - /* Comment this to debug instrument Test, - * There is an issue for AS to run NDK with instrument Test */ - externalNativeBuild { - ndkBuild { - path 'src/main/jni/Android.mk' - } - } - - testOptions { - unitTests.includeAndroidResources = true - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - packagingOptions { - jniLibs { - pickFirsts += ['**/*.so'] - } - } - testOptions { - unitTests.all { - exclude '**/*TestSuite*' - } - } - buildFeatures { - viewBinding true - buildConfig true - } - - kotlinOptions { - freeCompilerArgs = ['-Xjvm-default=all'] - } - -} - -apply from: '../config/logger.gradle' -apply from: '../config/kdoc.gradle' -apply from: '../config/publish.gradle' -/** - * Dependencies - * - */ -dependencies { - api project(':forgerock-core') - implementation fileTree(dir: 'libs', include: ['*.jar']) - - implementation 'com.squareup.okhttp3:okhttp:4.11.0' - implementation 'com.squareup.okhttp3:logging-interceptor:4.11.0' - implementation 'androidx.annotation:annotation:1.6.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - - def coroutine_version = '1.7.2' - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutine_version" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutine_version" - implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'androidx.fragment:fragment-ktx:1.6.1' - - //Make it optional for developer - compileOnly 'com.google.android.gms:play-services-location:21.0.1' - compileOnly 'com.google.android.gms:play-services-safetynet:18.0.1' - // Keeping this version for now, its breaking Apple SignIn for the later versions. - compileOnly 'net.openid:appauth:0.11.1' - compileOnly 'com.google.android.gms:play-services-fido:20.0.1' - - //For Device Binding - compileOnly 'androidx.biometric:biometric-ktx:1.2.0-alpha05' - compileOnly 'com.nimbusds:nimbus-jose-jwt:9.25' - - //Application Pin - compileOnly 'com.madgag.spongycastle:bcpkix-jdk15on:1.58.0.0' - - //Social Login - compileOnly 'com.google.android.gms:play-services-auth:20.6.0' - compileOnly 'com.facebook.android:facebook-login:16.0.0' - - //For App integrity - compileOnly 'com.google.android.play:integrity:1.3.0' - - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - androidTestImplementation 'com.squareup.okhttp:mockwebserver:2.7.5' - androidTestImplementation 'commons-io:commons-io:2.6' - androidTestImplementation 'androidx.test:rules:1.5.0' - androidTestImplementation 'com.google.android.gms:play-services-location:21.0.1' - //Do not update to the latest library, Only 2.x compatible with Android M and below. - androidTestImplementation 'org.assertj:assertj-core:2.9.1' - androidTestImplementation 'com.google.android.gms:play-services-fido:20.0.1' - - androidTestImplementation 'androidx.biometric:biometric-ktx:1.2.0-alpha05' - androidTestImplementation 'com.nimbusds:nimbus-jose-jwt:9.25' - //For Application Pin - androidTestImplementation 'com.madgag.spongycastle:bcpkix-jdk15on:1.58.0.0' - androidTestImplementation 'androidx.security:security-crypto:1.1.0-alpha06' - - //App Integrity - androidTestImplementation 'com.google.android.play:integrity:1.3.0' - - testImplementation 'androidx.test:core:1.5.0' - testImplementation 'androidx.test.ext:junit:1.1.5' - testImplementation 'androidx.test:runner:1.5.2' - testImplementation 'androidx.fragment:fragment-testing:1.6.1' - testImplementation 'com.nimbusds:nimbus-jose-jwt:9.25' - - testImplementation 'junit:junit:4.13.2' - testImplementation 'org.robolectric:robolectric:4.9.2' - testImplementation 'com.squareup.okhttp:mockwebserver:2.7.5' - testImplementation 'commons-io:commons-io:2.6' - testImplementation 'org.assertj:assertj-core:3.23.1' - testImplementation "androidx.test.espresso:espresso-intents:3.5.1" - testImplementation 'net.openid:appauth:0.11.1' - testImplementation 'com.google.android.gms:play-services-fido:20.0.1' - testImplementation 'com.google.android.gms:play-services-auth:20.6.0' - testImplementation 'com.facebook.android:facebook-login:16.0.0' - testImplementation 'com.google.android.gms:play-services-safetynet:18.0.1' - testImplementation 'org.jeasy:easy-random-core:4.0.0' - testImplementation 'com.nimbusds:nimbus-jose-jwt:9.25' - testImplementation 'androidx.biometric:biometric-ktx:1.2.0-alpha05' - - //Application Pin - testImplementation 'com.madgag.spongycastle:bcpkix-jdk15on:1.58.0.0' - testImplementation 'androidx.security:security-crypto:1.1.0-alpha06' - - //App Integrity - testImplementation 'com.google.android.play:integrity:1.3.0' - - testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.2' - - testImplementation 'org.mockito:mockito-core:4.8.1' - testImplementation 'org.mockito.kotlin:mockito-kotlin:4.0.0' - testImplementation 'org.powermock:powermock-module-junit4:2.0.9' - testImplementation 'org.powermock:powermock-api-mockito2:2.0.9' - - compileOnly "org.projectlombok:lombok:1.18.28" - delombok "org.projectlombok:lombok:1.18.28" - annotationProcessor 'org.projectlombok:lombok:1.18.28' - -} \ No newline at end of file diff --git a/forgerock-auth/build.gradle.kts b/forgerock-auth/build.gradle.kts new file mode 100644 index 00000000..898cac87 --- /dev/null +++ b/forgerock-auth/build.gradle.kts @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2024 ForgeRock. All rights reserved. + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +plugins { + id("com.android.library") + id("com.adarshr.test-logger") + id("maven-publish") + id("signing") + id("kotlin-android") + id("kotlin-parcelize") +} + +apply() + +android { + namespace = "org.forgerock.android.auth" + testNamespace = "org.forgerock.android.auth.androidTest" + + buildFeatures { + //Do we really need this? + viewBinding = true + } + + kotlinOptions { + freeCompilerArgs = listOf("-Xjvm-default=all") + } + + unitTestVariants.all { + this.mergedFlavor.manifestPlaceholders["appAuthRedirectScheme"] = "org.forgerock.demo" + } + +} + +apply("../config/logger.gradle") +apply("../config/kdoc.gradle") +apply("../config/publish.gradle") +/** + * Dependencies + */ + +val delombok by configurations.creating { + extendsFrom(configurations.compileOnly.get()) +} + +dependencies { + api(project(":forgerock-core")) + + implementation(libs.okhttp) + implementation(libs.logging.interceptor) + implementation(libs.androidx.annotation) + implementation(libs.androidx.constraintlayout) + + implementation(libs.org.jetbrains.kotlinx) + implementation(libs.jetbrains.kotlinx.coroutines.play.services) + implementation(libs.androidx.appcompat) + implementation(libs.androidx.fragment.ktx) + + //Make it optional for developer + compileOnly(libs.play.services.location) + compileOnly(libs.play.services.safetynet) + // Keeping this version for now, its breaking Apple SignIn for the later versions. + compileOnly(libs.appauth) + compileOnly(libs.play.services.fido) + + //For Device Binding + compileOnly(libs.androidx.biometric.ktx) + compileOnly(libs.nimbus.jose.jwt) + + //Application Pin + compileOnly(libs.bcpkix.jdk15on) + + //Social Login + compileOnly(libs.play.services.auth) + compileOnly(libs.facebook.login) + + //For App integrity + compileOnly(libs.integrity) + + androidTestImplementation(libs.androidx.test.ext.junit) + androidTestImplementation(libs.espresso.core) + androidTestImplementation(libs.mockwebserver) + androidTestImplementation(libs.commons.io) + androidTestImplementation(libs.rules) + androidTestImplementation(libs.play.services.location) + //Do not update to the latest library, Only 2.x compatible with Android M and below. + androidTestImplementation(libs.assertj.core) + androidTestImplementation(libs.play.services.fido) + + androidTestImplementation(libs.androidx.biometric.ktx) + androidTestImplementation(libs.nimbus.jose.jwt) + //For Application Pin + androidTestImplementation(libs.bcpkix.jdk15on) + androidTestImplementation(libs.androidx.security.crypto) + + //App Integrity + androidTestImplementation(libs.integrity) + + testImplementation(libs.androidx.test.core) + testImplementation(libs.androidx.test.ext.junit) + testImplementation(libs.androidx.test.runner) + testImplementation(libs.androidx.fragment.testing) + testImplementation(libs.nimbus.jose.jwt) + + testImplementation(libs.junit) + testImplementation(libs.org.robolectric.robolectric) + testImplementation(libs.mockwebserver) + testImplementation(libs.commons.io) + testImplementation(libs.assertj.core) + testImplementation(libs.androidx.espresso.intents) + testImplementation(libs.appauth) + testImplementation(libs.play.services.fido) + testImplementation(libs.play.services.auth) + testImplementation(libs.facebook.login) + testImplementation(libs.play.services.safetynet) + testImplementation(libs.easy.random.core) + testImplementation(libs.nimbus.jose.jwt) + testImplementation(libs.androidx.biometric.ktx) + + //Application Pin + testImplementation(libs.bcpkix.jdk15on) + testImplementation(libs.androidx.security.crypto) + + //App Integrity + testImplementation(libs.integrity) + + testImplementation(libs.kotlinx.coroutines.test) + + testImplementation(libs.mockito.core) + testImplementation(libs.mockito.kotlin) + testImplementation(libs.powermock.module.junit4) + testImplementation(libs.powermock.api.mockito2) + + compileOnly(libs.projectlombok.lombok) + delombok(libs.projectlombok.lombok) + annotationProcessor(libs.projectlombok.lombok) + +} \ No newline at end of file diff --git a/forgerock-auth/proguard-rules.pro b/forgerock-auth/proguard-rules.pro index f1b42451..2f9dc5a4 100644 --- a/forgerock-auth/proguard-rules.pro +++ b/forgerock-auth/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/forgerock-authenticator/build.gradle b/forgerock-authenticator/build.gradle deleted file mode 100644 index c8ea3471..00000000 --- a/forgerock-authenticator/build.gradle +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2020 - 2024 ForgeRock. All rights reserved. - * - * This software may be modified and distributed under the terms - * of the MIT license. See the LICENSE file for details. - */ - -apply plugin: 'com.android.library' -apply plugin: "com.adarshr.test-logger" -apply plugin: 'maven-publish' -apply plugin: 'signing' -apply plugin: 'kotlin-android' -// We cannot use kdoc for this project due to Lombak ,so need to add this dokka plugin here. -apply plugin: 'org.jetbrains.dokka' - -android { - namespace 'org.forgerock.android.authenticator' - - compileSdk 34 - - useLibrary 'android.test.base' - useLibrary 'android.test.mock' - - defaultConfig { - minSdkVersion 23 - targetSdkVersion 34 - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - buildConfig true - } - - testOptions { - unitTests.includeAndroidResources = true - unitTests.returnDefaultValues = true - unitTests.all { - exclude '**/*TestSuite*' - } - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - packagingOptions { - jniLibs { - pickFirsts += ['**/*.so'] - } - } - -} - -tasks.named("dokkaHtml") { - outputDirectory.set(file("$buildDir/html")) -} - -tasks.named("dokkaJavadoc") { - outputDirectory.set(file("$buildDir/javadoc")) -} - -/** - * JCenter Dependency Manager - */ -task sourcesJar(type: Jar) { - archiveClassifier.set('sources') - from android.sourceSets.main.java.srcDirs -} - -task javadocJar(type: Jar, dependsOn: dokkaHtml) { - archiveClassifier.set('javadoc') - from new File("$buildDir/generated-javadoc") -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -apply from: '../config/logger.gradle' -apply from: '../config/publish.gradle' - - -/** - * Dependencies - */ -dependencies { - api project(':forgerock-core') - implementation fileTree(dir: 'libs', include: ['*.jar']) - - // JWT - implementation 'com.nimbusds:nimbus-jose-jwt:9.25' - - // Common - implementation 'androidx.annotation:annotation:1.3.0' - implementation 'androidx.appcompat:appcompat:1.6.1' - - // FCM Notifications, make it optional for developer - compileOnly 'com.google.firebase:firebase-messaging:23.1.2' - - // Networking - implementation 'com.squareup.okhttp3:okhttp:4.11.0' - implementation 'com.squareup.okhttp3:logging-interceptor:4.11.0' - - // Biometric - implementation 'androidx.biometric:biometric-ktx:1.2.0-alpha05' - - - // Testing - testImplementation 'androidx.test:core:1.5.0' - testImplementation 'androidx.test.ext:junit:1.1.5' - testImplementation 'androidx.test:runner:1.5.2' - testImplementation 'junit:junit:4.13.2' - testImplementation 'org.robolectric:robolectric:4.8.1' - testImplementation 'com.squareup.okhttp3:mockwebserver:4.8.0' - testImplementation "com.google.firebase:firebase-messaging:23.1.2" - testImplementation 'org.mockito:mockito-core:4.8.1' - - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - -} - diff --git a/forgerock-authenticator/build.gradle.kts b/forgerock-authenticator/build.gradle.kts new file mode 100644 index 00000000..11b92f52 --- /dev/null +++ b/forgerock-authenticator/build.gradle.kts @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2020 - 2024 ForgeRock. All rights reserved. + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +plugins { + id("com.android.library") + id("com.adarshr.test-logger") + id("maven-publish") + id("signing") + id("kotlin-android") +// We cannot use kdoc for this project due to Lombak ,so need to add this dokka plugin here. + id("org.jetbrains.dokka") +} + +apply() + +android { + namespace = "org.forgerock.android.authenticator" +} + +tasks.dokkaHtml.configure { + outputDirectory.set(file("$buildDir/html")) +} + +tasks.dokkaJavadoc.configure { + outputDirectory.set(file("$buildDir/javadoc")) +} + +/** + * JCenter Dependency Manager + */ +tasks { + val sourcesJar by creating(Jar::class) { + archiveClassifier.set("sources") + from(android.sourceSets.getByName("main").java.srcDirs) + } + + val javadocJar by creating(Jar::class) { + dependsOn.add(dokkaHtml) + archiveClassifier.set("javadoc") + from(File("$buildDir/generated-javadoc")) + } + + artifacts { + archives(sourcesJar) + archives(javadocJar) + } +} + +apply("../config/logger.gradle") +apply("../config/publish.gradle") + + +/** + * Dependencies + */ +dependencies { + api(project(":forgerock-core")) + + // JWT + implementation(libs.nimbus.jose.jwt) + + // Common + implementation(libs.androidx.annotation) + implementation(libs.androidx.appcompat) + + // FCM Notifications, make it optional for developer + compileOnly(libs.firebase.messaging) + + // Networking + implementation(libs.okhttp) + implementation(libs.logging.interceptor) + + // Biometric + implementation(libs.androidx.biometric.ktx) + + + // Testing + testImplementation(libs.androidx.test.core) + testImplementation(libs.androidx.test.ext.junit) + testImplementation(libs.androidx.test.runner) + testImplementation(libs.junit) + testImplementation(libs.org.robolectric.robolectric) + testImplementation(libs.okhttp3.mockwebserver) + testImplementation(libs.firebase.messaging) + testImplementation(libs.mockito.core) + + androidTestImplementation(libs.androidx.test.ext.junit) + +} + diff --git a/forgerock-authenticator/proguard-rules.pro b/forgerock-authenticator/proguard-rules.pro index f1b42451..2f9dc5a4 100644 --- a/forgerock-authenticator/proguard-rules.pro +++ b/forgerock-authenticator/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/forgerock-core/build.gradle b/forgerock-core/build.gradle deleted file mode 100644 index a3e5fd04..00000000 --- a/forgerock-core/build.gradle +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2020 - 2024 ForgeRock. All rights reserved. - * - * This software may be modified and distributed under the terms - * of the MIT license. See the LICENSE file for details. - */ - -apply plugin: 'com.android.library' -apply plugin: "com.adarshr.test-logger" -apply plugin: 'maven-publish' -apply plugin: 'signing' -apply plugin: 'kotlin-android' - -android { - namespace 'org.forgerock.android.core' - - compileSdk 34 - - useLibrary 'android.test.base' - useLibrary 'android.test.mock' - - defaultConfig { - minSdkVersion 23 - targetSdkVersion 34 - buildConfigField 'String', 'VERSION_NAME', "\"" + VERSION + "\"" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - consumerProguardFiles 'consumer-rules.pro' - } - - buildFeatures { - buildConfig true - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - - testOptions { - unitTests.includeAndroidResources = true - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - packagingOptions { - jniLibs { - pickFirsts += ['**/*.so'] - } - } - - testOptions { - unitTests.all { - exclude '**/*TestSuite*' - } - } - - kotlinOptions { - freeCompilerArgs = ['-Xjvm-default=all'] - } - -} - -apply from: '../config/logger.gradle' -apply from: '../config/kdoc.gradle' -apply from: '../config/publish.gradle' - -/** - * Dependencies - */ -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - - implementation 'com.squareup.okhttp3:okhttp:4.11.0' - implementation 'com.squareup.okhttp3:logging-interceptor:4.11.0' - implementation 'androidx.annotation:annotation:1.6.0' - implementation 'androidx.security:security-crypto:1.1.0-alpha06' - - // Biometric - implementation 'androidx.biometric:biometric-ktx:1.2.0-alpha05' - - //Application Pin - compileOnly 'com.madgag.spongycastle:bcpkix-jdk15on:1.58.0.0' - - testImplementation 'androidx.test:core:1.5.0' - testImplementation 'androidx.test:runner:1.5.2' - - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - androidTestImplementation 'com.squareup.okhttp:mockwebserver:2.7.5' - androidTestImplementation 'commons-io:commons-io:2.6' - androidTestImplementation 'androidx.test:rules:1.5.0' - //Do not update to the latest library, Only 2.x compatible with Android M and below. - androidTestImplementation 'org.assertj:assertj-core:2.9.1' - - //For Application Pin - androidTestImplementation 'com.madgag.spongycastle:bcpkix-jdk15on:1.58.0.0' - androidTestImplementation 'androidx.security:security-crypto:1.1.0-alpha06' - - testImplementation 'androidx.test.ext:junit:1.1.5' - testImplementation 'junit:junit:4.13.2' - testImplementation 'org.robolectric:robolectric:4.9.2' - testImplementation 'com.squareup.okhttp:mockwebserver:2.7.5' - testImplementation 'commons-io:commons-io:2.6' - testImplementation 'org.assertj:assertj-core:3.23.1' - - testImplementation 'com.madgag.spongycastle:bcpkix-jdk15on:1.58.0.0' - testImplementation 'org.mockito:mockito-core:4.8.1' - testImplementation 'org.mockito.kotlin:mockito-kotlin:4.0.0' - testImplementation 'org.powermock:powermock-module-junit4:2.0.9' - testImplementation 'org.powermock:powermock-api-mockito2:2.0.9' - - compileOnly "org.projectlombok:lombok:1.18.28" - delombok "org.projectlombok:lombok:1.18.28" - annotationProcessor 'org.projectlombok:lombok:1.18.28' -} \ No newline at end of file diff --git a/forgerock-core/build.gradle.kts b/forgerock-core/build.gradle.kts new file mode 100644 index 00000000..f6f8e83e --- /dev/null +++ b/forgerock-core/build.gradle.kts @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2024 ForgeRock. All rights reserved. + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +plugins { + id("com.android.library") + id("com.adarshr.test-logger") + id("maven-publish") + id("signing") + id("kotlin-android") +} + +apply() + +android { + namespace = "org.forgerock.android.core" + + /** + * Comment this to debug instrument Test, + * There is an issue for AS to run NDK with instrument Test + */ + externalNativeBuild { + ndkBuild { + path("src/main/jni/Android.mk") + } + } + + val VERSION: String by project + defaultConfig { + buildConfigField("String", "VERSION_NAME", "\"$VERSION\"") + } + + packaging { + jniLibs { + pickFirsts.add("**/*.so") + } + } + + kotlinOptions { + freeCompilerArgs = listOf("-Xjvm-default=all") + } + +} + +apply("../config/logger.gradle") +apply("../config/kdoc.gradle") +apply("../config/publish.gradle") + +val delombok by configurations.creating { + extendsFrom(configurations.compileOnly.get()) +} + +/** + * Dependencies + */ +dependencies { + + implementation(libs.okhttp) + implementation(libs.logging.interceptor) + implementation(libs.androidx.annotation) + implementation(libs.androidx.security.crypto) + + // Biometric + implementation(libs.androidx.biometric.ktx) + + //Application Pin + compileOnly(libs.bcpkix.jdk15on) + + testImplementation(libs.androidx.test.core) + testImplementation(libs.androidx.test.runner) + + androidTestImplementation(libs.androidx.test.ext.junit) + androidTestImplementation(libs.espresso.core) + androidTestImplementation(libs.mockwebserver) + androidTestImplementation(libs.commons.io) + androidTestImplementation(libs.rules) + //Do not update to the latest library, Only 2.x compatible with Android M and below. + androidTestImplementation(libs.assertj.core) + + //For Application Pin + androidTestImplementation(libs.bcpkix.jdk15on) + androidTestImplementation(libs.androidx.security.crypto) + + testImplementation(libs.androidx.test.ext.junit) + testImplementation(libs.junit) + testImplementation(libs.org.robolectric.robolectric) + testImplementation(libs.mockwebserver) + testImplementation(libs.commons.io) + testImplementation(libs.assertj.core) + + testImplementation(libs.bcpkix.jdk15on) + testImplementation(libs.mockito.core) + testImplementation(libs.mockito.kotlin) + testImplementation(libs.powermock.module.junit4) + testImplementation(libs.powermock.api.mockito2) + + compileOnly(libs.projectlombok.lombok) + delombok(libs.projectlombok.lombok) + annotationProcessor(libs.projectlombok.lombok) +} \ No newline at end of file diff --git a/forgerock-core/proguard-rules.pro b/forgerock-core/proguard-rules.pro index f1b42451..2f9dc5a4 100644 --- a/forgerock-core/proguard-rules.pro +++ b/forgerock-core/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/forgerock-auth/src/main/jni/Android.mk b/forgerock-core/src/main/jni/Android.mk similarity index 100% rename from forgerock-auth/src/main/jni/Android.mk rename to forgerock-core/src/main/jni/Android.mk diff --git a/forgerock-auth/src/main/jni/Application.mk b/forgerock-core/src/main/jni/Application.mk similarity index 100% rename from forgerock-auth/src/main/jni/Application.mk rename to forgerock-core/src/main/jni/Application.mk diff --git a/forgerock-auth/src/main/jni/toolFile.cpp b/forgerock-core/src/main/jni/toolFile.cpp similarity index 100% rename from forgerock-auth/src/main/jni/toolFile.cpp rename to forgerock-core/src/main/jni/toolFile.cpp diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0ea3054a..ab7d413b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,29 +1,91 @@ [versions] agp = "8.2.2" +annotation = "1.6.0" +appauth = "0.11.1" +appcompat = "1.6.1" +assertj-core = "2.9.1" +bcpkix-jdk15on = "1.58.0.0" +biometric-ktx = "1.2.0-alpha05" +commons-io = "2.6" +constraintlayout = "2.1.4" +easy-random-core = "4.0.0" +facebook-login = "16.0.0" +firebase-messaging = "23.1.2" +fragment-ktx = "1.6.1" +integrity = "1.3.0" kotlin = "1.9.22" junit = "4.13.2" androidx-test-core = "1.5.0" androidx-test-ext-junit = "1.1.5" androidx-test-runner = "1.5.2" +kotlinx-coroutines-play-services = "1.7.2" +lombok-version = "1.18.28" +mockito-core = "4.8.1" +mockito-kotlin = "4.0.0" +mockwebserver = "2.7.5" +mockwebserver-version = "4.8.0" +nimbus-jose-jwt = "9.37.3" +okhttp = "4.11.0" org-robolectric-robolectric = "4.9.2" espresso-core = "3.5.1" io-mockk = "1.13.9" org-jetbrains-kotlinx = "1.7.2" com-pingidentity-signals = "5.1.2" +play-services-auth = "20.6.0" +play-services-fido = "20.0.1" +play-services-location = "21.0.1" +play-services-safetynet = "18.0.1" +powermock-module-junit4 = "2.0.9" +powermock-api-mockito2 = "2.0.9" +rules = "1.5.0" +security-crypto = "1.1.0-alpha06" [libraries] +androidx-annotation = { module = "androidx.annotation:annotation", version.ref = "annotation" } +androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" } +androidx-biometric-ktx = { module = "androidx.biometric:biometric-ktx", version.ref = "biometric-ktx" } +androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintlayout" } +androidx-espresso-intents = { module = "androidx.test.espresso:espresso-intents", version.ref = "espresso-core" } +androidx-fragment-ktx = { module = "androidx.fragment:fragment-ktx", version.ref = "fragment-ktx" } +androidx-fragment-testing = { module = "androidx.fragment:fragment-testing", version.ref = "fragment-ktx" } +androidx-security-crypto = { module = "androidx.security:security-crypto", version.ref = "security-crypto" } +appauth = { module = "net.openid:appauth", version.ref = "appauth" } +assertj-core = { module = "org.assertj:assertj-core", version.ref = "assertj-core" } +bcpkix-jdk15on = { module = "com.madgag.spongycastle:bcpkix-jdk15on", version.ref = "bcpkix-jdk15on" } +commons-io = { module = "commons-io:commons-io", version.ref = "commons-io" } +easy-random-core = { module = "org.jeasy:easy-random-core", version.ref = "easy-random-core" } +facebook-login = { module = "com.facebook.android:facebook-login", version.ref = "facebook-login" } +firebase-messaging = { module = "com.google.firebase:firebase-messaging", version.ref = "firebase-messaging" } +integrity = { module = "com.google.android.play:integrity", version.ref = "integrity" } +jetbrains-kotlinx-coroutines-play-services = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-play-services", version.ref = "kotlinx-coroutines-play-services" } junit = { group = "junit", name = "junit", version.ref = "junit" } androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext-junit" } androidx-test-core = { group = "androidx.test", name = "core", version.ref = "androidx-test-core" } androidx-test-runner = { group = "androidx.test", name = "runner", version.ref = "androidx-test-runner" } +kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "org-jetbrains-kotlinx" } +logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" } +mockito-kotlin = { module = "org.mockito.kotlin:mockito-kotlin", version.ref = "mockito-kotlin" } +mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito-core" } +mockwebserver = { module = "com.squareup.okhttp:mockwebserver", version.ref = "mockwebserver" } +nimbus-jose-jwt = { module = "com.nimbusds:nimbus-jose-jwt", version.ref = "nimbus-jose-jwt" } +okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } +okhttp3-mockwebserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "mockwebserver-version" } org-robolectric-robolectric = { group = "org.robolectric", name = "robolectric", version.ref = "org-robolectric-robolectric" } espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso-core" } io-mockk = { group = "io.mockk", name = "mockk", version.ref = "io-mockk" } org-jetbrains-kotlinx = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "org-jetbrains-kotlinx" } -com-pingidentity-signals = { group = "com.pingidentity.signals", name = "android-sdk", version.ref = "com-pingidentity-signals" } +com-pingidentity-signals = { group = "com.pingidentity.signals", name = "android-sdk", version.ref = "com-pingidentity-signals" } +play-services-auth = { module = "com.google.android.gms:play-services-auth", version.ref = "play-services-auth" } +play-services-fido = { module = "com.google.android.gms:play-services-fido", version.ref = "play-services-fido" } +play-services-location = { module = "com.google.android.gms:play-services-location", version.ref = "play-services-location" } +play-services-safetynet = { module = "com.google.android.gms:play-services-safetynet", version.ref = "play-services-safetynet" } +powermock-api-mockito2 = { module = "org.powermock:powermock-api-mockito2", version.ref = "powermock-api-mockito2" } +powermock-module-junit4 = { module = "org.powermock:powermock-module-junit4", version.ref = "powermock-module-junit4" } +projectlombok-lombok = { module = "org.projectlombok:lombok", version.ref = "lombok-version" } +rules = { module = "androidx.test:rules", version.ref = "rules" } [plugins] androidApplication = { id = "com.android.application", version.ref = "agp" } -androidLibrary= { id = "com.android.library", version.ref = "agp" } +androidLibrary = { id = "com.android.library", version.ref = "agp" } kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c10d70fc..c702fbca 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Aug 16 10:44:41 PDT 2021 +#Wed Feb 21 12:34:24 PST 2024 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/ping-protect/build.gradle.kts b/ping-protect/build.gradle.kts index 5c97dca1..22c391e4 100644 --- a/ping-protect/build.gradle.kts +++ b/ping-protect/build.gradle.kts @@ -43,7 +43,7 @@ android { } dependencies { - api(project(":forgerock-auth")) + implementation(project(":forgerock-auth")) implementation(libs.com.pingidentity.signals) implementation(libs.org.jetbrains.kotlinx) diff --git a/samples/app/build.gradle b/samples/app/build.gradle index e83d14ca..2e0e9c08 100644 --- a/samples/app/build.gradle +++ b/samples/app/build.gradle @@ -72,7 +72,7 @@ dependencies { //Device Binding + JWT + Application Pin implementation 'com.madgag.spongycastle:bcpkix-jdk15on:1.58.0.0' //Application PIN implementation 'androidx.security:security-crypto:1.1.0-alpha05' - implementation 'com.nimbusds:nimbus-jose-jwt:9.25' + implementation 'com.nimbusds:nimbus-jose-jwt:9.37.3' implementation 'androidx.biometric:biometric-ktx:1.2.0-alpha05' //WebAuthn diff --git a/samples/auth/build.gradle b/samples/auth/build.gradle index 5456914e..94695e6b 100644 --- a/samples/auth/build.gradle +++ b/samples/auth/build.gradle @@ -90,7 +90,7 @@ dependencies { implementation 'com.google.android.play:integrity:1.3.0' //Device Binding + JWT - implementation 'com.nimbusds:nimbus-jose-jwt:9.25' + implementation 'com.nimbusds:nimbus-jose-jwt:9.37.3' implementation 'androidx.biometric:biometric-ktx:1.2.0-alpha05' //Application Pin diff --git a/samples/kotlin/build.gradle b/samples/kotlin/build.gradle index 1f494d13..8a84f364 100644 --- a/samples/kotlin/build.gradle +++ b/samples/kotlin/build.gradle @@ -80,7 +80,7 @@ dependencies { implementation 'com.google.android.material:material:1.8.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'com.google.android.gms:play-services-fido:20.0.1' - implementation 'com.nimbusds:nimbus-jose-jwt:9.25' + implementation 'com.nimbusds:nimbus-jose-jwt:9.37.3' //Application Pin implementation 'com.madgag.spongycastle:bcpkix-jdk15on:1.58.0.0'