Skip to content

Commit 4a44a0d

Browse files
committed
Updates for TFA flows.
Added temporary action for Push TFA CI build
1 parent 1945f21 commit 4a44a0d

File tree

8 files changed

+419
-341
lines changed

8 files changed

+419
-341
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Build Bits & Bytes demo/variant debug Build (Develop)
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
workflow_dispatch:
8+
inputs:
9+
branch:
10+
description: 'Branch to run the workflow on'
11+
default: 'develop'
12+
required: true
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
with:
22+
ref: ${{ github.event.inputs.branch }}
23+
24+
- name: Set up JDK 17
25+
uses: actions/setup-java@v3
26+
with:
27+
distribution: 'zulu'
28+
java-version: '17'
29+
30+
- name: Update signingConfigs in build.gradle.kts
31+
run: |
32+
sed -i '/signingConfigs {/,/}/c\signingConfigs {\n\n getByName("debug") {\n keyAlias = "${{ secrets.BITS_N_BYTES_DEBUG_KEY_ALIAS }}"\n keyPassword = "${{ secrets.BITS_N_BYTES_DEBUG_KEY_PASSWORD }}"\n storeFile = file("keystore/debug")\n storePassword = "${{ secrets.BITS_N_BYTES_DEBUG_STORE_PASSWORD }}"\n }\n' app/build.gradle.kts
33+
34+
- name: Add API key tags to strings.xml resource (demo only)
35+
run: |
36+
sed -i '/<\/resources>/i \ <string name="com.sap.cxcdc.apikey">${{ secrets.BITS_N_BYTES_DEMO_API_KEY_PUSH_TFA }}</string>' app/src/main/res/values/strings.xml
37+
38+
- name: Add Google required resources to strings.xml resource (actual value for demo only)
39+
run: |
40+
sed -i '/<\/resources>/i \ <string name="google_server_client_id">${{ secrets.GOOGLE_WEB_SERVER_CLIENT_ID }}</string>' app/src/main/res/values/strings.xml
41+
42+
- name: Add Facebook required resources to strings.xml resource (actual value for demo only)
43+
run: |
44+
sed -i '/<\/resources>/i \ <string name="facebook_app_id">FB_APP_ID_HERE</string>' app/src/main/res/values/strings.xml
45+
sed -i '/<\/resources>/i \ <string name="fb_login_protocol_scheme">FB_LOGIN_PROTOCOL_SCHEME_HERE</string>' app/src/main/res/values/strings.xml
46+
sed -i '/<\/resources>/i \ <string name="facebook_client_token">FB_CLIENT_TOKEN_HERE</string>' app/src/main/res/values/strings.xml
47+
sed -i '/<\/resources>/i \ <string name="facebook_app_id">FB_APP_ID_HERE</string>' app/src/variant/res/values/strings.xml
48+
sed -i '/<\/resources>/i \ <string name="fb_login_protocol_scheme">FB_LOGIN_PROTOCOL_SCHEME_HERE</string>' app/src/variant/res/values/strings.xml
49+
sed -i '/<\/resources>/i \ <string name="facebook_client_token">FB_CLIENT_TOKEN_HERE</string>' app/src/variant/res/values/strings.xml
50+
51+
- name: Add Line required resources to strings.xml resource (actual value for demo only)
52+
run: |
53+
sed -i '/<\/resources>/i \ <string name="line_channel_id">LINE_CHANNEL_ID_HERE</string>' app/src/main/res/values/strings.xml
54+
55+
- name: Add WeChat required resources to strings.xml resource (actual value for demo only)
56+
run: |
57+
sed -i '/<\/resources>/i \ <string name="wechat_app_id">WECHAT_APP_ID_HERE</string>' app/src/main/res/values/strings.xml
58+
59+
- name: Create file for google-services.json (Demo)
60+
run: echo '${{ secrets.GOOGLE_SERVICES_JSON }}' > app/google-services.json
61+
62+
- name: Build Debug APK
63+
run: ./gradlew assembleDemoDebug
64+
65+
- name: Rename Demo APK file
66+
run: mv app/build/outputs/apk/demo/debug/app-demo-debug.apk app/build/outputs/apk/demo/debug/bits-n-bytes-app-demo-debug.apk
67+
68+
- name: Upload Demo APK
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: demo-debug-apk
72+
path: app/build/outputs/apk/demo/debug/bits-n-bytes-app-demo-debug.apk

