summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjakefeasel <jfeasel@gmail.com>2015-03-15 15:34:44 -0700
committerjakefeasel <jfeasel@gmail.com>2015-03-15 15:34:44 -0700
commit7a5adf3a4413e55b244c465874527d694f2d75d6 (patch)
tree0afd48078fe8fb21e607f85711af9b21ad510f73
parentee72259658b967384b2c1b92006280e10999bfda (diff)
downloadsqlfiddle2-7a5adf3a4413e55b244c465874527d694f2d75d6.zip
sqlfiddle2-7a5adf3a4413e55b244c465874527d694f2d75d6.tar.gz
sqlfiddle2-7a5adf3a4413e55b244c465874527d694f2d75d6.tar.bz2
Work-around for buggy behavior of restlet when making external/rest calls
-rw-r--r--src/main/resources/conf/endpoint-restClient.json5
-rw-r--r--src/main/resources/conf/script.json38
-rw-r--r--src/main/resources/script/oidc.js2
-rw-r--r--src/main/resources/script/restClient.groovy13
-rw-r--r--src/main/resources/ui/sqlfiddle/www/javascript/fiddle_backbone/utils/openidconnect.js2
5 files changed, 58 insertions, 2 deletions
diff --git a/src/main/resources/conf/endpoint-restClient.json b/src/main/resources/conf/endpoint-restClient.json
new file mode 100644
index 0000000..3ffcf9e
--- /dev/null
+++ b/src/main/resources/conf/endpoint-restClient.json
@@ -0,0 +1,5 @@
+{
+ "context" : "endpoint/restClient",
+ "type" : "groovy",
+ "file" : "script/restClient.groovy"
+} \ No newline at end of file
diff --git a/src/main/resources/conf/script.json b/src/main/resources/conf/script.json
new file mode 100644
index 0000000..01ac54f
--- /dev/null
+++ b/src/main/resources/conf/script.json
@@ -0,0 +1,38 @@
+{
+ "properties" : { },
+ "ECMAScript" : {
+ "#javascript.debug" : "transport=socket,suspend=y,address=9888,trace=true",
+ "javascript.recompile.minimumInterval" : "100"
+ },
+ "Groovy" : {
+ "#groovy.warnings" : "likely errors #othere values [none,likely,possible,paranoia]",
+ "#groovy.source.encoding" : "utf-8 #default US-ASCII",
+ "groovy.source.encoding" : "UTF-8",
+ "groovy.target.directory" : "&{launcher.install.location}/classes",
+ "#groovy.target.bytecode" : "1.5",
+ "groovy.classpath" : "/&{launcher.install.location}/lib/http-builder-0.7.1.jar:/&{launcher.install.location}/lib/json-lib-2.3-jdk15.jar:/&{launcher.install.location}/lib/xml-resolver-1.2.jar:/&{launcher.install.location}/lib/commons-collections-3.2.1.jar",
+ "#groovy.output.verbose" : "false",
+ "#groovy.output.debug" : "false",
+ "#groovy.errors.tolerance" : "10",
+ "#groovy.script.extension" : ".groovy",
+ "#groovy.script.base" : "#any class extends groovy.lang.Script",
+ "groovy.recompile" : "true",
+ "#groovy.recompile.minimumInterval" : "100 #in Millis",
+ "#groovy.target.indy" : "true",
+ "#groovy.disabled.global.ast.transformations" : ""
+ },
+ "sources" : {
+ "default" : {
+ "directory" : "&{launcher.install.location}/bin/defaults/script"
+ },
+ "install" : {
+ "directory" : "&{launcher.install.location}"
+ },
+ "project" : {
+ "directory" : "&{launcher.project.location}"
+ },
+ "project-script" : {
+ "directory" : "&{launcher.project.location}/script"
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/resources/script/oidc.js b/src/main/resources/script/oidc.js
index a6556bd..0f5699f 100644
--- a/src/main/resources/script/oidc.js
+++ b/src/main/resources/script/oidc.js
@@ -43,7 +43,7 @@
}
try {
- response = openidm.action("external/rest", "call", {
+ response = openidm.action("endpoint/restClient", "call", {
"method": "POST",
"url": resolver.token_endpoint,
"contentType": "application/x-www-form-urlencoded",
diff --git a/src/main/resources/script/restClient.groovy b/src/main/resources/script/restClient.groovy
new file mode 100644
index 0000000..724540b
--- /dev/null
+++ b/src/main/resources/script/restClient.groovy
@@ -0,0 +1,13 @@
+import groovyx.net.http.RESTClient
+import static groovyx.net.http.ContentType.*
+
+def content = request.getContent().asMap()
+def restRequest = new RESTClient( content.url )
+
+try {
+ def response = restRequest.post ([ body: content.body, requestContentType : URLENC ])
+
+ return response.data
+} catch (e) {
+ return null;
+} \ No newline at end of file
diff --git a/src/main/resources/ui/sqlfiddle/www/javascript/fiddle_backbone/utils/openidconnect.js b/src/main/resources/ui/sqlfiddle/www/javascript/fiddle_backbone/utils/openidconnect.js
index 0a5ffd5..a8b802e 100644
--- a/src/main/resources/ui/sqlfiddle/www/javascript/fiddle_backbone/utils/openidconnect.js
+++ b/src/main/resources/ui/sqlfiddle/www/javascript/fiddle_backbone/utils/openidconnect.js
@@ -31,7 +31,7 @@ define(["underscore", "jquery", "fiddle_backbone/models/OpenIDMResource"], funct
},
getMainUri: function () {
return window.location.protocol + "//" + window.location.host +
- window.location.pathname.replace(/(\/oauth\.html)|(\/$)/, '/index.html');
+ window.location.pathname.replace(/(\/oauth\.html)|(\/$)/, '/');
},
getToken: function () {
var params = this.getURLParams();