Files
alfresco-community-repo/source/web/index.jsp
Kevin Roast c560aef6bd Merged V2.2 to HEAD
8121: Merged V2.1 to V2.2
      8088: Turned off debug logging.
      8090: Tweaked session cache limiting for AVM.
      8095: Fix for issue raised in ACT 402
      8108: Fix for AWC-1816
      8115: Build fix 
      8117: Fix AR-1217: OpenOffice connection is actively maintained

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8480 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2008-03-10 15:22:43 +00:00

126 lines
5.5 KiB
Plaintext

<%--
* Copyright (C) 2005-2007 Alfresco Software Limited.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
--%>
<%@ page import="javax.faces.context.FacesContext" %>
<%@ page import="javax.transaction.UserTransaction" %>
<%@ page import="org.springframework.web.context.WebApplicationContext" %>
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<%@ page import="org.alfresco.service.transaction.TransactionService" %>
<%@ page import="org.alfresco.service.cmr.security.PermissionService" %>
<%@ page import="org.alfresco.service.cmr.security.AuthenticationService" %>
<%@ page import="org.alfresco.service.cmr.security.PersonService" %>
<%@ page import="org.alfresco.service.cmr.security.PermissionService" %>
<%@ page import="org.alfresco.service.cmr.repository.NodeRef" %>
<%@ page import="org.alfresco.repo.security.authentication.AuthenticationException" %>
<%@ page import="org.alfresco.config.ConfigService" %>
<%@ page import="org.alfresco.web.app.servlet.AuthenticationHelper" %>
<%@ page import="org.alfresco.web.app.servlet.FacesHelper" %>
<%@ page import="org.alfresco.web.bean.NavigationBean" %>
<%@ page import="org.alfresco.web.bean.repository.User" %>
<%@ page import="org.alfresco.web.bean.repository.PreferencesService" %>
<%@ page import="org.alfresco.web.config.ClientConfigElement" %>
<%-- redirect to the web application's appropriate start page --%>
<%
// get the start location as configured by the web-client config
WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(session.getServletContext());
ConfigService configService = (ConfigService)context.getBean("webClientConfigService");
ClientConfigElement configElement = (ClientConfigElement)configService.getGlobalConfig().getConfigElement("client");
String location = configElement.getInitialLocation();
AuthenticationService authService = (AuthenticationService)context.getBean("AuthenticationService");
// override with the users preference if they have one
User user = (User)session.getAttribute(AuthenticationHelper.AUTHENTICATION_USER);
if (user != null)
{
UserTransaction tx = ((TransactionService)context.getBean("TransactionService")).getUserTransaction();;
tx.begin();
try
{
authService.validate(user.getTicket());
// ensure construction of the FacesContext before attemping a service call
FacesContext fc = FacesHelper.getFacesContext(request, response, application);
String preference = (String)PreferencesService.getPreferences(fc).getValue("start-location");
if (preference != null)
{
location = preference;
}
tx.commit();
}
catch (AuthenticationException authErr)
{
try { tx.rollback(); } catch (Throwable tex) {}
// expired ticket
AuthenticationService unpAuth = (AuthenticationService)context.getBean("authenticationService");
unpAuth.invalidateTicket(unpAuth.getCurrentTicket());
unpAuth.clearCurrentSecurityContext();
}
catch (Throwable e)
{
try { tx.rollback(); } catch (Throwable tex) {}
}
}
else
{
UserTransaction tx = ((TransactionService)context.getBean("TransactionService")).getUserTransaction();;
tx.begin();
try
{
authService.authenticateAsGuest();
PersonService personService = (PersonService)context.getBean("personService");
NodeRef guestRef = personService.getPerson(PermissionService.GUEST_AUTHORITY);
user = new User(authService.getCurrentUserName(), authService.getCurrentTicket(), guestRef);
session.setAttribute(AuthenticationHelper.AUTHENTICATION_USER, user);
// ensure construction of the FacesContext before attemping a service call
FacesContext fc = FacesHelper.getFacesContext(request, response, application);
String preference = (String)PreferencesService.getPreferences(session).getValue("start-location");
if (preference != null)
{
location = preference;
}
session.removeAttribute(AuthenticationHelper.AUTHENTICATION_USER);
tx.commit();
}
catch (Throwable e)
{
try { tx.rollback(); } catch (Throwable tex) {}
}
}
if (NavigationBean.LOCATION_MYALFRESCO.equals(location))
{
response.sendRedirect(request.getContextPath() + "/faces/jsp/dashboards/container.jsp");
}
else
{
response.sendRedirect(request.getContextPath() + "/faces/jsp/browse/browse.jsp");
}
%>