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.PortletResponse;
023
024 import javax.servlet.http.HttpServletRequest;
025 import javax.servlet.http.HttpServletResponse;
026
027
030 public class CaptchaUtil {
031
032 public static void check(HttpServletRequest request)
033 throws CaptchaException {
034
035 getCaptcha().check(request);
036 }
037
038 public static void check(PortletRequest portletRequest)
039 throws CaptchaException {
040
041 getCaptcha().check(portletRequest);
042 }
043
044 public static Captcha getCaptcha() {
045 PortalRuntimePermission.checkGetBeanProperty(CaptchaUtil.class);
046
047 return _captcha;
048 }
049
050 public static String getTaglibPath() {
051 return getCaptcha().getTaglibPath();
052 }
053
054 public static boolean isEnabled(HttpServletRequest request)
055 throws CaptchaException {
056
057 return getCaptcha().isEnabled(request);
058 }
059
060 public static boolean isEnabled(PortletRequest portletRequest)
061 throws CaptchaException {
062
063 return getCaptcha().isEnabled(portletRequest);
064 }
065
066 public static void serveImage(
067 HttpServletRequest request, HttpServletResponse response)
068 throws IOException {
069
070 getCaptcha().serveImage(request, response);
071 }
072
073 public static void serveImage(
074 PortletRequest portletRequest, PortletResponse portletResponse)
075 throws IOException {
076
077 getCaptcha().serveImage(portletRequest, portletResponse);
078 }
079
080 public void setCaptcha(Captcha captcha) {
081 PortalRuntimePermission.checkSetBeanProperty(getClass());
082
083 _captcha = captcha;
084 }
085
086 private static Captcha _captcha;
087
088 }