|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| TestOnceAfterMaxRequestsCaptchaChannelProcessor.java | 100% | 100% | 100% | 100% |
|
||||||||||||||
| 1 | /* Copyright 2004, 2005 Acegi Technology Pty Limited | |
| 2 | * | |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 | * you may not use this file except in compliance with the License. | |
| 5 | * You may obtain a copy of the License at | |
| 6 | * | |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 | * | |
| 9 | * Unless required by applicable law or agreed to in writing, software | |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 | * See the License for the specific language governing permissions and | |
| 13 | * limitations under the License. | |
| 14 | */ | |
| 15 | package org.acegisecurity.captcha; | |
| 16 | ||
| 17 | /** | |
| 18 | * <p> | |
| 19 | * return false if ny CaptchaChannelProcessorTemplate mapped urls has been | |
| 20 | * requested more than thresold and humanity is false; <br> | |
| 21 | * Default keyword : REQUIRES_CAPTCHA_ONCE_ABOVE_THRESOLD_REQUESTS | |
| 22 | * </p> | |
| 23 | * | |
| 24 | * @author Marc-Antoine Garrigue | |
| 25 | * @version $Id: TestOnceAfterMaxRequestsCaptchaChannelProcessor.java,v 1.2 2005/11/17 00:55:49 benalex Exp $ | |
| 26 | */ | |
| 27 | public class TestOnceAfterMaxRequestsCaptchaChannelProcessor | |
| 28 | extends CaptchaChannelProcessorTemplate { | |
| 29 | //~ Static fields/initializers ============================================= | |
| 30 | ||
| 31 | public static final String DEFAULT_KEYWORD = "REQUIRES_CAPTCHA_ONCE_ABOVE_THRESOLD_REQUESTS"; | |
| 32 | ||
| 33 | //~ Constructors =========================================================== | |
| 34 | ||
| 35 | 2 | public TestOnceAfterMaxRequestsCaptchaChannelProcessor() { |
| 36 | 2 | super(); |
| 37 | 2 | this.setKeyword(DEFAULT_KEYWORD); |
| 38 | } | |
| 39 | ||
| 40 | //~ Methods ================================================================ | |
| 41 | ||
| 42 | 13 | boolean isContextValidConcerningHumanity(CaptchaSecurityContext context) { |
| 43 | 13 | if (context.isHuman() |
| 44 | || (context.getHumanRestrictedResourcesRequestsCount() < getThresold())) { | |
| 45 | 10 | logger.debug( |
| 46 | "context is valid concerning humanity or request count < thresold"); | |
| 47 | ||
| 48 | 10 | return true; |
| 49 | } else { | |
| 50 | 3 | logger.debug( |
| 51 | "context is not valid concerning humanity and request count > thresold"); | |
| 52 | ||
| 53 | 3 | return false; |
| 54 | } | |
| 55 | } | |
| 56 | } |
|
||||||||||