Skip to content

Commit 3b60260

Browse files
NFC-83 Add cert and sign constant for WebEidScreen. Move AppModules from java to kotlin. Add licences headers.
1 parent 15eab1f commit 3b60260

File tree

25 files changed

+479
-27
lines changed

25 files changed

+479
-27
lines changed

app/src/androidTest/kotlin/ee/ria/DigiDoc/viewmodel/WebEidViewModelTest.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* Copyright 2017 - 2026 Riigi Infosüsteemi Amet
3+
*
4+
* This library is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Lesser General Public
6+
* License as published by the Free Software Foundation; either
7+
* version 2.1 of the License, or (at your option) any later version.
8+
*
9+
* This library is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public
15+
* License along with this library; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+
*
18+
*/
19+
120
@file:Suppress("PackageName")
221

322
package ee.ria.DigiDoc.viewmodel

app/src/main/kotlin/ee/ria/DigiDoc/fragment/WebEidFragment.kt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* Copyright 2017 - 2026 Riigi Infosüsteemi Amet
3+
*
4+
* This library is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Lesser General Public
6+
* License as published by the Free Software Foundation; either
7+
* version 2.1 of the License, or (at your option) any later version.
8+
*
9+
* This library is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public
15+
* License along with this library; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+
*
18+
*/
19+
120
@file:Suppress("PackageName", "FunctionName")
221

322
package ee.ria.DigiDoc.fragment
@@ -19,7 +38,7 @@ import androidx.compose.ui.platform.testTag
1938
import androidx.compose.ui.semantics.semantics
2039
import androidx.compose.ui.semantics.testTagsAsResourceId
2140
import androidx.compose.ui.tooling.preview.Preview
22-
import androidx.hilt.navigation.compose.hiltViewModel
41+
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
2342
import androidx.navigation.NavHostController
2443
import androidx.navigation.compose.rememberNavController
2544
import ee.ria.DigiDoc.fragment.screen.WebEidScreen

app/src/main/kotlin/ee/ria/DigiDoc/fragment/screen/WebEidScreen.kt

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* Copyright 2017 - 2026 Riigi Infosüsteemi Amet
3+
*
4+
* This library is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Lesser General Public
6+
* License as published by the Free Software Foundation; either
7+
* version 2.1 of the License, or (at your option) any later version.
8+
*
9+
* This library is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public
15+
* License along with this library; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+
*
18+
*/
19+
120
@file:Suppress("PackageName", "FunctionName")
221

322
package ee.ria.DigiDoc.fragment.screen
@@ -81,6 +100,9 @@ import kotlinx.coroutines.flow.filterNotNull
81100
import kotlinx.coroutines.launch
82101
import kotlinx.coroutines.withContext
83102

