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 return getCaptcha().isEnabled(request);
057 }
058
059 public static boolean isEnabled(PortletRequest portletRequest) {
060 return getCaptcha().isEnabled(portletRequest);
061 }
062
063 public static void serveImage(
064 HttpServletRequest request, HttpServletResponse response)
065 throws IOException {
066
067 getCaptcha().serveImage(request, response);
068 }
069
070 public static void serveImage(
071 ResourceRequest resourceRequest, ResourceResponse resourceResponse)
072 throws IOException {
073
074 getCaptcha().serveImage(resourceRequest, resourceResponse);
075 }
076
077 public void setCaptcha(Captcha captcha) {
078 PortalRuntimePermission.checkSetBeanProperty(getClass());
079
080 _captcha = captcha;
081 }
082
083 private static Captcha _captcha;
084
085 }