Author: tyrell
Date: Fri Jan 25 23:22:53 2008
New Revision: 12945

Log:

Tweaking the https re-direction code.

Modified:
   trunk/mashup/java/modules/www/header.jsp
   trunk/mashup/java/modules/www/js/mashup-main.js
   trunk/mashup/java/modules/www/js/utils.js

Modified: trunk/mashup/java/modules/www/header.jsp
==============================================================================
--- trunk/mashup/java/modules/www/header.jsp    (original)
+++ trunk/mashup/java/modules/www/header.jsp    Fri Jan 25 23:22:53 2008
@@ -14,6 +14,17 @@
  * limitations under the License.
 --%>
 <%@ page import="java.net.URLEncoder" %>
+<script type="text/javascript" src="../wsasadmin/global_params.js"></script>
+<script type="text/javascript" src="../wsasadmin/js/main.js"></script>
+<script type="text/javascript" src="js/utils.js"></script>
+<script type="text/javascript" language="JavaScript">
+    var isUserLoggedIn = <%=RegistryUtils.isLoggedIn(registry)%>;
+    if(isUserLoggedIn){
+        redirectToHttps("<%=thisPage%>");
+    }else{
+        redirectToHttp("<%=thisPage%>");
+    }
+</script>
 <div id="banner">
     <table width="100%" border="0" cellpadding="0" cellspacing="0">
         <tr>
@@ -35,7 +46,7 @@
     }
 if (!RegistryUtils.isLoggedIn(registry)) { %>
                     <li class="tab"><a 
href="register_self.jsp?firstcall=true&bounceback=<%=URLEncoder.encode(thisPage,"UTF-8")%>">Sign
 up</a></li><li class="tab-right"><img src="images/blank.gif" width="8"/></li>
-<% } %>                    
+<% } %>
                 </ul>
             </td>
         </tr>

Modified: trunk/mashup/java/modules/www/js/mashup-main.js
==============================================================================
--- trunk/mashup/java/modules/www/js/mashup-main.js     (original)
+++ trunk/mashup/java/modules/www/js/mashup-main.js     Fri Jan 25 23:22:53 2008
@@ -30,15 +30,7 @@
             wso2.wsf.Util.initURLs();
 
             if (isSecure) {
-                /*Only for protocol determination*/
-                var _tmpURL = locationString.substring(0, 
locationString.lastIndexOf('/'));
-                if (_tmpURL.indexOf('https') == -1) {
-
-                    //Re-direct to https
-                    window.location =
-                    "https" + URL.substring(URL.indexOf('://'), 
URL.lastIndexOf(':') + 1) +
-                    HTTPS_PORT;
-                }
+                redirectToHttps();
             }
 
 

Modified: trunk/mashup/java/modules/www/js/utils.js
==============================================================================
--- trunk/mashup/java/modules/www/js/utils.js   (original)
+++ trunk/mashup/java/modules/www/js/utils.js   Fri Jan 25 23:22:53 2008
@@ -86,30 +86,42 @@
 }
 
 function redirectToHttps(bounceback) {
-    /*Only for protocol determination*/
+
     wso2.wsf.Util.initURLs();
     var locationString = self.location.href;
     var _tmpURL = locationString.substring(0, locationString.lastIndexOf('/'));
     if (_tmpURL.indexOf('https') == -1) {
 
         //Re-direct to https
-        window.location =
-        "https" + URL.substring(URL.indexOf('://'), URL.lastIndexOf(':') + 1) +
-        HTTPS_PORT + '/' + bounceback;
+        var redirectUrl = "https://"; + self.location.hostname;
+        
+        if(!(URL.indexOf('://') == URL.lastIndexOf(':'))){
+           redirectUrl += ":" + HTTPS_PORT + "/";
+        }
+
+        redirectUrl += bounceback;
+
+        window.location = redirectUrl;
     }
 }
 
 function redirectToHttp(bounceback) {
-    /*Only for protocol determination*/
+    
     wso2.wsf.Util.initURLs();
     var locationString = self.location.href;
     var _tmpURL = locationString.substring(0, locationString.lastIndexOf('/'));
     if (_tmpURL.indexOf('http') == -1) {
 
-        //Re-direct to https
-        window.location =
-        "http" + URL.substring(URL.indexOf('://'), URL.lastIndexOf(':') + 1) +
-        HTTPS_PORT + '/' + bounceback;
+        //Re-direct to http
+        var redirectUrlHttp = "http://"; + self.location.hostname;
+
+        if(!(URL.indexOf('://') == URL.lastIndexOf(':'))){
+           redirectUrlHttp += ":" + HTTP_PORT + "/";
+        }
+
+        redirectUrlHttp += bounceback;
+
+        window.location = redirectUrlHttp;
     }
 }
 

_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to