knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lmc...@apache.org
Subject [09/11] knox git commit: KNOX-686 - Default Form based SSO IDP as an Application
Date Thu, 10 Mar 2016 17:34:48 GMT
http://git-wip-us.apache.org/repos/asf/knox/blob/3e36bc69/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontawesome/fontawesome-webfont.ttf
----------------------------------------------------------------------
diff --git a/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontawesome/fontawesome-webfont.ttf
b/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontawesome/fontawesome-webfont.ttf
new file mode 100644
index 0000000..d365924
Binary files /dev/null and b/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontawesome/fontawesome-webfont.ttf
differ

http://git-wip-us.apache.org/repos/asf/knox/blob/3e36bc69/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontawesome/fontawesome-webfont.woff
----------------------------------------------------------------------
diff --git a/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontawesome/fontawesome-webfont.woff
b/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontawesome/fontawesome-webfont.woff
new file mode 100644
index 0000000..b9bd17e
Binary files /dev/null and b/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontawesome/fontawesome-webfont.woff
differ

http://git-wip-us.apache.org/repos/asf/knox/blob/3e36bc69/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-300.woff
----------------------------------------------------------------------
diff --git a/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-300.woff
b/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-300.woff
new file mode 100644
index 0000000..99f3353
Binary files /dev/null and b/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-300.woff
differ

http://git-wip-us.apache.org/repos/asf/knox/blob/3e36bc69/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-300i.woff
----------------------------------------------------------------------
diff --git a/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-300i.woff
b/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-300i.woff
new file mode 100644
index 0000000..dd0a0ea
Binary files /dev/null and b/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-300i.woff
differ

http://git-wip-us.apache.org/repos/asf/knox/blob/3e36bc69/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-400.woff
----------------------------------------------------------------------
diff --git a/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-400.woff
b/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-400.woff
new file mode 100644
index 0000000..55b25f8
Binary files /dev/null and b/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-400.woff
differ

http://git-wip-us.apache.org/repos/asf/knox/blob/3e36bc69/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-400i.woff
----------------------------------------------------------------------
diff --git a/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-400i.woff
b/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-400i.woff
new file mode 100644
index 0000000..cedefb8
Binary files /dev/null and b/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-400i.woff
differ

http://git-wip-us.apache.org/repos/asf/knox/blob/3e36bc69/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-600.woff
----------------------------------------------------------------------
diff --git a/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-600.woff
b/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-600.woff
new file mode 100644
index 0000000..e83bb33
Binary files /dev/null and b/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-600.woff
differ

http://git-wip-us.apache.org/repos/asf/knox/blob/3e36bc69/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-600i.woff
----------------------------------------------------------------------
diff --git a/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-600i.woff
b/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-600i.woff
new file mode 100644
index 0000000..983bb33
Binary files /dev/null and b/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-600i.woff
differ

http://git-wip-us.apache.org/repos/asf/knox/blob/3e36bc69/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-700.woff
----------------------------------------------------------------------
diff --git a/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-700.woff
b/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-700.woff
new file mode 100644
index 0000000..27619e7
Binary files /dev/null and b/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-700.woff
differ

http://git-wip-us.apache.org/repos/asf/knox/blob/3e36bc69/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-700i.woff
----------------------------------------------------------------------
diff --git a/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-700i.woff
b/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-700i.woff
new file mode 100644
index 0000000..e12c3a9
Binary files /dev/null and b/gateway-applications/src/main/resources/applications/knoxauth/fonts/fontopensans/open-sans-700i.woff
differ

http://git-wip-us.apache.org/repos/asf/knox/blob/3e36bc69/gateway-applications/src/main/resources/applications/knoxauth/images/avatar.png
----------------------------------------------------------------------
diff --git a/gateway-applications/src/main/resources/applications/knoxauth/images/avatar.png
b/gateway-applications/src/main/resources/applications/knoxauth/images/avatar.png
new file mode 100644
index 0000000..74a8031
Binary files /dev/null and b/gateway-applications/src/main/resources/applications/knoxauth/images/avatar.png
differ

http://git-wip-us.apache.org/repos/asf/knox/blob/3e36bc69/gateway-applications/src/main/resources/applications/knoxauth/images/blank.gif
----------------------------------------------------------------------
diff --git a/gateway-applications/src/main/resources/applications/knoxauth/images/blank.gif
b/gateway-applications/src/main/resources/applications/knoxauth/images/blank.gif
new file mode 100644
index 0000000..35d42e8
Binary files /dev/null and b/gateway-applications/src/main/resources/applications/knoxauth/images/blank.gif
differ

