@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; }
@ApiOperation("Retrieve the keycloak Javascript adapter (for use by the UI)") @ApiResponses({ @ApiResponse( code = 200, message = "Keycloak is disabled, return a Javascript comment to this effect."), @ApiResponse(code = 307, message = "Redirect to keycloak server to load Javascript adapter.") }) @Path("/keycloak.js") @Produces("text/javascript") @GET public Response getKeycloakJs() { logger.debug("Retrieving Keycloak Javascript adapter..."); Response response = null; try { final String url = controller.getKeycloakJs(); if (url == null) { response = Response.ok("/* " + DISABLED_MESSAGE + "; loading of keycloak.js blocked. */") .header(ApplicationHeader.cache_control.key(), NO_CACHE) .build(); } else { response = Response.temporaryRedirect(new URI(url)).build(); } } catch (final IndyWorkflowException | URISyntaxException e) { logger.error(String.format("Failed to load keycloak.js. Reason: %s", e.getMessage()), e); response = formatResponse(e); } return response; }
@ApiOperation("Retrieve the keycloak init Javascript (for use by the UI)") @ApiResponse(code = 200, message = "Always return 200 whether Keycloak is disabled or not") @Path("/keycloak-init.js") @Produces("text/javascript") @GET public Response getKeycloakInit() { logger.debug("Retrieving Keycloak UI-init Javascript file..."); Response response = null; try { response = Response.ok(controller.getKeycloakInit()) .header(ApplicationHeader.cache_control.key(), NO_CACHE) .build(); } catch (final IndyWorkflowException e) { logger.error(String.format("Failed to load keycloak-init.js. Reason: %s", e.getMessage()), e); response = formatResponse(e); } return response; }