001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.captcha;
016    
017    import com.liferay.portal.kernel.captcha.CaptchaUtil;
018    import com.liferay.portal.kernel.log.Log;
019    import com.liferay.portal.kernel.log.LogFactoryUtil;
020    import com.liferay.portal.struts.PortletAction;
021    
022    import javax.portlet.PortletConfig;
023    import javax.portlet.ResourceRequest;
024    import javax.portlet.ResourceResponse;
025    
026    import org.apache.struts.action.ActionForm;
027    import org.apache.struts.action.ActionMapping;
028    
029    /**
030     * @author Brian Wing Shun Chan
031     */
032    public class CaptchaPortletAction extends PortletAction {
033    
034            @Override
035            public void serveResource(
036                            ActionMapping actionMapping, ActionForm actionForm,
037                            PortletConfig portletConfig, ResourceRequest resourceRequest,
038                            ResourceResponse resourceResponse)
039                    throws Exception {
040    
041                    try {
042                            CaptchaUtil.serveImage(resourceRequest, resourceResponse);
043                    }
044                    catch (Exception e) {
045                            _log.error(e);
046                    }
047            }
048    
049            @Override
050            protected boolean isCheckMethodOnProcessAction() {
051                    return _CHECK_METHOD_ON_PROCESS_ACTION;
052            }
053    
054            private static final boolean _CHECK_METHOD_ON_PROCESS_ACTION = false;
055    
056            private static Log _log = LogFactoryUtil.getLog(CaptchaPortletAction.class);
057    
058    }