/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library 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 Lesser General Public License for more * details. */ package com.liferay.portal.settings.authentication.opensso.web.internal.portlet.action; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.portlet.bridges.mvc.MVCRenderCommand; import com.liferay.portal.kernel.portlet.bridges.mvc.MVCRenderConstants; import com.liferay.portal.kernel.util.Portal; import com.liferay.portal.settings.web.constants.PortalSettingsPortletKeys; import javax.portlet.PortletException; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; /** * @author Philip Jones */ @Component( property = { "javax.portlet.name=" + PortalSettingsPortletKeys.PORTAL_SETTINGS, "mvc.command.name=/portal_settings/test_opensso" } ) public class PortalSettingsTestOpenSSOMVCRenderCommand implements MVCRenderCommand { @Override public String render( RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { RequestDispatcher requestDispatcher = _servletContext.getRequestDispatcher(_JSP_PATH); try { HttpServletRequest httpServletRequest = _portal.getHttpServletRequest(renderRequest); HttpServletResponse httpServletResponse = _portal.getHttpServletResponse(renderResponse); requestDispatcher.include(httpServletRequest, httpServletResponse); } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug("Unable to include JSP " + _JSP_PATH, e); } throw new PortletException("Unable to include JSP " + _JSP_PATH, e); } return MVCRenderConstants.MVC_PATH_VALUE_SKIP_DISPATCH; } @Reference( target = "(osgi.web.symbolicname=com.liferay.portal.settings.authentication.opensso.web)", unbind = "-" ) protected void setServletContext(ServletContext servletContext) { _servletContext = servletContext; } private static final String _JSP_PATH = "/com.liferay.portal.settings.web/test_opensso.jsp"; private static final Log _log = LogFactoryUtil.getLog( PortalSettingsTestOpenSSOMVCRenderCommand.class); @Reference private Portal _portal; private ServletContext _servletContext; }