Skip to content

Commit

Permalink
PingProtect Implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jey authored and jeyanthanperiyasamy committed Feb 2, 2024
1 parent 8ebf0ff commit c690693
Show file tree
Hide file tree
Showing 32 changed files with 1,225 additions and 197 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.0'
classpath 'com.android.tools.build:gradle:8.2.0'
classpath "com.adarshr:gradle-test-logger-plugin:2.0.0"
classpath 'com.google.gms:google-services:4.3.15'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
Expand Down
1 change: 1 addition & 0 deletions forgerock-auth-ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ android {

buildFeatures {
viewBinding true
buildConfig true
}

}
Expand Down
2 changes: 1 addition & 1 deletion forgerock-auth/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ android {
}
buildFeatures {
viewBinding true
buildConfig true
}

kotlinOptions {
Expand All @@ -93,7 +94,6 @@ dependencies {

def coroutine_version = '1.7.2'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutine_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$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'
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright (c) 2019 - 2023 ForgeRock. All rights reserved.
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
package org.forgerock.android.auth.callback

import org.forgerock.android.auth.Logger.Companion.error

/**
* Factory to manage supported [Callback]
*/
class CallbackFactory private constructor() {
internal val callbacks: MutableMap<String, Class<out Callback>> = HashMap()

init {
register(ChoiceCallback::class.java)
register(NameCallback::class.java)
register(PasswordCallback::class.java)
register(StringAttributeInputCallback::class.java)
register(NumberAttributeInputCallback::class.java)
register(BooleanAttributeInputCallback::class.java)
register(ValidatedPasswordCallback::class.java)
register(ValidatedUsernameCallback::class.java)
register(KbaCreateCallback::class.java)
register(TermsAndConditionsCallback::class.java)
register(PollingWaitCallback::class.java)
register(ConfirmationCallback::class.java)
register(TextOutputCallback::class.java)
register(SuspendedTextOutputCallback::class.java)
register(ReCaptchaCallback::class.java)
register(ConsentMappingCallback::class.java)
register(HiddenValueCallback::class.java)
register(DeviceProfileCallback::class.java)
register(MetadataCallback::class.java)
register(WebAuthnRegistrationCallback::class.java)
register(WebAuthnAuthenticationCallback::class.java)
register(SelectIdPCallback::class.java)
register(IdPCallback::class.java)
register(DeviceBindingCallback::class.java)
register(DeviceSigningVerifierCallback::class.java)
register(AppIntegrityCallback::class.java)
}

/**
* Register new Callback Class
*
* @param callback The callback Class
*/
fun register(callback: Class<out Callback>) {
try {
callbacks[getType(callback)] = callback
} catch (e: Exception) {
error(TAG, e, e.message)
}
}

@Throws(InstantiationException::class, IllegalAccessException::class)
fun getType(callback: Class<out Callback>): String {
return callback.getDeclaredConstructor().newInstance().type
}

fun getCallbacks(): Map<String, Class<out Callback>> {
return callbacks
}

companion object {
private val TAG = CallbackFactory::class.java.simpleName

private val INSTANCE = CallbackFactory()

/**
* Returns a cached instance [CallbackFactory]
*
* @return instance of [CallbackFactory]
*/
@JvmStatic fun getInstance(): CallbackFactory {
return INSTANCE
}

}
}
4 changes: 4 additions & 0 deletions forgerock-authenticator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ android {
}
}

buildFeatures {
buildConfig true
}

testOptions {
unitTests.includeAndroidResources = true
unitTests.returnDefaultValues = true
Expand Down
5 changes: 5 additions & 0 deletions forgerock-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ android {
consumerProguardFiles 'consumer-rules.pro'
}

buildFeatures {
buildConfig true
}

buildTypes {
release {
minifyEnabled false
Expand Down Expand Up @@ -58,6 +62,7 @@ android {
kotlinOptions {
freeCompilerArgs = ['-Xjvm-default=all']
}

}

apply from: '../config/logger.gradle'
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ android.useAndroidX=true
GROUP=org.forgerock
VERSION=4.2.0
VERSION_CODE=18
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Aug 16 10:44:41 PDT 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
1 change: 1 addition & 0 deletions ping-protect/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
54 changes: 54 additions & 0 deletions ping-protect/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
}

android {
namespace = "org.forgerock.android.protect"
compileSdk = 34

defaultConfig {
minSdk = 23

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}

testOptions.unitTests.isIncludeAndroidResources = true

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
}

dependencies {
api(project(":forgerock-auth"))
implementation("com.pingidentity.signals:android-sdk:5.1.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.2")

testImplementation("org.robolectric:robolectric:4.9.2")
testImplementation("junit:junit:4.13.2")
testImplementation("androidx.test:core:1.5.0")
testImplementation("androidx.test.ext:junit:1.1.5")
testImplementation("androidx.test:runner:1.5.2")

//Mockk
testImplementation("io.mockk:mockk:1.13.9")

androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}
Empty file added ping-protect/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions ping-protect/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.forgerock.android.auth

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("org.forgerock.android.auth.test", appContext.packageName)
}
}
17 changes: 17 additions & 0 deletions ping-protect/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2023 ForgeRock. All rights reserved.
~
~ This software may be modified and distributed under the terms
~ of the MIT license. See the LICENSE file for details.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<provider
android:name="org.forgerock.android.auth.PingOneProvider"
android:enabled="true"
android:exported="false"
android:authorities="${applicationId}.PingOneProvider" />
</application>
</manifest>
Loading

0 comments on commit c690693

Please sign in to comment.