Skip to content

Commit b712eb0

Browse files
NFC-83 Origin fix for signing and cert. klintCheck
1 parent 4074a7d commit b712eb0

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

app/src/main/kotlin/ee/ria/DigiDoc/MainActivity.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,12 @@ class MainActivity :
123123
val locale = dataStore.getLocale() ?: getLocale("en")
124124
val webEidUri = intent?.data?.takeIf { it.scheme == "web-eid-mobile" }
125125

126-
val externalFileUris = if (webEidUri != null) {
127-
listOf()
128-
} else {
129-
getExternalFileUris(intent)
130-
}
126+
val externalFileUris =
127+
if (webEidUri != null) {
128+
listOf()
129+
} else {
130+
getExternalFileUris(intent)
131+
}
131132

132133
localeUtil.updateLocale(applicationContext, locale)
133134

@@ -172,7 +173,7 @@ class MainActivity :
172173
RIADigiDocTheme(darkTheme = useDarkMode) {
173174
RIADigiDocAppScreen(
174175
externalFileUris = externalFileUris,
175-
webEidUri = webEidUri
176+
webEidUri = webEidUri,
176177
)
177178
}
178179
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,10 @@ class WebEidRequestParserTest {
221221
private fun createSignUri(
222222
hash: String?,
223223
hashFunction: String?,
224-
origin: String? = "https://rp.example.com",
225224
): String {
226225
val responseUri = "https://rp.example.com/sign/response"
227226
val sb = StringBuilder()
228227
sb.append("{\"response_uri\":\"$responseUri\"")
229-
if (origin != null) sb.append(",\"origin\":\"$origin\"")
230228
if (hash != null) sb.append(",\"hash\":\"$hash\"")
231229
if (hashFunction != null) sb.append(",\"hash_function\":\"$hashFunction\"")
232230
sb.append("}")

web-eid-lib/src/main/java/ee/ria/DigiDoc/webEid/utils/WebEidRequestParser.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ object WebEidRequestParser {
2121
val request = decodeUriFragment(authUri)
2222
val challenge = request.getString("challenge")
2323
val responseUri = validateResponseUri(request.getString("login_uri"))
24-
val origin = parseOrigin(responseUri)
2524
if (challenge.isNullOrBlank() ||
2625
challenge.length < MIN_CHALLENGE_LENGTH ||
2726
challenge.length > MAX_CHALLENGE_LENGTH
@@ -37,18 +36,17 @@ object WebEidRequestParser {
3736
challenge = challenge,
3837
loginUri = responseUri.toString(),
3938
getSigningCertificate = request.optBoolean("get_signing_certificate", false),
40-
origin = origin,
39+
origin = parseOrigin(responseUri),
4140
)
4241
}
4342

4443
fun parseCertificateUri(uri: Uri): WebEidSignRequest {
4544
val request = decodeUriFragment(uri)
4645
val responseUri = validateResponseUri(request.optString("response_uri", ""))
47-
val origin = request.optString("origin", "")
4846

4947
return WebEidSignRequest(
5048
responseUri = responseUri.toString(),
51-
origin = origin,
49+
origin = parseOrigin(responseUri),
5250
hash = null,
5351
hashFunction = null,
5452
)
@@ -59,7 +57,6 @@ object WebEidRequestParser {
5957
val responseUri = validateResponseUri(request.optString("response_uri", ""))
6058
val hash = request.optString("hash", "")
6159
val hashFunction = request.optString("hash_function", "")
62-
val origin = request.optString("origin", "")
6360

6461
if (hash.isBlank() || hashFunction.isBlank()) {
6562
throw WebEidException(
@@ -71,7 +68,7 @@ object WebEidRequestParser {
7168

7269
return WebEidSignRequest(
7370
responseUri = responseUri.toString(),
74-
origin = origin,
71+
origin = parseOrigin(responseUri),
7572
hash = hash,
7673
hashFunction = hashFunction,
7774
)

0 commit comments

Comments
 (0)