ValidatePasswordServlet.java

00001 /*
00002  * OpenMobileIS - a free Java(TM) Framework for mobile applications Java(TM)
00003  * Copyright (C) 2004-2006 Philippe Delrieu
00004  * All rights reserved.
00005  * Contact: pdelrieu@openmobileis.org
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00020  * USA
00021  *
00022  *  Author : Philippe Delrieu
00023  *  
00024  *  Modifications :
00025  *  Creation P.Delrieu
00026  * 
00027  */
00028 
00029 package org.openmobileis.services.security;
00030 
00031 import javax.servlet.ServletException;
00032 import javax.servlet.http.HttpServlet;
00033 import javax.servlet.http.HttpServletRequest;
00034 import javax.servlet.http.HttpServletResponse;
00035 
00036 import org.openmobileis.common.intl.IntlResourceManager;
00037 import org.openmobileis.common.util.log.LogManager;
00038 import org.openmobileis.common.util.log.LogServices;
00039 import org.openmobileis.embedded.webserver.WebServerConnection;
00040 import org.openmobileis.services.Service;
00041 
00049 public class ValidatePasswordServlet extends HttpServlet {
00050   static final long serialVersionUID = 5521257935120563452L;
00051         
00052   public void service( HttpServletRequest req, HttpServletResponse res ) throws ServletException, java.io.IOException {
00053         try     {
00054                 String pass = req.getParameter("password");
00055                 if ((pass==null)||(pass.length() ==0) ||  (!SessionLoginManager.getManager().validateSessionPass(pass)))        {
00056                         req.getSession(true).setAttribute("security.pass.form", IntlResourceManager.getManager().getLocalizedProperty("org.openmobileis.module.login.validatepassword.error.login"));
00057                 } else  {
00058                         SessionLoginManager.getManager().setServiceCall();
00059                 }
00060         } catch (Throwable ex)  {
00061                 LogManager.traceError(LogServices.WEBSERVICE, ex);
00062                 req.getSession(true).setAttribute("security.pass.form", IntlResourceManager.getManager().getLocalizedProperty("org.openmobileis.module.login.validatepassword.error.login"));
00063         }
00064         Service service = (Service)req.getSession(true).getAttribute("passservletreturnservice");
00065         String uri = (String)req.getSession(true).getAttribute("passservletreturnservicerequri");
00066         java.util.Map oldparam = (java.util.Map)req.getSession(true).getAttribute("passservletreturnservicereqparam");
00067         ((WebServerConnection)res).setRequestURI(uri);
00068         java.util.Map newparam = req.getParameterMap();
00069         newparam.clear();
00070         newparam.putAll(oldparam);
00071         service.runService(req, res);
00072   }
00073 
00074 }

Generated on Tue May 22 23:01:12 2007 for OpenMobileIS by  doxygen 1.5.1-p1