app/src/main/java/com/sap/cdc/bitsnbytes/MainApplication.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class MainApplication : Application() {
1515

1616
// Allow WebView debugging.
1717
CDCDebuggable.debugLogging(true)
18-
CDCDebuggable.httpLogging(false)
18+
CDCDebuggable.httpLogging(true)
1919
CDCDebuggable.setWebViewDebuggable(true)
2020
}
2121
}

library/src/main/java/com/sap/cdc/android/sdk/auth/Auth.kt

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import com.sap.cdc.android.sdk.auth.flow.LoginAuthFlow
66
import com.sap.cdc.android.sdk.auth.flow.LogoutAuthFlow
77
import com.sap.cdc.android.sdk.auth.flow.ProviderAuthFow
88
import com.sap.cdc.android.sdk.auth.flow.RegistrationAuthFlow
9+
import com.sap.cdc.android.sdk.auth.flow.TFAAuthFlow
910
import com.sap.cdc.android.sdk.auth.model.ConflictingAccountsEntity
1011
import com.sap.cdc.android.sdk.auth.provider.IAuthenticationProvider
1112
import com.sap.cdc.android.sdk.auth.session.Session
@@ -586,35 +587,35 @@ internal class AuthTFA(
586587
) : IAuthTFA {
587588

588589
override suspend fun getProviders(regToken: String): IAuthResponse {
589-
val accountFlow = AccountAuthFlow(coreClient, sessionService)
590-
return accountFlow.getTFAProviders(mutableMapOf("regToken" to regToken))
590+
val tfaFlow = TFAAuthFlow(coreClient, sessionService)
591+
return tfaFlow.getTFAProviders(mutableMapOf("regToken" to regToken))
591592
}
592593

593594
override suspend fun optInForPushAuthentication(): IAuthResponse {
594-
val accountFlow = AccountAuthFlow(coreClient, sessionService)
595+
val tfaFlow = TFAAuthFlow(coreClient, sessionService)
595596
val parameters = mutableMapOf(
596597
"provider" to TFAProvider.PUSH.value, "mode" to "register"
597598
)
598-
return accountFlow.optInForPushTFA(parameters = parameters)
599+
return tfaFlow.optInForPushTFA(parameters = parameters)
599600
}
600601

601602
override suspend fun finalizeOtpInForPushAuthentication(
602603
parameters: MutableMap<String, String>
603604
): IAuthResponse {
604-
val accountFlow = AccountAuthFlow(coreClient, sessionService)
605-
return accountFlow.finalizeOptInForPushTFA(parameters)
605+
val tfaFlow = TFAAuthFlow(coreClient, sessionService)
606+
return tfaFlow.finalizeOptInForPushTFA(parameters)
606607
}
607608

608609
override suspend fun verifyPushTFA(parameters: MutableMap<String, String>): IAuthResponse {
609-
val accountFlow = AccountAuthFlow(coreClient, sessionService)
610-
return accountFlow.verifyPushTFA(parameters)
610+
val tfaFlow = TFAAuthFlow(coreClient, sessionService)
611+
return tfaFlow.verifyPushTFA(parameters)
611612
}
612613

613614
override suspend fun getRegisteredEmails(
614615
resolvableContext: ResolvableContext
615616
): IAuthResponse {
616-
val accountFlow = AccountAuthFlow(coreClient, sessionService)
617-
return accountFlow.getRegisteredEmails(
617+
val tfaFlow = TFAAuthFlow(coreClient, sessionService)
618+
return tfaFlow.getRegisteredEmails(
618619
resolvableContext,
619620
mutableMapOf("provider" to TFAProvider.EMAIL.value, "mode" to "verify")
620621
)
@@ -625,8 +626,8 @@ internal class AuthTFA(
625626
emailAddress: String,
626627
language: String?
627628
): IAuthResponse {
628-
val accountFlow = AccountAuthFlow(coreClient, sessionService)
629-
return accountFlow.sendEmailCode(
629+
val tfaFlow = TFAAuthFlow(coreClient, sessionService)
630+
return tfaFlow.sendEmailCode(
630631
resolvableContext,
631632
mutableMapOf("emailID" to emailAddress, "lang" to (language ?: "en"))
632633
)
@@ -638,8 +639,8 @@ internal class AuthTFA(
638639
language: String?,
639640
method: TFAPhoneMethod?
640641
): IAuthResponse {
641-
val accountFlow = AccountAuthFlow(coreClient, sessionService)
642-
return accountFlow.registerPhone(
642+
val tfaFlow = TFAAuthFlow(coreClient, sessionService)
643+
return tfaFlow.registerPhone(
643644
resolvableContext, phoneNumber,
644645
mutableMapOf(
645646
"provider" to TFAProvider.PHONE.value,
@@ -651,8 +652,8 @@ internal class AuthTFA(
651652
}
652653

653654
override suspend fun registerTOTP(resolvableContext: ResolvableContext): IAuthResponse {
654-
val accountFlow = AccountAuthFlow(coreClient, sessionService)
655-
return accountFlow.registerTOTP(
655+
val tfaFlow = TFAAuthFlow(coreClient, sessionService)
656+
return tfaFlow.registerTOTP(
656657
resolvableContext, mutableMapOf(
657658
"provider" to TFAProvider.TOTP.value,
658659
"mode" to "register"
@@ -661,8 +662,8 @@ internal class AuthTFA(
661662
}
662663

663664
override suspend fun getRegisteredPhoneNumbers(resolvableContext: ResolvableContext): IAuthResponse {
664-
val accountFlow = AccountAuthFlow(coreClient, sessionService)
665-
return accountFlow.getRegisteredPhoneNumbers(
665+
val tfaFlow = TFAAuthFlow(coreClient, sessionService)
666+
return tfaFlow.getRegisteredPhoneNumbers(
666667
resolvableContext, mutableMapOf(
667668
"provider" to TFAProvider.PHONE.value,
668669
"mode" to "verify"
@@ -676,8 +677,8 @@ internal class AuthTFA(
676677
method: TFAPhoneMethod?,
677678
language: String?
678679
): IAuthResponse {
679-
val accountFlow = AccountAuthFlow(coreClient, sessionService)
680-
return accountFlow.sendPhoneCode(
680+
val tfaFlow = TFAAuthFlow(coreClient, sessionService)
681+
return tfaFlow.sendPhoneCode(
681682
resolvableContext, mutableMapOf(
682683
"lang" to (language ?: "en"),
683684
"phoneID" to phoneId,
@@ -691,8 +692,8 @@ internal class AuthTFA(
691692
code: String,
692693
rememberDevice: Boolean?
693694
): IAuthResponse {
694-
val accountFlow = AccountAuthFlow(coreClient, sessionService)
695-
return accountFlow.verifyCode(
695+
val tfaFlow = TFAAuthFlow(coreClient, sessionService)
696+
return tfaFlow.verifyCode(
696697
resolvableContext,
697698
mutableMapOf("code" to code),
698699
TFAProvider.EMAIL,
@@ -705,8 +706,8 @@ internal class AuthTFA(
705706
code: String,
706707
rememberDevice: Boolean?
707708
): IAuthResponse {
708-
val accountFlow = AccountAuthFlow(coreClient, sessionService)
709-
return accountFlow.verifyCode(
709+
val tfaFlow = TFAAuthFlow(coreClient, sessionService)
710+
return tfaFlow.verifyCode(
710711
resolvableContext,
711712
mutableMapOf("code" to code),
712713
TFAProvider.PHONE,
@@ -719,8 +720,8 @@ internal class AuthTFA(
719720
code: String,
720721
rememberDevice: Boolean?
721722
): IAuthResponse {
722-
val accountFlow = AccountAuthFlow(coreClient, sessionService)
723-
return accountFlow.verifyCode(
723+
val tfaFlow = TFAAuthFlow(coreClient, sessionService)
724+
return tfaFlow.verifyCode(
724725
resolvableContext,
725726
mutableMapOf("code" to code),
726727
TFAProvider.TOTP,

0 commit comments

Comments
 (0)