forked from EWC-consortium/eudi-wallet-oid4vc-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Support for client_metadata_uri
- Loading branch information
Showing
5 changed files
with
140 additions
and
50 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
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
33 changes: 33 additions & 0 deletions
33
...et-oidc-android/src/main/java/com/ewc/eudi_wallet_oidc_android/services/utils/JwtUtils.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,33 @@ | ||
package com.ewc.eudi_wallet_oidc_android.services.utils | ||
|
||
import com.nimbusds.jose.shaded.json.parser.ParseException | ||
import com.nimbusds.jwt.SignedJWT | ||
|
||
object JwtUtils { | ||
fun isValidJWT(token: String?): Boolean { | ||
if (token.isNullOrBlank()) | ||
return false | ||
try { | ||
// Parse the JWT token | ||
val parsedJWT = SignedJWT.parse(token) | ||
return parsedJWT.payload != null | ||
} catch (e: Exception) { | ||
println("JWT parsing failed: ${e.message}") | ||
return false | ||
} | ||
} | ||
|
||
@Throws(ParseException::class) | ||
fun parseJWTForPayload(accessToken: String?): String { | ||
if (accessToken.isNullOrBlank()) | ||
throw java.lang.Exception("Invalid token!") | ||
try { | ||
val decodedJWT = SignedJWT.parse(accessToken) | ||
return decodedJWT.payload.toString() | ||
} catch (e: ParseException) { | ||
throw java.lang.Exception(e.message ?: "Invalid token!") | ||
} catch (e: Exception){ | ||
throw java.lang.Exception("Invalid token!") | ||
} | ||
} | ||
} |
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