http://git-wip-us.apache.org/repos/asf/knox/blob/3e36bc69/gateway-applications/src/main/resources/applications/knoxauth/images/knox-logo.gif
----------------------------------------------------------------------
diff --git a/gateway-applications/src/main/resources/applications/knoxauth/images/knox-logo.gif
b/gateway-applications/src/main/resources/applications/knoxauth/images/knox-logo.gif
new file mode 100644
index 0000000..6f476ac
Binary files /dev/null and b/gateway-applications/src/main/resources/applications/knoxauth/images/knox-logo.gif
differ

http://git-wip-us.apache.org/repos/asf/knox/blob/3e36bc69/gateway-applications/src/main/resources/applications/knoxauth/images/loading.gif
----------------------------------------------------------------------
diff --git a/gateway-applications/src/main/resources/applications/knoxauth/images/loading.gif
b/gateway-applications/src/main/resources/applications/knoxauth/images/loading.gif
new file mode 100644
index 0000000..5b33f7e
Binary files /dev/null and b/gateway-applications/src/main/resources/applications/knoxauth/images/loading.gif
differ

http://git-wip-us.apache.org/repos/asf/knox/blob/3e36bc69/gateway-applications/src/main/resources/applications/knoxauth/js/knoxauth.js
----------------------------------------------------------------------
diff --git a/gateway-applications/src/main/resources/applications/knoxauth/js/knoxauth.js
b/gateway-applications/src/main/resources/applications/knoxauth/js/knoxauth.js
new file mode 100644
index 0000000..bc99f01
--- /dev/null
+++ b/gateway-applications/src/main/resources/applications/knoxauth/js/knoxauth.js
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var loginURL = "/gateway/knoxsso/api/v1/websso?originalUrl=";
+var logoutURL = "/WebServices/LogOff";
+var userAgent = navigator.userAgent.toLowerCase();
+var firstLogIn = true;
+
+function get(name){
+   if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
+      return decodeURIComponent(name[1]);
+}
+
+var login = function() {
+    var form = document.forms[0];
+    var username = form.username.value;
+    var password = form.password.value;
+    var _login = function(){
+    var originalUrl = get("originalUrl");
+    var idpUrl = loginURL + originalUrl;
+      //Instantiate HTTP Request
+        var request = ((window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"));
+        request.open("POST", loginURL + originalUrl, true);
+        request.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password))
+        request.send(null);
+
+      //Process Response
+        request.onreadystatechange = function(){
+            if (request.readyState == 4) {
+                if (request.status==200 || request.status==204 || request.status==307 ||
request.status==303) {
+                  // window.location.replace(originalUrl);
+                  // window.location = originalUrl;
+                  try { window.location.replace(originalUrl); } 
+                  catch(e) { window.location = originalUrl; }
+                }
+                else {
+                    // if (navigator.userAgent.toLowerCase().indexOf("firefox") != -1){
+                    //     logoff();
+                    // }
+                  if (request.status==401) {
+                    $('#errorBox').show();
+                    $('#signInLoading').hide();
+                    $('#signIn').removeAttr('disabled');
+                    $('#errorBox .errorMsg').text("The username or password you entered is
incorrect.");
+                  }
+                }
+            }
+        }
+    }
+
+    var userAgent = navigator.userAgent.toLowerCase();
+    if (userAgent.indexOf("firefox") != -1){ //TODO: check version number
+        if (firstLogIn) _login();
+        else logoff(_login);
+    }
+    else{
+        _login();
+    }
+
+    if (firstLogIn) firstLogIn = false;
+}
+
+var logoff = function(callback){
+
+    if (userAgent.indexOf("msie") != -1) {
+        document.execCommand("ClearAuthenticationCache");
+    }
+    else if (userAgent.indexOf("firefox") != -1){ //TODO: check version number
+
+        var request1 = new XMLHttpRequest();
+        var request2 = new XMLHttpRequest();
+
+      //Logout. Tell the server not to return the "WWW-Authenticate" header
+        request1.open("GET", logoutURL + "?prompt=false", true);
+        request1.send("");
+        request1.onreadystatechange = function(){
+            if (request1.readyState == 4) {
+
+              //Login with dummy credentials to clear the auth cache
+                request2.open("GET", logoutURL, true, "logout", "logout");
+                request2.send("");
+
+                request2.onreadystatechange = function(){
+                    if (request2.readyState == 4) {
+                        if (callback!=null) callback.call();
+                    }
+                }
+            }
+        }
+    }
+    else {
+        var request = ((window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"));
+        request.open("GET", logoutURL, true, "logout", "logout");
+        request.send("");
+    }
+}
\ No newline at end of file


Mime
View raw message