@Test public void testKeycloakRefreshTokenType() throws Exception { JsonObject json = new JsonObject(); json.put("typ", "Refresh"); try { OidcUtils.validatePrimaryJwtTokenType(new OidcTenantConfig.Token(), json); fail("Exception expected: wrong token type"); } catch (OIDCException ex) { } }
public static void validatePrimaryJwtTokenType(OidcTenantConfig.Token tokenConfig, JsonObject tokenJson) { if (tokenJson.containsKey("typ")) { String type = tokenJson.getString("typ"); if (tokenConfig.getTokenType().isPresent() && !tokenConfig.getTokenType().get().equals(type)) { throw new OIDCException("Invalid token type"); } else if ("Refresh".equals(type)) { throw new OIDCException("Refresh token can only be used with the refresh token grant"); } } }
OidcUtils { public static void validatePrimaryJwtTokenType(OidcTenantConfig.Token tokenConfig, JsonObject tokenJson) { if (tokenJson.containsKey("typ")) { String type = tokenJson.getString("typ"); if (tokenConfig.getTokenType().isPresent() && !tokenConfig.getTokenType().get().equals(type)) { throw new OIDCException("Invalid token type"); } else if ("Refresh".equals(type)) { throw new OIDCException("Refresh token can only be used with the refresh token grant"); } } } }
OidcUtils { public static void validatePrimaryJwtTokenType(OidcTenantConfig.Token tokenConfig, JsonObject tokenJson) { if (tokenJson.containsKey("typ")) { String type = tokenJson.getString("typ"); if (tokenConfig.getTokenType().isPresent() && !tokenConfig.getTokenType().get().equals(type)) { throw new OIDCException("Invalid token type"); } else if ("Refresh".equals(type)) { throw new OIDCException("Refresh token can only be used with the refresh token grant"); } } } private  OidcUtils(); }
OidcUtils { public static void validatePrimaryJwtTokenType(OidcTenantConfig.Token tokenConfig, JsonObject tokenJson) { if (tokenJson.containsKey("typ")) { String type = tokenJson.getString("typ"); if (tokenConfig.getTokenType().isPresent() && !tokenConfig.getTokenType().get().equals(type)) { throw new OIDCException("Invalid token type"); } else if ("Refresh".equals(type)) { throw new OIDCException("Refresh token can only be used with the refresh token grant"); } } } 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 void validatePrimaryJwtTokenType(OidcTenantConfig.Token tokenConfig, JsonObject tokenJson) { if (tokenJson.containsKey("typ")) { String type = tokenJson.getString("typ"); if (tokenConfig.getTokenType().isPresent() && !tokenConfig.getTokenType().get().equals(type)) { throw new OIDCException("Invalid token type"); } else if ("Refresh".equals(type)) { throw new OIDCException("Refresh token can only be used with the refresh token grant"); } } } 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);  }