Author: channa Date: Sat Jul 12 21:03:26 2008 New Revision: 19186 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=19186
Log: Added check for initial setup completion into validate_login, to ensure it's called only when not logged in (preventing WSAS PM call on each page load). Included check_setup call in callable pages where login is not validated. Added: trunk/mashup/java/modules/www/check_setup.jsp Modified: trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java trunk/mashup/java/modules/www/index.jsp trunk/mashup/java/modules/www/register_self.jsp trunk/mashup/java/modules/www/signin.jsp trunk/mashup/java/modules/www/validate_login.jsp Modified: trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java?rev=19186&r1=19185&r2=19186&view=diff ============================================================================== --- trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java (original) +++ trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java Sat Jul 12 21:03:26 2008 @@ -92,6 +92,8 @@ import javax.management.AttributeNotFoundException; import javax.management.InvalidAttributeValueException; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.Cookie; import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamException; import java.io.BufferedReader; @@ -801,6 +803,36 @@ } /** + * Removes cookies that could possibly have been set by a previous installation of the mashup + * server. + * @param request Servlet request. + * @param response Servlet response. + */ + public static void removeCookies(HttpServletRequest request, HttpServletResponse response) { + Cookie[] cookies = request.getCookies(); + + if (cookies != null) { + Cookie curCookie; + for (int x = 0; x < cookies.length; x++) { + curCookie = cookies[x]; + if (curCookie.getName().equalsIgnoreCase("rememberMe")) { + curCookie.setMaxAge(0); + response.addCookie(curCookie); + } else if (curCookie.getName().equalsIgnoreCase("username")) { + curCookie.setMaxAge(0); + response.addCookie(curCookie); + } else if (curCookie.getName().equalsIgnoreCase("password")) { + curCookie.setMaxAge(0); + response.addCookie(curCookie); + } else if (curCookie.getName().equalsIgnoreCase(MashupConstants.REMEMBER_OPENID)) { + curCookie.setMaxAge(0); + response.addCookie(curCookie); + } + } + } + } + + /** * Determines if the request originated from the local system. * * @param request Servlet request object. Added: trunk/mashup/java/modules/www/check_setup.jsp URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/www/check_setup.jsp?pathrev=19186 ============================================================================== --- (empty file) +++ trunk/mashup/java/modules/www/check_setup.jsp Sat Jul 12 21:03:26 2008 @@ -0,0 +1,24 @@ +<%-- + * Copyright 2006,2007 WSO2, Inc. http://www.wso2.org + * + * Licensed 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. +--%> +<%@ page import="org.wso2.mashup.utils.MashupUtils" %> +<%@ page import="org.wso2.mashup.MashupConstants" %> +<% + if (!MashupUtils.isInitialSetupComplete() && MashupUtils.isFromLocalHost(request)) { + //Deleting previous user login cookies, if found + MashupUtils.removeCookies(request, response); + response.sendRedirect("register_admin.jsp?firstcall=true"); + } +%> \ No newline at end of file Modified: trunk/mashup/java/modules/www/index.jsp URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/www/index.jsp?rev=19186&r1=19185&r2=19186&view=diff ============================================================================== --- trunk/mashup/java/modules/www/index.jsp (original) +++ trunk/mashup/java/modules/www/index.jsp Sat Jul 12 21:03:26 2008 @@ -30,32 +30,6 @@ <% ResourceBundle bundle = ResourceBundle.getBundle("UI"); - if (!MashupUtils.isInitialSetupComplete() && MashupUtils.isFromLocalHost(request)) { - //Deleting previous user login cookies, if found - Cookie[] cookies = request.getCookies(); - - if (cookies != null) { - Cookie curCookie = null; - for (int x = 0; x < cookies.length; x++) { - curCookie = cookies[x]; - if (curCookie.getName().equalsIgnoreCase("rememberMe")) { - curCookie.setMaxAge(0); - response.addCookie(curCookie); - } else if (curCookie.getName().equalsIgnoreCase("username")) { - curCookie.setMaxAge(0); - response.addCookie(curCookie); - } else if (curCookie.getName().equalsIgnoreCase("password")) { - curCookie.setMaxAge(0); - response.addCookie(curCookie); - } else if (curCookie.getName().equalsIgnoreCase(MashupConstants.REMEMBER_OPENID)) { - curCookie.setMaxAge(0); - response.addCookie(curCookie); - } - } - } - response.sendRedirect("register_admin.jsp?firstcall=true"); - } - String thisPage = "index.jsp"; %> Modified: trunk/mashup/java/modules/www/register_self.jsp URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/www/register_self.jsp?rev=19186&r1=19185&r2=19186&view=diff ============================================================================== --- trunk/mashup/java/modules/www/register_self.jsp (original) +++ trunk/mashup/java/modules/www/register_self.jsp Sat Jul 12 21:03:26 2008 @@ -24,7 +24,8 @@ <%@ page import="java.net.URLEncoder" %> <%@ page import="java.util.ResourceBundle" %> - +<!-- Makes sure initial setup has been completed before allowing access to the page --> +<%@ include file="check_setup.jsp" %> <% ResourceBundle bundle = ResourceBundle.getBundle("UI"); UserRegistry userRegistry = RegistryUtils.getRegistry(request); Modified: trunk/mashup/java/modules/www/signin.jsp URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/www/signin.jsp?rev=19186&r1=19185&r2=19186&view=diff ============================================================================== --- trunk/mashup/java/modules/www/signin.jsp (original) +++ trunk/mashup/java/modules/www/signin.jsp Sat Jul 12 21:03:26 2008 @@ -28,6 +28,9 @@ <%@ page import="java.util.ResourceBundle" %> <%@ page import="org.apache.axiom.om.util.Base64" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %> + +<!-- Makes sure initial setup has been completed before allowing access to the page --> +<%@ include file="check_setup.jsp" %> <% ResourceBundle bundle = ResourceBundle.getBundle("UI"); UserRegistry userRegistry = RegistryUtils.getRegistry(request); Modified: trunk/mashup/java/modules/www/validate_login.jsp URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/www/validate_login.jsp?rev=19186&r1=19185&r2=19186&view=diff ============================================================================== --- trunk/mashup/java/modules/www/validate_login.jsp (original) +++ trunk/mashup/java/modules/www/validate_login.jsp Sat Jul 12 21:03:26 2008 @@ -39,9 +39,15 @@ UserRegistry userRegistry = RegistryUtils.getRegistry(request); //Checking whether the user is logged in - if (!RegistryUtils.isLoggedIn(userRegistry) && MashupUtils.isInitialSetupComplete()) { + if (!RegistryUtils.isLoggedIn(userRegistry)) { + // Do a first check to make sure initial setup is complete, before attempting login. + if (!MashupUtils.isInitialSetupComplete() && MashupUtils.isFromLocalHost(request)) { + //Deleting previous user login cookies, if found + MashupUtils.removeCookies(request, response); + response.sendRedirect("register_admin.jsp?firstcall=true"); + } else { - //Check whether the remember me option is set + //Check whether the remember me option is set Cookie[] cookies = request.getCookies(); if (cookies != null) { @@ -109,5 +115,6 @@ request.getSession().setAttribute(MashupConstants.USER_REGISTRY, userRegistry); } } + } } %> \ No newline at end of file _______________________________________________ Mashup-dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/mashup-dev
