From 5a152c0cb70b18fbb73b951515c7cadbd3c838c7 Mon Sep 17 00:00:00 2001 From: Jesus Federico <jesus@123it.ca> Date: Mon, 29 Sep 2014 14:48:21 -0400 Subject: [PATCH] bbb-lti: ssl_enabled is now validated only once --- .../org/bigbluebutton/LtiService.groovy | 67 ++++++++++--------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/bbb-lti/grails-app/services/org/bigbluebutton/LtiService.groovy b/bbb-lti/grails-app/services/org/bigbluebutton/LtiService.groovy index 1c2c229524..5f610351e1 100644 --- a/bbb-lti/grails-app/services/org/bigbluebutton/LtiService.groovy +++ b/bbb-lti/grails-app/services/org/bigbluebutton/LtiService.groovy @@ -26,11 +26,13 @@ import org.apache.commons.codec.binary.Base64 class LtiService { boolean transactional = false - - def endPoint = "http://localhost/lti/tool" + + def endPoint = "localhost" def consumers = "demo:welcome" def mode = "simple" + def ssl_enabled + Map<String, String> consumerMap def retrieveIconEndpoint() { @@ -97,35 +99,38 @@ class LtiService { } def boolean isSSLEnabled(String query) { - def sslEnabled = false - - try { - // open connection - StringBuilder urlStr = new StringBuilder(query) - URL url = new URL(urlStr.toString()) - HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection() - httpConnection.setUseCaches(false) - httpConnection.setDoOutput(true) - httpConnection.setRequestMethod("HEAD") - httpConnection.setConnectTimeout(5000) - httpConnection.connect() - - int responseCode = httpConnection.getResponseCode() - if (responseCode == HttpURLConnection.HTTP_OK) { - sslEnabled = true - } else { - log.debug("HTTPERROR: Message=" + "BBB server responded with HTTP status code " + responseCode) - } - - } catch(IOException e) { - log.debug("IOException: Message=" + e.getMessage()) - } catch(IllegalArgumentException e) { - log.debug("IllegalArgumentException: Message=" + e.getMessage()) - } catch(Exception e) { - log.debug("Exception: Message=" + e.getMessage()) - } - - return sslEnabled + if ( ssl_enabled == null ) { + ssl_enabled = false + log.debug("Pinging SSL connection") + + try { + // open connection + StringBuilder urlStr = new StringBuilder(query) + URL url = new URL(urlStr.toString()) + HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection() + httpConnection.setUseCaches(false) + httpConnection.setDoOutput(true) + httpConnection.setRequestMethod("HEAD") + httpConnection.setConnectTimeout(5000) + httpConnection.connect() + + int responseCode = httpConnection.getResponseCode() + if (responseCode == HttpURLConnection.HTTP_OK) { + ssl_enabled = true + } else { + log.debug("HTTPERROR: Message=" + "BBB server responded with HTTP status code " + responseCode) + } + + } catch(IOException e) { + log.debug("IOException: Message=" + e.getMessage()) + } catch(IllegalArgumentException e) { + log.debug("IllegalArgumentException: Message=" + e.getMessage()) + } catch(Exception e) { + log.debug("Exception: Message=" + e.getMessage()) + } + } + + return ssl_enabled } } -- GitLab