@Test public void testDecodeOpaqueTokenAsJwt() throws Exception { assertNull(OidcUtils.decodeJwtContent("123")); assertNull(OidcUtils.decodeJwtContent("1.23")); assertNull(OidcUtils.decodeJwtContent("1.2.3")); }
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);  }