|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| CaptchaSecurityContextImpl.java | - | 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 | package org.acegisecurity.captcha; | |
| 17 | ||
| 18 | import org.acegisecurity.context.SecurityContextImpl; | |
| 19 | ||
| 20 | ||
| 21 | /** | |
| 22 | * Default CaptchaSecurityContext implementation | |
| 23 | * | |
| 24 | * @author mag | |
| 25 | */ | |
| 26 | public class CaptchaSecurityContextImpl extends SecurityContextImpl | |
| 27 | implements CaptchaSecurityContext { | |
| 28 | //~ Instance fields ======================================================== | |
| 29 | ||
| 30 | private boolean human; | |
| 31 | private int humanRestrictedResourcesRequestsCount; | |
| 32 | private long lastPassedCaptchaDate; | |
| 33 | ||
| 34 | //~ Constructors =========================================================== | |
| 35 | ||
| 36 | /** | |
| 37 | * | |
| 38 | */ | |
| 39 | 20 | public CaptchaSecurityContextImpl() { |
| 40 | 20 | super(); |
| 41 | 20 | human = false; |
| 42 | 20 | lastPassedCaptchaDate = 0; |
| 43 | 20 | humanRestrictedResourcesRequestsCount = 0; |
| 44 | } | |
| 45 | ||
| 46 | //~ Methods ================================================================ | |
| 47 | ||
| 48 | /** | |
| 49 | * reset the lastPassedCaptchaDate and count. | |
| 50 | */ | |
| 51 | 16 | public void setHuman() { |
| 52 | 16 | this.human = true; |
| 53 | 16 | this.lastPassedCaptchaDate = System.currentTimeMillis(); |
| 54 | 16 | this.humanRestrictedResourcesRequestsCount = 0; |
| 55 | } | |
| 56 | ||
| 57 | /* | |
| 58 | * (non-Javadoc) | |
| 59 | * | |
| 60 | * @see org.acegisecurity.context.CaptchaSecurityContext#isHuman() | |
| 61 | */ | |
| 62 | 273862 | public boolean isHuman() { |
| 63 | 273862 | return human; |
| 64 | } | |
| 65 | ||
| 66 | /* | |
| 67 | * (non-Javadoc) | |
| 68 | * | |
| 69 | * @see org.acegisecurity.context.CaptchaSecurityContext#getHumanRestrictedResourcesRequestsCount() | |
| 70 | */ | |
| 71 | 273862 | public int getHumanRestrictedResourcesRequestsCount() { |
| 72 | 273862 | return humanRestrictedResourcesRequestsCount; |
| 73 | } | |
| 74 | ||
| 75 | /* | |
| 76 | * (non-Javadoc) | |
| 77 | * | |
| 78 | * @see org.acegisecurity.context.CaptchaSecurityContext#getLastPassedCaptchaDateInMillis() | |
| 79 | */ | |
| 80 | 409225 | public long getLastPassedCaptchaDateInMillis() { |
| 81 | 409225 | return lastPassedCaptchaDate; |
| 82 | } | |
| 83 | ||
| 84 | /** | |
| 85 | * Method to increment the human Restricted Resrouces Requests Count; | |
| 86 | */ | |
| 87 | 21 | public void incrementHumanRestrictedRessoucesRequestsCount() { |
| 88 | 21 | humanRestrictedResourcesRequestsCount++; |
| 89 | } | |
| 90 | } |
|
||||||||||