001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/ogcwebservices/wass/wss/operation/DoServiceSessionHandler.java $ 002 /*---------------- FILE HEADER ------------------------------------------ 003 004 This file is part of deegree. 005 Copyright (C) 2001-2006 by: 006 EXSE, Department of Geography, University of Bonn 007 http://www.giub.uni-bonn.de/exse/ 008 lat/lon GmbH 009 http://www.lat-lon.de 010 011 This library is free software; you can redistribute it and/or 012 modify it under the terms of the GNU Lesser General Public 013 License as published by the Free Software Foundation; either 014 version 2.1 of the License, or (at your option) any later version. 015 016 This library is distributed in the hope that it will be useful, 017 but WITHOUT ANY WARRANTY; without even the implied warranty of 018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 019 Lesser General Public License for more details. 020 021 You should have received a copy of the GNU Lesser General Public 022 License along with this library; if not, write to the Free Software 023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 024 025 Contact: 026 027 Andreas Poth 028 lat/lon GmbH 029 Aennchenstraße 19 030 53177 Bonn 031 Germany 032 E-Mail: poth@lat-lon.de 033 034 Jens Fitzke 035 lat/lon GmbH 036 Aennchenstraße 19 037 53177 Bonn 038 Germany 039 E-Mail: jens.fitzke@uni-bonn.de 040 041 ---------------------------------------------------------------------------*/ 042 043 package org.deegree.ogcwebservices.wass.wss.operation; 044 045 import org.deegree.framework.log.ILogger; 046 import org.deegree.framework.log.LoggerFactory; 047 import org.deegree.i18n.Messages; 048 import org.deegree.ogcwebservices.wass.common.AuthenticationData; 049 import org.deegree.ogcwebservices.wass.exceptions.DoServiceException; 050 import org.deegree.security.session.MemoryBasedSessionManager; 051 import org.deegree.security.session.Session; 052 import org.deegree.security.session.SessionStatusException; 053 054 /** 055 * Checks if the session presented from a client is valid. 056 * 057 * @author <a href="mailto:bezema@lat-lon.de">Rutger Bezema</a> 058 * 059 * @author last edited by: $Author: aschmitz $ 060 * 061 * @version 2.0, $Revision: 7341 $, $Date: 2007-05-29 14:03:14 +0200 (Di, 29 Mai 2007) $ 062 * 063 * @since 2.0 064 */ 065 066 public class DoServiceSessionHandler extends DoServiceHandler { 067 068 private static final ILogger LOG = LoggerFactory.getLogger( DoServiceSessionHandler.class ); 069 070 private final MemoryBasedSessionManager sessionManager; 071 072 /** 073 * 074 */ 075 public DoServiceSessionHandler() { 076 sessionManager = MemoryBasedSessionManager.getInstance(); 077 } 078 079 @Override 080 public void handleRequest( DoService request ) 081 throws DoServiceException { 082 083 AuthenticationData authData = request.getAuthenticationData(); 084 if ( authData.usesSessionAuthentication() ) { 085 try { 086 Session ses = sessionManager.getSessionByID( authData.getCredentials() ); 087 if ( ses == null || !ses.isAlive() ){ 088 throw new DoServiceException( 089 Messages.getMessage( 090 "WASS_ERROR_INVALID_SESSION", 091 "WSS" ) ); 092 093 } 094 setRequestAllowed( true ); 095 } catch ( SessionStatusException e ) { 096 LOG.logError( e.getLocalizedMessage(), e ); 097 throw new DoServiceException( e.getLocalizedMessage(), e ); 098 } 099 } 100 101 } 102 103 }