Author: tyrell
Date: Thu Jun  5 10:11:04 2008
New Revision: 18037
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=18037

Log:
Adding sign in handling.

Modified:
   trunk/mashup/java/modules/dashboard/header.jsp
   trunk/mashup/java/modules/dashboard/index.jsp
   trunk/mashup/java/modules/dashboard/login_validator.jsp

Modified: trunk/mashup/java/modules/dashboard/header.jsp
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/dashboard/header.jsp?rev=18037&r1=18036&r2=18037&view=diff
==============================================================================
--- trunk/mashup/java/modules/dashboard/header.jsp      (original)
+++ trunk/mashup/java/modules/dashboard/header.jsp      Thu Jun  5 10:11:04 2008
@@ -13,7 +13,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
 --%>
-
+<script type="text/javascript">
+    function showSignIn() {
+        document.getElementById("login-form").style.display = "block";
+    }
+</script>
 <div align="right">
 
     <div align="right" width="100%" style="padding: 0pt 0pt 4px; font-size: 
84%;" id="user-data">
@@ -23,15 +27,30 @@
                 <%
                     if (!RegistryUtils.isLoggedIn(userRegistry)) {
                 %>
-                <a href="../signin.jsp">Sign In</a>
+                <a href="#" onclick="showSignIn();">Sign In</a>
                 <%
                     }
                 %>
             </b> | <a
                 href="../index.jsp">Classic Home</a> | <a 
href="../user.jsp?name=<%=currentUser%>">My
-            Account</a> | <a
-                
href="../signout.jsp?bounceback=dashboard/index.jsp?signout=true">Sign out</a>
+            Account</a> | <a href="index.jsp?signout=true">Sign out</a>
         </nobr>
+        <br/>
+
+        <div style="display: none;" id="login-form">
+            <form method="post" id="side-login" action="index.jsp"><label
+                    for="username">Username </label> <input type="text" 
tabindex="1" size="15"
+                                                            id="username"
+                                                            
name="username"/><label
+                    for="password">Password </label><input type="password" 
tabindex="2"
+                                                           size="15" 
id="password"
+                                                           
name="password"/><label
+                    for="rememberme">Remember? </label> <input type="checkbox" 
checked="checked"
+                                                               tabindex="3" 
id="rememberme"
+                                                               
name="rememberme"/>
+                <button tabindex="4" value="Go" name="submit" 
type="submit">Go</button>
+            </form>
+        </div>
     </div>
 
 </div>
\ No newline at end of file

Modified: trunk/mashup/java/modules/dashboard/index.jsp
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/dashboard/index.jsp?rev=18037&r1=18036&r2=18037&view=diff
==============================================================================
--- trunk/mashup/java/modules/dashboard/index.jsp       (original)
+++ trunk/mashup/java/modules/dashboard/index.jsp       Thu Jun  5 10:11:04 2008
@@ -136,6 +136,10 @@
     %>
     [<a href="directory.jsp">Add Gadgets</a>]
     <%
+        }else{
+      %>
+    [<a href="#" onclick="showSignIn();">Sign in to Add Gadgets</a>]
+    <%
         }
     %>
 </div>

Modified: trunk/mashup/java/modules/dashboard/login_validator.jsp
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/dashboard/login_validator.jsp?rev=18037&r1=18036&r2=18037&view=diff
==============================================================================
--- trunk/mashup/java/modules/dashboard/login_validator.jsp     (original)
+++ trunk/mashup/java/modules/dashboard/login_validator.jsp     Thu Jun  5 
10:11:04 2008
@@ -11,8 +11,12 @@
 <%
     String signout = request.getParameter("signout");
 
-    if(signout != null){
-        if(signout.equalsIgnoreCase("true")){
+    String username = request.getParameter("username");
+    String password = request.getParameter("password");
+    String remember = request.getParameter("rememberme");
+
+    if (signout != null) {
+        if (signout.equalsIgnoreCase("true")) {
             request.getSession().setAttribute(MashupConstants.USER_REGISTRY, 
null);
             response.sendRedirect("index.jsp");
         }
@@ -77,8 +81,8 @@
                             response.addCookie(curCookie);
                         }
                     }
-                    //Re-directing to the sign in page
-                    response.sendRedirect("../signin.jsp?bounceback=" + 
thisPage);
+                    //Re-directing to the main page
+                    response.sendRedirect("index.jsp");
                 }
 
                 userRegistry =
@@ -87,6 +91,42 @@
                 
request.getSession().setAttribute(MashupConstants.USER_REGISTRY, userRegistry);
             }
         }
+
+        if ((username != null) && (password != null)) {
+            try {
+                MashupUtils.login(username, password, session.getId(), "/");
+                userRegistry =
+                        RegistryUtils.createUserRegistry(username, 
embeddedRegistry);
+
+                
request.getSession().setAttribute(MashupConstants.USER_REGISTRY, userRegistry);
+
+                if (remember.equalsIgnoreCase("true")) {
+                    int expireIn = 60 * 60 * 24 * 14; // 2 weeks
+                    
+                    //Saving the remember me option
+                    Cookie rememberMeCookie = new Cookie("rememberMe", 
remember);
+                    rememberMeCookie.setMaxAge(expireIn);
+                    response.addCookie(rememberMeCookie);
+
+                    Cookie usernameCookie = new Cookie("username", username);
+                    usernameCookie.setMaxAge(expireIn);
+                    usernameCookie.setSecure(true);
+                    response.addCookie(usernameCookie);
+
+                    // Encode the password
+                    Cookie passwordCookie = new Cookie("password",
+                                                       new 
sun.misc.BASE64Encoder().encode(
+                                                               
password.getBytes(
+                                                                       
"UTF-8")));
+                    passwordCookie.setMaxAge(expireIn);
+                    passwordCookie.setSecure(true);
+                    response.addCookie(passwordCookie);
+                }
+            } catch (Exception e) {
+                //Re-directing to the main page
+                response.sendRedirect("index.jsp");
+            }
+        }
     }
 
 %>
\ No newline at end of file

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

Reply via email to