PasswordFormServlet.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.util.log.LogManager;
00037 import org.openmobileis.common.util.log.LogServices;
00038 import org.openmobileis.embedded.webserver.templates.TemplateManager;
00039 
00040 import freemarker.template.SimpleScalar;
00041 import freemarker.template.TemplateModelRoot;
00042 
00051 public final class PasswordFormServlet extends HttpServlet {
00052   static final long serialVersionUID = 5521257935120563452L;
00053 //      public static final String SERVICE_URI = "/showpassform";
00054   public void service( HttpServletRequest req, HttpServletResponse res ) throws ServletException, java.io.IOException {
00055                 String templateName="openmischannel/passwordform.htm";
00056     try {
00057                         TemplateModelRoot modelRoot = TemplateManager.getManager().getTemplateModelRoot();
00058                         //manage error
00059                         String error = (String)req.getSession(true).getAttribute("security.pass.form");
00060                         if (error !=null)       {
00061                         modelRoot.put("haserror", new SimpleScalar(true));
00062                         modelRoot.put("errorMessage", new SimpleScalar(error));
00063                                 req.getSession(true).removeAttribute("security.pass.form");
00064                         }      
00065       
00066       TemplateManager.getManager().sendResponse(templateName, modelRoot, res);
00067     } catch (Throwable ex)  {
00068         res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Internal Error");
00069         LogManager.traceAlert(LogServices.WEBSERVICE, "Error during execution of Service show password");
00070         LogManager.traceAlert(LogServices.WEBSERVICE, ex);
00071     }
00072   }
00073 
00074 }

Generated on Mon Jan 14 17:29:49 2008 for OpenMobileIS by  doxygen 1.5.4