示例#1
0
  @ApiOperation("Retrieve the keycloak JSON configuration (for use by the UI)")
  @ApiResponses({
    @ApiResponse(code = 400, message = "Keycloak is disabled"),
    @ApiResponse(code = 200, message = "File retrieval successful")
  })
  @Path("/keycloak.json")
  @Produces("application/json")
  @GET
  public Response getKeycloakUiJson() {
    logger.debug("Retrieving Keycloak UI JSON file...");
    Response response = null;
    try {
      final String content = controller.getKeycloakUiJson();
      if (content == null) {
        response =
            Response.status(Status.BAD_REQUEST)
                .entity(DISABLED_MESSAGE)
                .header(ApplicationHeader.cache_control.key(), NO_CACHE)
                .build();
      } else {
        response =
            Response.ok(content).header(ApplicationHeader.cache_control.key(), NO_CACHE).build();
      }
    } catch (final IndyWorkflowException e) {
      logger.error(
          String.format("Failed to load client-side keycloak.json. Reason: %s", e.getMessage()), e);
      response = formatResponse(e);
    }

    return response;
  }