Author: tyrell
Date: Wed Jan 16 04:30:43 2008
New Revision: 12347

Log:

Adding 'Remember Me' option to the ui.

Modified:
   trunk/mashup/java/modules/core/conf/server.xml
   trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
   trunk/mashup/java/modules/www/index.jsp
   trunk/mashup/java/modules/www/js/mashup-utils.js
   trunk/mashup/java/modules/www/signin.jsp
   trunk/mashup/java/modules/www/signout.jsp

Modified: trunk/mashup/java/modules/core/conf/server.xml
==============================================================================
--- trunk/mashup/java/modules/core/conf/server.xml      (original)
+++ trunk/mashup/java/modules/core/conf/server.xml      Wed Jan 16 04:30:43 2008
@@ -133,11 +133,19 @@
         </Jabber>
     </IMConfig>
 
+
+    <!--Used to configure session management attributes-->
+    <SessionManagement>
+        <!--The time period (in days) to remember a user session, when one 
selects 'Remember Me' in the UI.
+         Setting to -1 means remember indefinetely.
+        -->
+          <RememberMePeriod>14</RememberMePeriod>
+    </SessionManagement>
+
     <!--
        Functions related to the Management Console
     -->
     <Management>
-
         <!--
            Enable the Management Console, true/false
         -->

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
==============================================================================
--- trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java     
(original)
+++ trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java     
Wed Jan 16 04:30:43 2008
@@ -37,6 +37,10 @@
     public static String ICQ = IM_CONFIG + "." + "ICQ";
     public static String JABBER = IM_CONFIG + "." + "Jabber";
     public static String YAHOO = IM_CONFIG + "." + "Yahoo";
+    public static String SESSION_MANAGEMENT = "SessionManagement";
+    public static String REMEMBER_ME_PERIOD = "RememberMePeriod";
+    public static String ORIGINAL_INACTIVE_INTERVAL = 
"OriginalInactiveInterval";
+
 
     public static String QUARTZ_FUNCTION_SCHEDULER = "FunctionScheduler";
 
@@ -63,7 +67,7 @@
     public static final String MY_TOP_MASHUPS_QUERY_PATH = 
QUERYSTORE_QUERY_PATH + "/mytopmashups";
     public static final String ACTIVITY_QUERY_PATH = QUERYSTORE_QUERY_PATH + 
"/activity";
     public static final String COMMENTS_QUERY_PATH = QUERYSTORE_QUERY_PATH + 
"/comments";
-    public static final String MY_COMMENTS_QUERY_PATH = QUERYSTORE_QUERY_PATH 
+ "/mycomments";    
+    public static final String MY_COMMENTS_QUERY_PATH = QUERYSTORE_QUERY_PATH 
+ "/mycomments";
 
     public static final String FULL_NAME = "fullName";
     public static final String FIRST_NAME = "firstname";
@@ -75,7 +79,8 @@
     public static final String INFOCARD_PPID = "ppid";
     public static final String INFOCARD_COUNT = "cardcount";
 
-    public static final int SHOW_RESULTS_COUNT = 5;    // How many results to 
show before showing "more".
+    public static final int SHOW_RESULTS_COUNT =
+            5;    // How many results to show before showing "more".
     public static final int MAX_RESULTS_COUNT = 1000;  // Maximum results to 
return.
 
     public static final String IMPOSSIBLE_VALUE = "[EMAIL PROTECTED]@";
@@ -93,7 +98,7 @@
 
     public static final String SELF_REGISTRATION_ENABLED = 
"self_registration_enabled";
 
-    public static final String MASHUP_ADMIN_SERVICEGROUP = 
"wso2mashup-adminService"; 
+    public static final String MASHUP_ADMIN_SERVICEGROUP = 
"wso2mashup-adminService";
     public static final String MASHUP_LOGIN_SERVICEUT = "MashupLoginServiceUT";
     public static final String MASHUP_LOGIN_SERVICEIC = "MashupLoginServiceIC";
     public static final String USER_LOGGED_IN = "UserLoggedIn";

Modified: trunk/mashup/java/modules/www/index.jsp
==============================================================================
--- trunk/mashup/java/modules/www/index.jsp     (original)
+++ trunk/mashup/java/modules/www/index.jsp     Wed Jan 16 04:30:43 2008
@@ -166,7 +166,6 @@
 <%@ include file="welcome.jsp" %>
 
 <div id="content">
-
 <table class="queryarea" border="0" cellspacing="0" cellpadding="5">
 <tr>
 <td valign="top">

Modified: trunk/mashup/java/modules/www/js/mashup-utils.js
==============================================================================
--- trunk/mashup/java/modules/www/js/mashup-utils.js    (original)
+++ trunk/mashup/java/modules/www/js/mashup-utils.js    Wed Jan 16 04:30:43 2008
@@ -599,15 +599,37 @@
     return docFrag;
 };
 
