@@ -73,6 +73,10 @@ public java.security.cert.X509Certificate[] getAcceptedIssuers()
7373 this .piconfig = privacyIDEA .configuration ();
7474
7575 OkHttpClient .Builder builder = new OkHttpClient .Builder ();
76+ builder .connectTimeout (piconfig .httpTimeoutMs , TimeUnit .MILLISECONDS )
77+ .writeTimeout (piconfig .httpTimeoutMs , TimeUnit .MILLISECONDS )
78+ .readTimeout (piconfig .httpTimeoutMs , TimeUnit .MILLISECONDS );
79+
7680 if (!this .piconfig .doSSLVerify )
7781 {
7882 // Trust all certs and verify every host
@@ -108,7 +112,7 @@ void sendRequestAsync(String endpoint, Map<String, String> params, Map<String, S
108112 if (httpUrl == null )
109113 {
110114 privacyIDEA .error ("Server url could not be parsed: " + (piconfig .serverURL + endpoint ));
111- // Invoke the callback to terminate the thread that called this method .
115+ // Invoke the callback to terminate the thread that called this function .
112116 callback .onFailure (null , new IOException ("Request could not be created because the url could not be parsed" ));
113117 return ;
114118 }
@@ -118,12 +122,7 @@ void sendRequestAsync(String endpoint, Map<String, String> params, Map<String, S
118122 {
119123 if (k .equals ("pass" ) || k .equals ("password" ))
120124 {
121- StringBuilder tmp = new StringBuilder ();
122- for (int i = 0 ; i < v .length (); i ++)
123- {
124- tmp .append ("*" );
125- }
126- v = tmp .toString ();
125+ v = "*" .repeat (v .length ());
127126 }
128127
129128 privacyIDEA .log (k + "=" + v );
@@ -133,15 +132,8 @@ void sendRequestAsync(String endpoint, Map<String, String> params, Map<String, S
133132 {
134133 params .forEach ((key , value ) ->
135134 {
136- try
137- {
138- String encValue = URLEncoder .encode (value , StandardCharsets .UTF_8 .toString ());
139- urlBuilder .addQueryParameter (key , encValue );
140- }
141- catch (UnsupportedEncodingException e )
142- {
143- e .printStackTrace ();
144- }
135+ String encValue = URLEncoder .encode (value , StandardCharsets .UTF_8 );
136+ urlBuilder .addQueryParameter (key , encValue );
145137 });
146138 }
147139
@@ -168,14 +160,7 @@ void sendRequestAsync(String endpoint, Map<String, String> params, Map<String, S
168160 // they are already in the correct encoding for the server
169161 if (!WEBAUTHN_PARAMETERS .contains (key ))
170162 {
171- try
172- {
173- encValue = URLEncoder .encode (value , StandardCharsets .UTF_8 .toString ());
174- }
175- catch (UnsupportedEncodingException e )
176- {
177- privacyIDEA .error (e );
178- }
163+ encValue = URLEncoder .encode (value , StandardCharsets .UTF_8 );
179164 }
180165 formBodyBuilder .add (key , encValue );
181166 }
0 commit comments