-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
79 changed files
with
987 additions
and
126 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -4,6 +4,8 @@ on: | |
schedule: | ||
- cron: '0 15 * * 1-5' | ||
workflow_dispatch: | ||
push: | ||
pull_request: | ||
|
||
env: | ||
BROWSERSTACK_ACCESSKEY: ${{ secrets.BROWSERSTACK_ACCESSKEY }} | ||
|
@@ -16,6 +18,18 @@ env: | |
|
||
|
||
jobs: | ||
pmd_scan: | ||
name: "PMD Scan" | ||
runs-on: ubuntu-latest | ||
if: > | ||
github.event_name == 'pull_request' && | ||
!contains(github.event.head_commit.message, '[skip pmd]') && | ||
!contains(github.event.head_commit.message, '[force]') | ||
steps: | ||
- uses: Alfresco/[email protected] | ||
with: | ||
fail-on-new-issues: "false" | ||
create-github-annotations: "false" | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
|
This file contains 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 |
---|---|---|
|
@@ -9,4 +9,6 @@ android { | |
|
||
dependencies { | ||
implementation libs.kotlin.stdlib | ||
|
||
implementation libs.androidx.security.crypto | ||
} |
This file contains 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
91 changes: 91 additions & 0 deletions
91
account/src/main/kotlin/com/alfresco/content/account/SecureSharedPreferencesManager.kt
This file contains 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,91 @@ | ||
package com.alfresco.content.account | ||
|
||
import android.content.Context | ||
import android.util.Log | ||
import androidx.security.crypto.EncryptedSharedPreferences | ||
import androidx.security.crypto.MasterKey | ||
|
||
/** | ||
* Marked as SecureSharedPreferencesManager | ||
*/ | ||
class SecureSharedPreferencesManager(private val context: Context) { | ||
|
||
private val masterKey: MasterKey = MasterKey.Builder(context, MasterKey.DEFAULT_MASTER_KEY_ALIAS) | ||
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM) | ||
.build() | ||
|
||
fun saveCredentials(email: String, password: String, displayName: String) { | ||
try { | ||
val encryptedSharedPreferences = EncryptedSharedPreferences.create( | ||
context, | ||
KEY_PREF_NAME, | ||
masterKey, | ||
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, | ||
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM, | ||
) | ||
|
||
encryptedSharedPreferences.edit() | ||
.putString(KEY_EMAIL, email) | ||
.putString(KEY_DISPLAY_NAME, displayName) | ||
.putString(KEY_PASSWORD, password) | ||
.apply() | ||
|
||
Log.d(TAG, "Credentials saved securely") | ||
} catch (e: Exception) { | ||
Log.e(TAG, "Error saving credentials: ${e.message}") | ||
} | ||
} | ||
|
||
fun savePassword(password: String) { | ||
try { | ||
val encryptedSharedPreferences = EncryptedSharedPreferences.create( | ||
context, | ||
KEY_PREF_NAME, | ||
masterKey, | ||
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, | ||
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM, | ||
) | ||
|
||
encryptedSharedPreferences.edit() | ||
.putString(KEY_PASSWORD, password) | ||
.apply() | ||
|
||
Log.d(TAG, "Password saved securely") | ||
} catch (e: Exception) { | ||
Log.e(TAG, "Error saving credentials: ${e.message}") | ||
} | ||
} | ||
|
||
fun getSavedCredentials(): Triple<String, String, String>? { | ||
try { | ||
val encryptedSharedPreferences = EncryptedSharedPreferences.create( | ||
context, | ||
KEY_PREF_NAME, | ||
masterKey, | ||
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, | ||
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM, | ||
) | ||
|
||
val email = encryptedSharedPreferences.getString(KEY_EMAIL, null) | ||
val password = encryptedSharedPreferences.getString(KEY_PASSWORD, null) | ||
val displayName = encryptedSharedPreferences.getString(KEY_DISPLAY_NAME, null) | ||
|
||
if (email != null && password != null && displayName != null) { | ||
return Triple(email, password, displayName) | ||
} | ||
} catch (e: Exception) { | ||
Log.e(TAG, "Error retrieving credentials: ${e.message}") | ||
} | ||
|
||
return null | ||
} | ||
|
||
companion object { | ||
const val KEY_DISPLAY_NAME = "display_name" | ||
const val KEY_EMAIL = "email" | ||
const val KEY_PASSWORD = "password" | ||
const val KEY_PREF_NAME = "secure_prefs" | ||
|
||
val TAG: String = SecureSharedPreferencesManager::class.java.simpleName | ||
} | ||
} |
This file contains 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 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 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
36 changes: 36 additions & 0 deletions
36
actions/src/main/kotlin/com/alfresco/content/actions/sheet/ListViewProcessErrorMessage.kt
This file contains 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,36 @@ | ||
package com.alfresco.content.actions.sheet | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import android.view.LayoutInflater | ||
import android.widget.FrameLayout | ||
import androidx.annotation.DrawableRes | ||
import androidx.annotation.StringRes | ||
import com.airbnb.epoxy.ModelProp | ||
import com.airbnb.epoxy.ModelView | ||
import com.alfresco.content.actions.databinding.ViewListProcessMessageBinding | ||
|
||
@ModelView(autoLayout = ModelView.Size.MATCH_WIDTH_MATCH_HEIGHT) | ||
class ListViewProcessErrorMessage @JvmOverloads constructor( | ||
context: Context, | ||
attrs: AttributeSet? = null, | ||
defStyleAttr: Int = 0, | ||
) : FrameLayout(context, attrs, defStyleAttr) { | ||
|
||
private val binding = ViewListProcessMessageBinding.inflate(LayoutInflater.from(context), this) | ||
|
||
@ModelProp | ||
fun setIconRes(@DrawableRes drawableRes: Int) { | ||
binding.icon.setImageResource(drawableRes) | ||
} | ||
|
||
@ModelProp | ||
fun setTitle(@StringRes stringRes: Int) { | ||
binding.title.text = resources.getText(stringRes) | ||
} | ||
|
||
@ModelProp | ||
fun setMessage(@StringRes stringRes: Int) { | ||
binding.message.text = resources.getText(stringRes) | ||
} | ||
} |
Oops, something went wrong.