use of com.nimbusds.jose.shaded.json.JSONObject in project kf-key-management by kids-first.
the class FenceResourceDeprecated method getAuthClient.
@GetMapping("/auth-client")
public Mono<JSONObject> getAuthClient(@RequestParam("fence") String fenceKey) throws IllegalArgumentException {
val fence = fenceService.getFence(fenceKey);
// No UserID check - no auth required
val body = new JSONObject();
body.put("client_id", fence.getClientId());
body.put("redirect_uri", fence.getRedirectUri());
body.put("scope", fence.getScope());
return Mono.just(body);
}
use of com.nimbusds.jose.shaded.json.JSONObject in project kf-key-management by kids-first.
the class FenceResourceDeprecated method refresh.
@PostMapping("/refresh")
public Mono<ResponseEntity<JSONObject>> refresh(@RequestParam("fence") String fenceKey, JwtAuthenticationToken authentication) {
val userId = authentication.getTokenAttributes().get("sub").toString();
val fence = fenceService.getFence(fenceKey);
val storedRefresh = secretService.fetchRefreshToken(fence, userId);
return storedRefresh.flatMap(refresh -> fenceService.refreshTokens(refresh, fence)).flatMap(tokens -> {
val body = new JSONObject();
body.put("access_token", tokens.getAccessToken().getValue());
body.put("refresh_token", tokens.getRefreshToken().getValue());
return secretService.persistTokens(fence, userId, tokens).then(Mono.just(ResponseEntity.ok().body(body)));
}).defaultIfEmpty(ResponseEntity.notFound().build());
}
use of com.nimbusds.jose.shaded.json.JSONObject in project kf-key-management by kids-first.
the class FenceResourceDeprecated method requestTokens.
@PostMapping("/token")
public Mono<ResponseEntity<JSONObject>> requestTokens(@RequestParam("code") String authCode, @RequestParam("fence") String fenceKey, JwtAuthenticationToken authentication) {
val userId = authentication.getTokenAttributes().get("sub").toString();
val fence = fenceService.getFence(fenceKey);
return fenceService.requestTokens(authCode, fence).flatMap(t -> {
val body = new JSONObject();
body.put("access_token", t.getAccessToken().getValue());
body.put("refresh_token", t.getRefreshToken().getValue());
val response = ResponseEntity.ok().body(body);
return secretService.persistTokens(fence, userId, t, true).then(Mono.just(response));
}).defaultIfEmpty(ResponseEntity.notFound().build());
}
use of com.nimbusds.jose.shaded.json.JSONObject in project kf-key-management by kids-first.
the class FenceResourceDeprecated method getTokens.
@GetMapping("/token")
public Mono<ResponseEntity<JSONObject>> getTokens(@RequestParam("fence") String fenceKey, JwtAuthenticationToken authentication) {
val userId = authentication.getTokenAttributes().get("sub").toString();
val fence = fenceService.getFence(fenceKey);
val accessToken = secretService.fetchAccessToken(fence, userId);
val refreshToken = secretService.fetchRefreshToken(fence, userId);
return accessToken.zipWith(refreshToken).map(Tuple2::getT1).map(token -> {
val body = new JSONObject();
body.put("access_token", token);
return ResponseEntity.ok(body);
}).defaultIfEmpty(ResponseEntity.notFound().build()).onErrorReturn(ResponseEntity.notFound().build());
}
use of com.nimbusds.jose.shaded.json.JSONObject in project kf-key-management by kids-first.
the class CavaticaTests method testCavaticaPostWithoutBody.
@Test
void testCavaticaPostWithoutBody() {
JSONObject content = new JSONObject();
content.put("path", "/user");
content.put("method", "GET");
cavaticaWM.stubFor(get("/user").willReturn(ok(cavaticaResponseBody)));
webClient.post().uri("/cavatica").contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + defaultAccessToken).bodyValue(content.toJSONString()).exchange().expectStatus().isOk().expectBody().json(cavaticaResponseBody);
}
Aggregations