/*
This file is part of tPortal.
tPortal 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 3 of the License, or
(at your option) any later version.
tPortal 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 tPortal. If not, see <http://www.gnu.org/licenses/>.
The original code was written by Sebastien Bettinger <sebastien.bettinger@gmail.com>
*/
package net.tinyportal.portlet;
import java.io.IOException;
import java.security.Principal;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import org.apache.log4j.Logger;
public class LoginPortlet extends GenericPortlet {
private static final Logger logger = Logger.getLogger(LoginPortlet.class);
public void processAction (ActionRequest request, ActionResponse response)
throws PortletException, java.io.IOException {
logger.error("Action");
}
public void doView(RenderRequest request,RenderResponse response)
throws PortletException,IOException {
Principal user = request.getUserPrincipal();
if (user == null) {
PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/login.jsp");
dispatcher.include(request, response);
} else {
request.setAttribute("user", user);
PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/logged.jsp");
dispatcher.include(request, response);
}
}
}