import groovy.json.JsonSlurper import io.opentelemetry.api.trace.Span def url = parameters.get('url') try { //TODO/haburger/2024-AUG-20: remove if reCaptcha is not needed anymore session.remove('agov.fido2.X-ReCAPTCHA-Integration') def spanCtxt = Span.current().getSpanContext() def traceparent = "00-${spanCtxt.getTraceId()}-${spanCtxt.getSpanId()}-${spanCtxt.getTraceFlags().asHex()}" LOG.error('traceparent: ' + traceparent) 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.fido2.json.captchaSettings.enabled', String.valueOf(json.captchaSettings.enabled)) // response.setSessionAttribute('agov.fido2.json.captchaSettings.reCaptchaInvisibleSiteKey', json.captchaSettings.reCaptchaInvisibleSiteKey) // response.setSessionAttribute('agov.fido2.json.captchaSettings.reCaptchaVisibleSiteKey', json.captchaSettings.reCaptchaVisibleSiteKey) // // if (session.get('agov.fido2.X-ReCAPTCHA-Integration') == null) { // response.setSessionAttribute('agov.fido2.X-ReCAPTCHA-Integration', 'INVISIBLE') // } else { // response.setSessionAttribute('agov.fido2.X-ReCAPTCHA-Integration', 'VISIBLE') // } response.setSessionAttribute('agov.fido2.captchaSettings.enabled', String.valueOf(json.friendlyCaptureClientSettings.enabled)) response.setSessionAttribute('agov.fido2.captchaSettings.siteKey', json.friendlyCaptureClientSettings.siteKey) response.setSessionAttribute('agov.fido2.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') }