001
014
015 package com.liferay.portal.kernel.captcha;
016
017 import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018
019 import java.io.IOException;
020
021 import javax.portlet.PortletRequest;
022 import javax.portlet.ResourceRequest;
023 import javax.portlet.ResourceResponse;
024
025 import javax.servlet.http.HttpServletRequest;
026 import javax.servlet.http.HttpServletResponse;
027
028
031 public class CaptchaUtil {
032
033 public static void check(HttpServletRequest request)
034 throws CaptchaException {
035
036 getCaptcha().check(request);
037 }
038
039 public static void check(PortletRequest portletRequest)
040 throws CaptchaException {
041
042 getCaptcha().check(portletRequest);
043 }
044
045 public static Captcha getCaptcha() {
046 PortalRuntimePermission.checkGetBeanProperty(CaptchaUtil.class);
047
048 return _captcha;
049 }
050
051 public static String getTaglibPath() {
052 return getCaptcha().getTaglibPath();
053 }
054
055 public static boolean isEnabled(HttpServletRequest request)
056 throws CaptchaException {
057
058 return getCaptcha().isEnabled(request);
059 }
060
061 public static boolean isEnabled(PortletRequest portletRequest)
062 throws CaptchaException {
063
064 return getCaptcha().isEnabled(portletRequest);
065 }
066
067 public static void serveImage(
068 HttpServletRequest request, HttpServletResponse response)
069 throws IOException {
070
071 getCaptcha().serveImage(request, response);
072 }
073
074 public static void serveImage(
075 ResourceRequest resourceRequest, ResourceResponse resourceResponse)
076 throws IOException {
077
078 getCaptcha().serveImage(resourceRequest, resourceResponse);
079 }
080
081 public void setCaptcha(Captcha captcha) {
082 PortalRuntimePermission.checkSetBeanProperty(getClass());
083
084 _captcha = captcha;
085 }
086
087 private static Captcha _captcha;
088
089 }