@Test public void testDecodeJwt() throws Exception { final byte[] keyBytes = "AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow" .getBytes(StandardCharsets.UTF_8); SecretKey key = new SecretKeySpec(keyBytes, 0, keyBytes.length, "HMACSHA256"); String jwt = Jwt.claims().sign(key); assertNull(OidcUtils.decodeJwtContent(jwt + ".4")); JsonObject json = OidcUtils.decodeJwtContent(jwt); assertTrue(json.containsKey("iat")); assertTrue(json.containsKey("exp")); assertTrue(json.containsKey("jti")); }
public static JsonObject decodeJwtContent(String jwt) { StringTokenizer tokens = new StringTokenizer(jwt, "."); tokens.nextToken(); if (!tokens.hasMoreTokens()) { return null; } String encodedContent = tokens.nextToken(); if (tokens.countTokens() != 1) { return null; } try { return new JsonObject(new String(Base64.getUrlDecoder().decode(encodedContent), StandardCharsets.UTF_8)); } catch (IllegalArgumentException ex) { return null; } }
OidcUtils { public static JsonObject decodeJwtContent(String jwt) { StringTokenizer tokens = new StringTokenizer(jwt, "."); tokens.nextToken(); if (!tokens.hasMoreTokens()) { return null; } String encodedContent = tokens.nextToken(); if (tokens.countTokens() != 1) { return null; } try { return new JsonObject(new String(Base64.getUrlDecoder().decode(encodedContent), StandardCharsets.UTF_8)); } catch (IllegalArgumentException ex) { return null; } } }
OidcUtils { public static JsonObject decodeJwtContent(String jwt) { StringTokenizer tokens = new StringTokenizer(jwt, "."); tokens.nextToken(); if (!tokens.hasMoreTokens()) { return null; } String encodedContent = tokens.nextToken(); if (tokens.countTokens() != 1) { return null; } try { return new JsonObject(new String(Base64.getUrlDecoder().decode(encodedContent), StandardCharsets.UTF_8)); } catch (IllegalArgumentException ex) { return null; } } private  OidcUtils(); }
OidcUtils { public static JsonObject decodeJwtContent(String jwt) { StringTokenizer tokens = new StringTokenizer(jwt, "."); tokens.nextToken(); if (!tokens.hasMoreTokens()) { return null; } String encodedContent = tokens.nextToken(); if (tokens.countTokens() != 1) { return null; } try { return new JsonObject(new String(Base64.getUrlDecoder().decode(encodedContent), StandardCharsets.UTF_8)); } catch (IllegalArgumentException ex) { return null; } } private  OidcUtils(); static boolean isOpaqueToken(String token); static JsonObject decodeJwtContent(String jwt); static boolean validateClaims(OidcTenantConfig.Token tokenConfig, JsonObject json); static List<String> findRoles(String clientId, OidcTenantConfig.Roles rolesConfig, JsonObject json); static void setSecurityIdentityRoles(QuarkusSecurityIdentity.Builder builder, OidcTenantConfig config,
            JsonObject rolesJson); static void setBlockinApiAttribute(QuarkusSecurityIdentity.Builder builder, RoutingContext vertxContext); static void setTenantIdAttribute(QuarkusSecurityIdentity.Builder builder, OidcTenantConfig config); static void setSecurityIdentityUserInfo(QuarkusSecurityIdentity.Builder builder, JsonObject userInfo); static void validatePrimaryJwtTokenType(OidcTenantConfig.Token tokenConfig, JsonObject tokenJson); }
OidcUtils { public static JsonObject decodeJwtContent(String jwt) { StringTokenizer tokens = new StringTokenizer(jwt, "."); tokens.nextToken(); if (!tokens.hasMoreTokens()) { return null; } String encodedContent = tokens.nextToken(); if (tokens.countTokens() != 1) { return null; } try { return new JsonObject(new String(Base64.getUrlDecoder().decode(encodedContent), StandardCharsets.UTF_8)); } catch (IllegalArgumentException ex) { return null; } } private  OidcUtils(); static boolean isOpaqueToken(String token); static JsonObject decodeJwtContent(String jwt); static boolean validateClaims(OidcTenantConfig.Token tokenConfig, JsonObject json); static List<String> findRoles(String clientId, OidcTenantConfig.Roles rolesConfig, JsonObject json); static void setSecurityIdentityRoles(QuarkusSecurityIdentity.Builder builder, OidcTenantConfig config,
            JsonObject rolesJson); static void setBlockinApiAttribute(QuarkusSecurityIdentity.Builder builder, RoutingContext vertxContext); static void setTenantIdAttribute(QuarkusSecurityIdentity.Builder builder, OidcTenantConfig config); static void setSecurityIdentityUserInfo(QuarkusSecurityIdentity.Builder builder, JsonObject userInfo); static void validatePrimaryJwtTokenType(OidcTenantConfig.Token tokenConfig, JsonObject tokenJson);  }