|
26 | 26 | import java.util.Objects; |
27 | 27 | import java.util.concurrent.ArrayBlockingQueue; |
28 | 28 | import java.util.concurrent.BlockingQueue; |
29 | | -import java.util.concurrent.Callable; |
30 | 29 | import java.util.concurrent.CountDownLatch; |
31 | 30 | import java.util.concurrent.ExecutionException; |
32 | 31 | import java.util.concurrent.Executors; |
@@ -95,7 +94,7 @@ private PrivacyIDEA(PIConfig configuration, IPILogger logger, IPISimpleLogger si |
95 | 94 | } |
96 | 95 | else |
97 | 96 | { |
98 | | - error("No service account configured. No JWT will be retrieved."); |
| 97 | + log("No service account configured. No JWT will be retrieved."); |
99 | 98 | } |
100 | 99 | } |
101 | 100 |
|
@@ -209,8 +208,14 @@ private PIResponse getPIResponse(String type, String input, String pass, Map<Str |
209 | 208 | { |
210 | 209 | params.put(TRANSACTION_ID, transactionID); |
211 | 210 | } |
212 | | - String response = runRequestAsync(ENDPOINT_VALIDATE_CHECK, params, headers, false, POST); |
213 | | - return this.parser.parsePIResponse(response); |
| 211 | + AsyncRequestCallable callable = submitRequest(ENDPOINT_VALIDATE_CHECK, params, headers, false, POST); |
| 212 | + PIResponse piResponse = this.parser.parsePIResponse(callable.body); |
| 213 | + if (piResponse != null) |
| 214 | + { |
| 215 | + // The rotated pi_remember_device cookie lives in the Set-Cookie response header, not the body. |
| 216 | + piResponse.setCookieHeaders = callable.setCookies; |
| 217 | + } |
| 218 | + return piResponse; |
214 | 219 | } |
215 | 220 |
|
216 | 221 | /** |
@@ -588,24 +593,33 @@ public boolean serviceAccountAvailable() |
588 | 593 | */ |
589 | 594 | private String runRequestAsync(String path, Map<String, String> params, Map<String, String> headers, boolean authorizationRequired, |
590 | 595 | String method) |
| 596 | + { |
| 597 | + return submitRequest(path, params, headers, authorizationRequired, method).body; |
| 598 | + } |
| 599 | + |
| 600 | + /** |
| 601 | + * Like {@link #runRequestAsync} but returns the completed callable so callers can also read |
| 602 | + * response metadata (e.g. Set-Cookie headers) that the plain body string does not carry. |
| 603 | + */ |
| 604 | + private AsyncRequestCallable submitRequest(String path, Map<String, String> params, Map<String, String> headers, |
| 605 | + boolean authorizationRequired, String method) |
591 | 606 | { |
592 | 607 | if (authorizationRequired) |
593 | 608 | { |
594 | 609 | // Wait for the JWT to be retrieved and add it to the header |
595 | 610 | headers.put(PIConstants.HEADER_AUTHORIZATION, getJWT()); |
596 | 611 | } |
597 | | - Callable<String> callable = new AsyncRequestCallable(this, this.endpoint, path, params, headers, method); |
| 612 | + AsyncRequestCallable callable = new AsyncRequestCallable(this, this.endpoint, path, params, headers, method); |
598 | 613 | Future<String> future = this.threadPool.submit(callable); |
599 | | - String response = null; |
600 | 614 | try |
601 | 615 | { |
602 | | - response = future.get(); |
| 616 | + callable.body = future.get(); |
603 | 617 | } |
604 | 618 | catch (InterruptedException | ExecutionException e) |
605 | 619 | { |
606 | 620 | log("runRequestAsync: " + e.getLocalizedMessage()); |
607 | 621 | } |
608 | | - return response; |
| 622 | + return callable; |
609 | 623 | } |
610 | 624 |
|
611 | 625 | /** |
|
0 commit comments