Source:
public static String oidcClientBearer(String oidcUsername, String oidcPassword, OidcConfiguration oidcConfiguration) throws java.lang.Exception { if (oidcConfiguration == null) { throw new IllegalArgumentException( "OIDC configuration is not set"); } if (oidcUsername == null || oidcUsername.isEmpty()) { throw new IllegalArgumentException( "OIDC username is a required parameter"); } if (oidcPassword == null) { throw new IllegalArgumentException( "OIDC password is a required parameter"); } String tokenEndpoint = oidcConfiguration.getTokenEndpoint(); if (tokenEndpoint == null || tokenEndpoint.isEmpty()) { throw new Exception("Token endpoint setting is null or empty"); } String clientId = oidcConfiguration.getPublicClientId(); if (clientId == null || clientId.isEmpty()) { throw new Exception("OIDC client ID setting is null or empty"); } String clientSecret = oidcConfiguration.getClientSecret(); String scope = oidcConfiguration.getScope(); @SuppressWarnings("rawtypes") WebClient webClient = WebClient .create(tokenEndpoint, java.util.Collections .singletonList(new org.apache.cxf.jaxrs.provider.json.JSONProvider())) .type("application/x-www-form-urlencoded"); Response response = webClient.post("grant_type=password&scope=" + scope + "&username=" + oidcUsername + "&password=" + oidcPassword + "&client_id=" + clientId); java.util.Map<String, String> responseMap; try { responseMap = parseJson((java.io.InputStream) response.getEntity()); } catch (Exception ex) { throw new Exception( "Can not parse response from OIDC Access Token service: ", ex); } if (response.getStatus() != 200) { if (responseMap.get("error") != null) { throw new Exception("OIDC Access Token request failed: " + responseMap.get("error")); } else { throw new Exception("OIDC token endpoint replied with HTTTP " + response.getStatus() + " on token request"); } } if (!"Bearer".equals(responseMap.get("token_type"))) { throw new Exception( "Token returned from OIDC Access Token service is not of Bearer type"); } return "Bearer " + responseMap.get("access_token"); }

Target:
public static String oidcClientBearer(String oidcUsername, String oidcPassword, OidcConfiguration oidcConfiguration) throws java.lang.Exception { if (oidcConfiguration == null) { throw new IllegalArgumentException( "OIDC configuration is not set"); } if (oidcUsername == null || oidcUsername.isEmpty()) { throw new IllegalArgumentException( "OIDC username is a required parameter"); } if (oidcPassword == null) { throw new IllegalArgumentException( "OIDC password is a required parameter"); } String tokenEndpoint = oidcConfiguration.getTokenEndpoint(); if (tokenEndpoint == null || tokenEndpoint.isEmpty()) { throw new Exception("Token endpoint setting is null or empty"); } String clientId = oidcConfiguration.getPublicClientId(); if (clientId == null || clientId.isEmpty()) { throw new Exception("OIDC client ID setting is null or empty"); } String scope = oidcConfiguration.getScope(); @SuppressWarnings("rawtypes") WebClient webClient = WebClient .create(tokenEndpoint, java.util.Collections .singletonList(new org.apache.cxf.jaxrs.provider.json.JSONProvider())) .type("application/x-www-form-urlencoded"); Response response = webClient.post("grant_type=password&scope=" + scope + "&username=" + oidcUsername + "&password=" + oidcPassword + "&client_id=" + clientId); java.util.Map<String, String> responseMap; try { responseMap = parseJson((java.io.InputStream) response.getEntity()); } catch (Exception ex) { throw new Exception( "Can not parse response from OIDC Access Token service: ", ex); } if (response.getStatus() != 200) { if (responseMap.get("error") != null) { throw new Exception("OIDC Access Token request failed: " + responseMap.get("error")); } else { throw new Exception("OIDC token endpoint replied with HTTTP " + response.getStatus() + " on token request"); } } if (!"Bearer".equals(responseMap.get("token_type"))) { throw new Exception( "Token returned from OIDC Access Token service is not of Bearer type"); } return "Bearer " + responseMap.get("access_token"); }