103+
private const val WEB_EID_CERTIFICATE_PATH = "/certificate"
104+
private const val WEB_EID_SIGNATURE_PATH = "/signature"
105+
84106
@OptIn(ExperimentalMaterial3Api::class)
85107
@Composable
86108
fun WebEidScreen(
@@ -237,7 +259,11 @@ fun WebEidScreen(
237259
verticalArrangement = Arrangement.spacedBy(XSPadding),
238260
) {
239261
val responseUri = signRequest?.responseUri?.lowercase() ?: ""
240-
val isCertificateFlow = responseUri.contains("/certificate") && !responseUri.contains("/signature")
262+
val isCertificateFlow =
263+
responseUri.contains(WEB_EID_CERTIFICATE_PATH) &&
264+
!responseUri.contains(
265+
WEB_EID_SIGNATURE_PATH,
266+
)
241267

242268
val title =
243269
when {
@@ -303,7 +329,11 @@ fun WebEidScreen(
303329
}
304330
} else if (signRequest != null) {
305331
val responseUri = signRequest.responseUri.lowercase()
306-
val isCertificateFlow = responseUri.contains("/certificate") && !responseUri.contains("/signature")
332+
val isCertificateFlow =
333+
responseUri.contains(WEB_EID_CERTIFICATE_PATH) &&
334+
!responseUri.contains(
335+
WEB_EID_SIGNATURE_PATH,
336+
)
307337

308338
if (!isWebEidAuthenticating) {
309339
WebEidSignOrCertificateInfo(
@@ -403,7 +433,11 @@ fun WebEidScreen(
403433
}
404434
} else if (signRequest != null) {
405435
val responseUri = signRequest.responseUri.lowercase()
406-
val isCertificateFlow = responseUri.contains("/certificate") && !responseUri.contains("/signature")
436+
val isCertificateFlow =
437+
responseUri.contains(WEB_EID_CERTIFICATE_PATH) &&
438+
!responseUri.contains(
439+
WEB_EID_SIGNATURE_PATH,
440+
)
407441

408442
Button(
409443
onClick = {

app/src/main/kotlin/ee/ria/DigiDoc/viewmodel/WebEidViewModel.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* Copyright 2017 - 2026 Riigi Infosüsteemi Amet
3+
*
4+
* This library is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Lesser General Public
6+
* License as published by the Free Software Foundation; either
7+
* version 2.1 of the License, or (at your option) any later version.
8+
*
9+
* This library is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public
15+
* License along with this library; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+
*
18+
*/
19+
120
@file:Suppress("PackageName")
221

322
package ee.ria.DigiDoc.viewmodel

web-eid-lib/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
}
77

88
android {
9-
namespace = "com.example.web_eid_lib"
9+
namespace = "ee.ria.DigiDoc.webEid"
1010
compileSdk = Integer.parseInt(libs.versions.compileSdkVersion.get())
1111

1212
defaultConfig {

web-eid-lib/src/androidTest/java/ee/ria/DigiDoc/webEid/WebEidAuthServiceTest.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* Copyright 2017 - 2026 Riigi Infosüsteemi Amet
3+
*
4+
* This library is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Lesser General Public
6+
* License as published by the Free Software Foundation; either
7+
* version 2.1 of the License, or (at your option) any later version.
8+
*
9+
* This library is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public
15+
* License along with this library; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+
*
18+
*/
19+
120
@file:Suppress("PackageName")
221

322
package ee.ria.DigiDoc.webEid

web-eid-lib/src/androidTest/java/ee/ria/DigiDoc/webEid/WebEidRequestParserTest.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* Copyright 2017 - 2026 Riigi Infosüsteemi Amet
3+
*
4+
* This library is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Lesser General Public
6+
* License as published by the Free Software Foundation; either
7+
* version 2.1 of the License, or (at your option) any later version.
8+
*
9+
* This library is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public
15+
* License along with this library; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+
*
18+
*/
19+
120
@file:Suppress("PackageName")
221

322
package ee.ria.DigiDoc.webEid

web-eid-lib/src/androidTest/java/ee/ria/DigiDoc/webEid/WebEidSignServiceTest.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* Copyright 2017 - 2026 Riigi Infosüsteemi Amet
3+
*
4+
* This library is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Lesser General Public
6+
* License as published by the Free Software Foundation; either
7+
* version 2.1 of the License, or (at your option) any later version.
8+
*
9+
* This library is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public
15+
* License along with this library; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+
*
18+
*/
19+
120
@file:Suppress("PackageName")
221

322
package ee.ria.DigiDoc.webEid

web-eid-lib/src/androidTest/java/ee/ria/DigiDoc/webEid/di/AppModulesTest.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* Copyright 2017 - 2026 Riigi Infosüsteemi Amet
3+
*
4+
* This library is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Lesser General Public
6+
* License as published by the Free Software Foundation; either
7+
* version 2.1 of the License, or (at your option) any later version.
8+
*
9+
* This library is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public
15+
* License along with this library; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+
*
18+
*/
19+
120
@file:Suppress("PackageName")
221

322
package ee.ria.DigiDoc.webEid.di

web-eid-lib/src/androidTest/java/ee/ria/DigiDoc/webEid/exception/WebEidExceptionTest.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* Copyright 2017 - 2026 Riigi Infosüsteemi Amet
3+
*
4+
* This library is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Lesser General Public
6+
* License as published by the Free Software Foundation; either
7+
* version 2.1 of the License, or (at your option) any later version.
8+
*
9+
* This library is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public
15+
* License along with this library; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+
*
18+
*/
19+
120
@file:Suppress("PackageName")
221

322
package ee.ria.DigiDoc.webEid.exception

0 commit comments

Comments
 (0)