1717
1818import java .io .IOException ;
1919import java .io .InputStream ;
20- import java .net .URLEncoder ;
21- import java .nio .charset .StandardCharsets ;
2220import java .security .KeyStore ;
2321import java .security .PrivateKey ;
2422import java .time .Duration ;
2523import java .util .Date ;
2624import java .util .HashMap ;
25+ import java .util .List ;
2726import java .util .Map ;
2827import java .util .UUID ;
29- import java .util .stream .Collectors ;
3028
3129import org .slf4j .Logger ;
3230import org .slf4j .LoggerFactory ;
@@ -71,19 +69,27 @@ public String getAccessToken()
7169 LOGGER .debug ("Getting access token..." );
7270 final String requestToken = this .createRequestToken ();
7371
74- final HashMap <String , String > parameters = new HashMap <>();
72+ final HashMap <String , Object > parameters = new HashMap <>();
7573 parameters .put ("grant_type" , "client_credentials" );
7674 parameters .put ("client_assertion_type" , "urn:ietf:params:oauth:client-assertion-type:jwt-bearer" );
7775 parameters .put ("client_assertion" , requestToken );
7876
79- return this .client .invokeAPI (
80- this . configuration . getRealmEnvironmentBaseUrl () + "/auth/realms/mds/protocol/openid-connect/token" ,
77+ return this .client .getApiClient (). invokeAPI (
78+ "/auth/realms/mds/protocol/openid-connect/token" ,
8179 "POST" ,
82- this .createFormForParameters (parameters ),
80+ List .of (),
81+ List .of (),
82+ "" ,
83+ null ,
84+ Map .of (),
85+ Map .of (),
86+ parameters ,
87+ "" ,
88+ "application/x-www-form-urlencoded;charset=UTF8" ,
89+ new String []{},
8390 new TypeReference <AccessTokenHttpResponse >()
8491 {
85- },
86- Map .of ("Content-Type" , "application/x-www-form-urlencoded" )
92+ }
8793 ).getAccessToken ();
8894 }
8995
@@ -92,14 +98,6 @@ public String getAccessTokenWithBearerPrefix()
9298 return BEARER_STRING + this .getAccessToken ();
9399 }
94100
95- private String createFormForParameters (final HashMap <String , String > parameters )
96- {
97- // Creating form with all parameters
98- return parameters .keySet ().stream ()
99- .map (key -> key + "=" + URLEncoder .encode (parameters .get (key ), StandardCharsets .UTF_8 ))
100- .collect (Collectors .joining ("&" ));
101- }
102-
103101 private String createRequestToken ()
104102 {
105103 LOGGER .debug ("Creating jwt token..." );
0 commit comments