|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| AlwaysTestAfterMaxRequestsCaptchaChannelProcessor.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 | ||
| 16 | /* | |
| 17 | * Copyright (c) 2005 Your Corporation. All Rights Reserved. | |
| 18 | */ | |
| 19 | package org.acegisecurity.captcha; | |
| 20 | ||
| 21 | /** | |
| 22 | * <p> | |
| 23 | * return false if ny CaptchaChannelProcessorTemplate of mapped urls has been | |
| 24 | * requested more than thresold; <br> | |
| 25 | * Default keyword : REQUIRES_CAPTCHA_ABOVE_THRESOLD_REQUESTS | |
| 26 | * </p> | |
| 27 | * | |
| 28 | * @author Marc-Antoine Garrigue | |
| 29 | * @version $Id: AlwaysTestAfterMaxRequestsCaptchaChannelProcessor.java,v 1.2 2005/11/17 00:55:49 benalex Exp $ | |
| 30 | */ | |
| 31 | public class AlwaysTestAfterMaxRequestsCaptchaChannelProcessor | |
| 32 | extends CaptchaChannelProcessorTemplate { | |
| 33 | //~ Static fields/initializers ============================================= | |
| 34 | ||
| 35 | /** Keyword for this channelProcessor */ | |
| 36 | public static final String DEFAULT_KEYWORD = "REQUIRES_CAPTCHA_ABOVE_THRESOLD_REQUESTS"; | |
| 37 | ||
| 38 | //~ Constructors =========================================================== | |
| 39 | ||
| 40 | /** | |
| 41 | * Constructor | |
| 42 | */ | |
| 43 | 2 | public AlwaysTestAfterMaxRequestsCaptchaChannelProcessor() { |
| 44 | 2 | super(); |
| 45 | 2 | this.setKeyword(DEFAULT_KEYWORD); |
| 46 | } | |
| 47 | ||
| 48 | //~ Methods ================================================================ | |
| 49 | ||
| 50 | /** | |
| 51 | * Verify wheter the context is valid concerning humanity | |
| 52 | * | |
| 53 | * @param context | |
| 54 | * | |
| 55 | * @return true if valid, false otherwise | |
| 56 | */ | |
| 57 | 7 | boolean isContextValidConcerningHumanity(CaptchaSecurityContext context) { |
| 58 | 7 | if (context.getHumanRestrictedResourcesRequestsCount() < getThresold()) { |
| 59 | 4 | logger.debug("context is valid : request count < thresold"); |
| 60 | ||
| 61 | 4 | return true; |
| 62 | } else { | |
| 63 | 3 | logger.debug("context is not valid : request count > thresold"); |
| 64 | ||
| 65 | 3 | return false; |
| 66 | } | |
| 67 | } | |
| 68 | } |
|
||||||||||