-WSO2.MashupUtils.getCookieValue = function (cookieName) {
-    var exp = new RegExp(escape(cookieName) + "=([^;]+)");
-    if (exp.test(document.cookie + ";")) {
-        exp.exec(document.cookie + ";");
-        return unescape(RegExp.$1);
+
+WSO2.MashupUtils.readCookie = function(name) {
+    var nameEQ = name + "=";
+    var ca = document.cookie.split(';');
+    for (var i = 0; i < ca.length; i++) {
+        var c = ca[i];
+        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
+        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, 
c.length);
+    }
+    return null;
+};
+
+
+WSO2.MashupUtils.eraseCookie = function(name) {
+    WSO2.MashupUtils.createCookie(name, "", -1);
+}
+
+
+WSO2.MashupUtils.createCookie = function(name, value, days) {
+    var expires = "";
+    
+    if (days) {
+        var date = new Date();
+        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
+        expires = "; expires=" + date.toGMTString();
     }
-    else return false;
+    
+    document.cookie = name + "=" + value + expires + "; path=/";
 };
 
+
 /**
  * @description Handles the change to a service status. Updates the mashup 
list model, which propagates to the view.
  * @method handleServiceStartStop

Modified: trunk/mashup/java/modules/www/signin.jsp
==============================================================================
--- trunk/mashup/java/modules/www/signin.jsp    (original)
+++ trunk/mashup/java/modules/www/signin.jsp    Wed Jan 16 04:30:43 2008
@@ -43,6 +43,7 @@
 <%@ page import="java.net.URL" %>
 <%@ page import="java.net.URLDecoder" %>
 <%@ page import="java.util.*" %>
+<%@ page import="org.wso2.utils.ServerConfiguration" %>
 <%
     Registry registry = RegistryUtils.getRegistry(request);
     // required by header.jsp
@@ -60,6 +61,8 @@
 
     String nameProvided = request.getParameter("userName");
     String passwordProvided = request.getParameter("password");
+    String rememberMe = request.getParameter("rememberme");
+
     if (firsttime != null) {
         // Prevent login using default profiles.
         if (nameProvided.equals(MashupConstants.SAMPLES_USER) ||
@@ -78,10 +81,28 @@
 
                 MashupUtils.login(nameProvided, passwordProvided);
 
-                SecureRegistry secureRegistry = new 
SecureRegistry(nameProvided, jdbcRegistry, realm);
+                SecureRegistry secureRegistry =
+                        new SecureRegistry(nameProvided, jdbcRegistry, realm);
 
                 
request.getSession().setAttribute(MashupConstants.USER_REGISTRY, 
secureRegistry);
 
+                //Checking whether the user has opted to remember the session
+                if (rememberMe.equalsIgnoreCase("true")) {
+                    ServerConfiguration serverConfig = 
ServerConfiguration.getInstance();
+                    String rememberMeDays =
+                            
serverConfig.getFirstProperty(MashupConstants.SESSION_MANAGEMENT + "." +
+                                    MashupConstants.REMEMBER_ME_PERIOD);
+
+                    if (rememberMeDays != null) {
+                        int days = Integer.parseInt(rememberMeDays);
+                        //Storing the original timeout to be reset at logout
+                        
request.getSession().setAttribute(MashupConstants.ORIGINAL_INACTIVE_INTERVAL, 
request.getSession().getMaxInactiveInterval());
+
+                        //Setting the new timeout according to the value 
configured in server.xml
+                        request.getSession().setMaxInactiveInterval(days * 24 
* 60 * 60);
+                    }
+                }
+
                 // Check if the user is active - if not, fail login.
                 if (ManageUsers.isUserActive(secureRegistry, nameProvided)) {
                     response.sendRedirect(bounceback);
@@ -90,7 +111,7 @@
                 }
             } catch (RegistryException e) {
                 success = false;
-            }  catch (MashupFault e) {
+            } catch (MashupFault e) {
                 success = false;
             }
         }
@@ -108,6 +129,21 @@
     <script language="javascript" src="js/utils.js" 
type="text/javascript"></script>
     <script type="text/javascript" 
src="../wsasadmin/global_params.js"></script>
     <script type="text/javascript" src="../wsasadmin/js/main.js"></script>
+
+    <script type="text/javascript" language="JavaScript">
+
+        function setRememberMe(){
+            var val = document.getElementById("chkRemember").checked;
+            var remMe = document.getElementById("rememberme");
+
+            if(val){
+                remMe.value = "true";
+            }else{
+                remMe.value = "false";
+            }
+        }
+
+    </script>
 </head>
 
 <body onload="redirectToHttps('<%=thisPage%>');">
@@ -115,13 +151,14 @@
 
     <%@ include file="header.jsp" %>
     <div id="search"></div>
-    <div id="content">
+    <div id="content">          
         <table width="100%" height="400" border="0" cellspacing="0" 
cellpadding="5">
             <tr>
                 <td valign="top">
                     <form id="Login" onsubmit="return true;" method="post">
                         <input type="hidden" name="firsttime" value="false"/>
                         <input type="hidden" name="bounceback" 
value="<%=bounceback%>"/>
+                        <input type="hidden" id="rememberme" name="rememberme" 
value="false"/>
                         <br/>
                         <table width="600" border="0" align="right" 
cellpadding="3" cellspacing="0"
                                class="box">
@@ -147,10 +184,13 @@
                                     <label style="margin-right:31px; 
"><strong>Password:</strong></label><input
                                         type="password" name="password" 
id="password"/>
                                     <br/><br/><br/>
-
-                                    <div style="width:100%; text-align:center 
"><input type="submit"
-                                                                               
        id="signin"
-                                                                               
        value="Sign In"/>
+                                    <div style="width:100%; text-align: left; 
"><input
+                                            type="checkbox" id="chkRemember" 
onclick="setRememberMe();"><label style="text-align: left; ">
+                                        Remember me on this 
computer</label><br><br></div>
+                                    <div style="width:100%; text-align: center 
"><input
+                                            type="submit"
+                                            id="signin"
+                                            value="Sign In"/>
                                     </div>
                                 </td>
                                 <td align="center" height="175">
@@ -160,7 +200,9 @@
                                     Signup using your personal or managed 
infocard.
                                     <br/>
                                     <br/>
-                                    <a 
href="http://wso2.org/projects/solutions/identity"; target="_blank"><img 
src="images/powered_identity.gif" border="0"></a>
+                                    <a 
href="http://wso2.org/projects/solutions/identity";
+                                       target="_blank"><img 
src="images/powered_identity.gif"
+                                                            border="0"></a>
                                 </td>
                             </tr>
                         </table>

Modified: trunk/mashup/java/modules/www/signout.jsp
==============================================================================
--- trunk/mashup/java/modules/www/signout.jsp   (original)
+++ trunk/mashup/java/modules/www/signout.jsp   Wed Jan 16 04:30:43 2008
@@ -51,10 +51,10 @@
 <%@ page import="java.util.List" %>
 <%@ page import="java.util.Map" %>
 <%
-     Registry registry = RegistryUtils.getRegistry(request);
-       // required by header.jsp
-       String thisPage = "signout.jsp";
-    
+    Registry registry = RegistryUtils.getRegistry(request);
+    // required by header.jsp
+    String thisPage = "signout.jsp";
+
     String bounceback = request.getParameter("bounceback");
     if (bounceback == null) bounceback = "index.jsp";
 
@@ -82,22 +82,28 @@
         } else {
     */
 
-            try {
-                ServletContext context = 
request.getSession().getServletContext();
+    try {
+        ServletContext context = request.getSession().getServletContext();
 
-                JDBCRegistry jdbcRegistry =
-                        (JDBCRegistry) 
context.getAttribute(RegistryConstants.REGISTRY);
+        JDBCRegistry jdbcRegistry =
+                (JDBCRegistry) 
context.getAttribute(RegistryConstants.REGISTRY);
 
-                Realm realm = (Realm) 
context.getAttribute(RegistryConstants.REGISTRY_REALM);
+        Realm realm = (Realm) 
context.getAttribute(RegistryConstants.REGISTRY_REALM);
 
-                SecureRegistry secureRegistry =
-                    new SecureRegistry(RegistryConstants.ANONYMOUS_USER, 
"guest", jdbcRegistry, realm);
+        SecureRegistry secureRegistry =
+                new SecureRegistry(RegistryConstants.ANONYMOUS_USER, "guest", 
jdbcRegistry, realm);
 
-                
request.getSession().setAttribute(MashupConstants.USER_REGISTRY, 
secureRegistry);
-                response.sendRedirect(bounceback);
+        request.getSession().setAttribute(MashupConstants.USER_REGISTRY, 
secureRegistry);
 
-            } catch (RegistryException e) {
-            }
+        //Resetting the session timeout to the original value
+        request.getSession()
+                
.setMaxInactiveInterval((Integer)request.getSession().getAttribute(
+                        MashupConstants.ORIGINAL_INACTIVE_INTERVAL));
+        
+        response.sendRedirect(bounceback);
+
+    } catch (RegistryException e) {
+    }
     /*
         }
     */
@@ -107,21 +113,21 @@
 <head>
     <title>WSO2 Mashup Server - Sign Out</title>
     <!-- Required CSS -->
-    <link href="css/styles.css" rel="stylesheet" type="text/css" />
+    <link href="css/styles.css" rel="stylesheet" type="text/css"/>
     <script language="javascript" src="js/common.js" 
type="text/javascript"></script>
 </head>
 
 <body>
 <div id="page">
 
-<%@ include file="header.jsp" %>
-<div id="search"></div>
+    <%@ include file="header.jsp" %>
+    <div id="search"></div>
 
-<div id="content">
-    <div class="login-error">Unable to sign out!</div>
-    <div><a href="signout.jsp">Try again</a>.</div>
-</div>
-<%@ include file="footer.jsp"%>
+    <div id="content">
+        <div class="login-error">Unable to sign out!</div>
+        <div><a href="signout.jsp">Try again</a>.</div>
+    </div>
+    <%@ include file="footer.jsp" %>
 
 </div>
 

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

Reply via email to