import groovy.json.JsonSlurper def url = parameters.get('url') try { def jsonSlurper = new JsonSlurper() def httpClient = HttpClients.create(parameters) def httpResponse = Http.get().url(url).build().send(httpClient) LOG.debug('Response Message: ' + httpResponse.reasonPhrase()) LOG.debug('Response Status Code: ' + httpResponse.code()) LOG.debug('Response: ' + httpResponse.bodyAsString()) if (httpResponse.code() == 200) { def json = jsonSlurper.parseText(httpResponse.bodyAsString()) // TODO/haburger/2024-AUG-20: remove if reCaptcha is not needed anymore // response.setSessionAttribute('agov.recovery.json.accountUrl', json.accountUrl) // response.setSessionAttribute('agov.recovery.json.registrationUrl', json.registrationUrl) // response.setSessionAttribute('agov.recovery.json.captchaSettings.enabled', String.valueOf(json.captchaSettings.enabled)) // response.setSessionAttribute('agov.recovery.json.captchaSettings.reCaptchaInvisibleSiteKey', json.captchaSettings.reCaptchaInvisibleSiteKey) // response.setSessionAttribute('agov.recovery.json.captchaSettings.reCaptchaVisibleSiteKey', json.captchaSettings.reCaptchaVisibleSiteKey) // if (session.get('agov.recovery.X-ReCAPTCHA-Integration') == null) { // response.setSessionAttribute('agov.recovery.X-ReCAPTCHA-Integration', 'INVISIBLE') // } else { // response.setSessionAttribute('agov.recovery.X-ReCAPTCHA-Integration', 'VISIBLE') // } response.setSessionAttribute('agov.recovery.captchaSettings.enabled', String.valueOf(json.captchaSettings.enabled)) response.setSessionAttribute('agov.recovery.captchaSettings.siteKey', json.friendlyCaptureClientSettings.siteKey) response.setSessionAttribute('agov.recovery.captchaSettings.puzzleUrl', json.friendlyCaptureClientSettings.puzzleUrl) response.setResult('ok') } else { LOG.error('Unexcpected HTTP response code: ' + httpResponse.code()) response.setResult('error') response.setError(1, 'Unexpected HTTP reponse') } } catch (all) { // Handle exception and set the transition LOG.error('error: ' + all, all) response.setResult('error') response.setError(1, 'Exception during HTTP call') }