-
Notifications
You must be signed in to change notification settings - Fork 29
freeRASP 6.12.0 #159
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
Merged
Merged
freeRASP 6.12.0 #159
Changes from 14 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
f59d955
build: raise Gradle to version 8
yardexx 242c872
build: upgrade Gradle to version 8
yardexx d6570e4
feat: screen protection
yardexx 1777f75
docs: raise version + CHANGELOG.md
yardexx b8bc322
feat: screen recoding
yardexx 87816d6
docs: update + formatting
yardexx 11d4a26
feat: deferred registration of ScreenProtector
yardexx ac35ca6
feat: ScreenProtector
yardexx 99b51e3
feat: update example app
yardexx 14d9bd9
style: misc
yardexx ff57486
style: naming
yardexx 4d1b721
style: update docs
yardexx 11350d4
style: update docs
yardexx 3b57a7e
feat: remove unused activity
yardexx b6a66c7
feat: update iOS sdk
yardexx ad3db88
feat: adjust ScreenProtector
yardexx 7e01fd0
test: update component
yardexx 4a0cfd7
fix: restrict platforms
yardexx c9d926d
docs: update date
yardexx 522108f
chore: update signing team
tompsota 2d21669
docs: fix version
yardexx 8e9a2dd
feat: fix ios impl
yardexx 500e3a0
fix: screen protection button
yardexx 040810d
fix: CHANGELOG.md
yardexx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| distributionBase=GRADLE_USER_HOME | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip | ||
| distributionPath=wrapper/dists | ||
| zipStoreBase=GRADLE_USER_HOME | ||
| zipStorePath=wrapper/dists | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
android/src/main/kotlin/com/aheaditec/freerasp/ScreenProtector.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| package com.aheaditec.freerasp | ||
|
|
||
| import android.annotation.SuppressLint | ||
| import android.app.Activity | ||
| import android.app.Activity.ScreenCaptureCallback | ||
| import android.content.Context | ||
| import android.content.pm.PackageManager | ||
| import android.os.Build | ||
| import android.util.Log | ||
| import android.view.WindowManager.SCREEN_RECORDING_STATE_VISIBLE | ||
| import androidx.annotation.RequiresApi | ||
| import androidx.core.content.ContextCompat | ||
| import androidx.lifecycle.DefaultLifecycleObserver | ||
| import androidx.lifecycle.LifecycleOwner | ||
| import com.aheaditec.talsec_security.security.api.Talsec | ||
| import java.util.function.Consumer | ||
|
|
||
| @SuppressLint("StaticFieldLeak") | ||
| internal object ScreenProtector : DefaultLifecycleObserver { | ||
| private const val TAG = "TalsecScreenProtector" | ||
| private const val SCREEN_CAPTURE_PERMISSION = "android.permission.DETECT_SCREEN_CAPTURE" | ||
| private const val SCREEN_RECORDING_PERMISSION = "android.permission.DETECT_SCREEN_RECORDING" | ||
|
|
||
| internal var activity: Activity? = null | ||
| private var isEnabled = false | ||
|
|
||
| private val screenCaptureCallback = ScreenCaptureCallback { Talsec.onScreenshotDetected() } | ||
| private val screenRecordCallback: Consumer<Int> = Consumer<Int> { state -> | ||
| if (state == SCREEN_RECORDING_STATE_VISIBLE) { | ||
| Talsec.onScreenRecordingDetected() | ||
| Log.e("ScreenProtector", "Screen recording detected") | ||
| } | ||
| } | ||
|
|
||
| fun enable() { | ||
| if (isEnabled) return | ||
| isEnabled = true | ||
| activity?.let { register(it) } | ||
| } | ||
|
|
||
| override fun onStart(owner: LifecycleOwner) { | ||
| super.onStart(owner) | ||
|
|
||
| if (isEnabled) | ||
| activity?.let { register(it) } | ||
| } | ||
|
|
||
| override fun onStop(owner: LifecycleOwner) { | ||
| super.onStop(owner) | ||
|
|
||
| if (isEnabled) | ||
| activity?.let { unregister(it) } | ||
| } | ||
|
|
||
| private fun register(activity: Activity) { | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { | ||
| registerScreenCapture(activity) | ||
| } | ||
|
|
||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) { | ||
| registerScreenRecording(activity) | ||
| } | ||
| } | ||
|
|
||
| // Missing permission is suppressed because the decision to use the screen capture API is made | ||
| // by developer, and not enforced by the library. | ||
| @SuppressLint("MissingPermission") | ||
| private fun unregister(currentActivity: Activity) { | ||
| val context = currentActivity.applicationContext | ||
|
|
||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE && | ||
| hasPermission(context, SCREEN_CAPTURE_PERMISSION) | ||
| ) { | ||
| currentActivity.unregisterScreenCaptureCallback(screenCaptureCallback) | ||
| } | ||
|
|
||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM && | ||
| hasPermission(context, SCREEN_RECORDING_PERMISSION) | ||
| ) { | ||
| currentActivity.windowManager?.removeScreenRecordingCallback(screenRecordCallback) | ||
| } | ||
| } | ||
|
|
||
| // Missing permission is suppressed because the decision to use the screen capture API is made | ||
| // by developer, and not enforced by the library. | ||
| @SuppressLint("MissingPermission") | ||
| @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) | ||
| private fun registerScreenCapture(currentActivity: Activity) { | ||
| val context = currentActivity.applicationContext | ||
|
|
||
| if (!hasPermission(context, SCREEN_CAPTURE_PERMISSION)) { | ||
| reportMissingPermission("screenshot", SCREEN_CAPTURE_PERMISSION) | ||
| return | ||
| } | ||
|
|
||
| currentActivity.registerScreenCaptureCallback(context.mainExecutor, screenCaptureCallback) | ||
| } | ||
|
|
||
| // Missing permission is suppressed because the decision to use the screen capture API is made | ||
| // by developer, and not enforced by the library. | ||
| @SuppressLint("MissingPermission") | ||
| @RequiresApi(Build.VERSION_CODES.VANILLA_ICE_CREAM) | ||
| private fun registerScreenRecording(currentActivity: Activity) { | ||
| val context = currentActivity.applicationContext | ||
|
|
||
| if (!hasPermission(context, SCREEN_RECORDING_PERMISSION)) { | ||
| reportMissingPermission("screen record", SCREEN_RECORDING_PERMISSION) | ||
| return | ||
| } | ||
|
|
||
| val initialState = currentActivity.windowManager.addScreenRecordingCallback( | ||
| context.mainExecutor, screenRecordCallback | ||
| ) | ||
| screenRecordCallback.accept(initialState) | ||
|
|
||
| } | ||
|
|
||
| private fun hasPermission(context: Context, permission: String): Boolean { | ||
| return ContextCompat.checkSelfPermission( | ||
| context, permission | ||
| ) == PackageManager.PERMISSION_GRANTED | ||
| } | ||
|
|
||
| private fun reportMissingPermission(protectionType: String, permission: String) { | ||
| Log.e( | ||
| TAG, | ||
| "Failed to register $protectionType callback. Check if $permission permission is granted in AndroidManifest.xml" | ||
| ) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| #Fri Jun 23 08:50:38 CEST 2017 | ||
| distributionBase=GRADLE_USER_HOME | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip | ||
| distributionPath=wrapper/dists | ||
| zipStoreBase=GRADLE_USER_HOME | ||
| zipStorePath=wrapper/dists | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip | ||
| zipStorePath=wrapper/dists |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.