From dd2a46c7ca66ba3b29fcfb75305a587096ab0c65 Mon Sep 17 00:00:00 2001 From: Luke Taylor Date: Tue, 11 Sep 2007 11:11:05 +0000 Subject: [PATCH] SEC-368: Tidied up captcha spelling. --- ...ysTestAfterMaxRequestsCaptchaChannelProcessor.java | 9 ++++----- ...sTestAfterTimeInMillisCaptchaChannelProcessor.java | 8 ++++---- ...geTimeInMillisBetweenRequestsChannelProcessor.java | 7 +++---- .../captcha/CaptchaChannelProcessorTemplate.java | 4 ++-- .../org/acegisecurity/captcha/CaptchaEntryPoint.java | 3 --- .../acegisecurity/captcha/CaptchaSecurityContext.java | 2 +- .../captcha/CaptchaSecurityContextImpl.java | 2 +- ...stOnceAfterMaxRequestsCaptchaChannelProcessor.java | 3 +-- ...tAfterMaxRequestsCaptchaChannelProcessorTests.java | 11 ++++------- ...AfterTimeInMillisCaptchaChannelProcessorTests.java | 2 +- ...eInMillisBetweenRequestsChannelProcessorTests.java | 6 +++--- .../captcha/CaptchaChannelProcessorTemplateTests.java | 4 ++-- .../captcha/CaptchaSecurityContextImplTests.java | 8 ++++---- ...eAfterMaxRequestsCaptchaChannelProcessorTests.java | 8 ++++---- 14 files changed, 34 insertions(+), 43 deletions(-) diff --git a/core/src/main/java/org/acegisecurity/captcha/AlwaysTestAfterMaxRequestsCaptchaChannelProcessor.java b/core/src/main/java/org/acegisecurity/captcha/AlwaysTestAfterMaxRequestsCaptchaChannelProcessor.java index ca7d0bd80a..53a998e76c 100644 --- a/core/src/main/java/org/acegisecurity/captcha/AlwaysTestAfterMaxRequestsCaptchaChannelProcessor.java +++ b/core/src/main/java/org/acegisecurity/captcha/AlwaysTestAfterMaxRequestsCaptchaChannelProcessor.java @@ -29,29 +29,28 @@ public class AlwaysTestAfterMaxRequestsCaptchaChannelProcessor extends CaptchaCh //~ Static fields/initializers ===================================================================================== /** Keyword for this channelProcessor */ - public static final String DEFAULT_KEYWORD = "REQUIRES_CAPTCHA_ABOVE_THRESOLD_REQUESTS"; + public static final String DEFAULT_KEYWORD = "REQUIRES_CAPTCHA_ABOVE_THRESHOLD_REQUESTS"; //~ Constructors =================================================================================================== -/** + /** * Constructor */ public AlwaysTestAfterMaxRequestsCaptchaChannelProcessor() { - super(); this.setKeyword(DEFAULT_KEYWORD); } //~ Methods ======================================================================================================== /** - * Verify wheter the context is valid concerning humanity + * Verify whether the context is valid concerning humanity * * @param context * * @return true if valid, false otherwise */ boolean isContextValidConcerningHumanity(CaptchaSecurityContext context) { - if (context.getHumanRestrictedResourcesRequestsCount() < getThresold()) { + if (context.getHumanRestrictedResourcesRequestsCount() < getThreshold()) { logger.debug("context is valid : request count < thresold"); return true; diff --git a/core/src/main/java/org/acegisecurity/captcha/AlwaysTestAfterTimeInMillisCaptchaChannelProcessor.java b/core/src/main/java/org/acegisecurity/captcha/AlwaysTestAfterTimeInMillisCaptchaChannelProcessor.java index 8fd089bfe7..fc9966fc25 100644 --- a/core/src/main/java/org/acegisecurity/captcha/AlwaysTestAfterTimeInMillisCaptchaChannelProcessor.java +++ b/core/src/main/java/org/acegisecurity/captcha/AlwaysTestAfterTimeInMillisCaptchaChannelProcessor.java @@ -26,15 +26,15 @@ public class AlwaysTestAfterTimeInMillisCaptchaChannelProcessor extends CaptchaC //~ Static fields/initializers ===================================================================================== /** Keyword for this channelProcessor */ - public static final String DEFAULT_KEYWORD = "REQUIRES_CAPTCHA_AFTER_THRESOLD_IN_MILLIS"; + public static final String DEFAULT_KEYWORD = "REQUIRES_CAPTCHA_AFTER_THRESHOLD_IN_MILLIS"; //~ Constructors =================================================================================================== -/** + /** * Constructor */ public AlwaysTestAfterTimeInMillisCaptchaChannelProcessor() { - super(); + this.setKeyword(DEFAULT_KEYWORD); } @@ -48,7 +48,7 @@ public class AlwaysTestAfterTimeInMillisCaptchaChannelProcessor extends CaptchaC * @return true if valid, false otherwise */ boolean isContextValidConcerningHumanity(CaptchaSecurityContext context) { - if ((System.currentTimeMillis() - context.getLastPassedCaptchaDateInMillis()) < getThresold()) { + if ((System.currentTimeMillis() - context.getLastPassedCaptchaDateInMillis()) < getThreshold()) { logger.debug("context is valid : last passed captcha date - current time < thresold"); return true; diff --git a/core/src/main/java/org/acegisecurity/captcha/AlwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessor.java b/core/src/main/java/org/acegisecurity/captcha/AlwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessor.java index 900dfb45bf..2234c8d5ae 100644 --- a/core/src/main/java/org/acegisecurity/captcha/AlwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessor.java +++ b/core/src/main/java/org/acegisecurity/captcha/AlwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessor.java @@ -35,11 +35,10 @@ public class AlwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessor e //~ Constructors =================================================================================================== -/** + /** * Constructor */ public AlwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessor() { - super(); this.setKeyword(DEFAULT_KEYWORD); } @@ -52,7 +51,7 @@ public class AlwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessor e */ public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); - Assert.isTrue(getThresold() > 0, "thresold must be > 0"); + Assert.isTrue(getThreshold() > 0, "thresold must be > 0"); } /** @@ -64,7 +63,7 @@ public class AlwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessor e */ boolean isContextValidConcerningHumanity(CaptchaSecurityContext context) { int req = context.getHumanRestrictedResourcesRequestsCount(); - float thresold = getThresold(); + float thresold = getThreshold(); float duration = System.currentTimeMillis() - context.getLastPassedCaptchaDateInMillis(); float average; diff --git a/core/src/main/java/org/acegisecurity/captcha/CaptchaChannelProcessorTemplate.java b/core/src/main/java/org/acegisecurity/captcha/CaptchaChannelProcessorTemplate.java index 1a037b746b..1ab56e5c39 100644 --- a/core/src/main/java/org/acegisecurity/captcha/CaptchaChannelProcessorTemplate.java +++ b/core/src/main/java/org/acegisecurity/captcha/CaptchaChannelProcessorTemplate.java @@ -99,7 +99,7 @@ public abstract class CaptchaChannelProcessorTemplate implements ChannelProcesso redirectToEntryPoint(invocation); } else { logger.debug("has been successfully checked this keyword, increment request count"); - context.incrementHumanRestrictedRessoucesRequestsCount(); + context.incrementHumanRestrictedResourcesRequestsCount(); } } else { logger.debug("do not support this attribute"); @@ -115,7 +115,7 @@ public abstract class CaptchaChannelProcessorTemplate implements ChannelProcesso return keyword; } - public int getThresold() { + public int getThreshold() { return thresold; } diff --git a/core/src/main/java/org/acegisecurity/captcha/CaptchaEntryPoint.java b/core/src/main/java/org/acegisecurity/captcha/CaptchaEntryPoint.java index 83767816a1..47363ee543 100644 --- a/core/src/main/java/org/acegisecurity/captcha/CaptchaEntryPoint.java +++ b/core/src/main/java/org/acegisecurity/captcha/CaptchaEntryPoint.java @@ -92,8 +92,6 @@ public class CaptchaEntryPoint implements ChannelEntryPoint, InitializingBean { //~ Instance fields ================================================================================================ - // ~ Instance fields - // ======================================================== private PortMapper portMapper = new PortMapperImpl(); private PortResolver portResolver = new PortResolverImpl(); private String captchaFormUrl; @@ -208,7 +206,6 @@ public class CaptchaEntryPoint implements ChannelEntryPoint, InitializingBean { } /** - * DOCUMENT ME! * * @return the captcha test page to redirect to. */ diff --git a/core/src/main/java/org/acegisecurity/captcha/CaptchaSecurityContext.java b/core/src/main/java/org/acegisecurity/captcha/CaptchaSecurityContext.java index 6a04dae869..9741b48b5d 100644 --- a/core/src/main/java/org/acegisecurity/captcha/CaptchaSecurityContext.java +++ b/core/src/main/java/org/acegisecurity/captcha/CaptchaSecurityContext.java @@ -43,7 +43,7 @@ public interface CaptchaSecurityContext extends SecurityContext { /** * Method to increment the human Restricted Resrouces Requests Count; */ - void incrementHumanRestrictedRessoucesRequestsCount(); + void incrementHumanRestrictedResourcesRequestsCount(); /** * DOCUMENT ME! diff --git a/core/src/main/java/org/acegisecurity/captcha/CaptchaSecurityContextImpl.java b/core/src/main/java/org/acegisecurity/captcha/CaptchaSecurityContextImpl.java index 7b1c76bd9e..40cfec602e 100644 --- a/core/src/main/java/org/acegisecurity/captcha/CaptchaSecurityContextImpl.java +++ b/core/src/main/java/org/acegisecurity/captcha/CaptchaSecurityContextImpl.java @@ -86,7 +86,7 @@ public class CaptchaSecurityContextImpl extends SecurityContextImpl implements C /** * Method to increment the human Restricted Resrouces Requests Count; */ - public void incrementHumanRestrictedRessoucesRequestsCount() { + public void incrementHumanRestrictedResourcesRequestsCount() { humanRestrictedResourcesRequestsCount++; } diff --git a/core/src/main/java/org/acegisecurity/captcha/TestOnceAfterMaxRequestsCaptchaChannelProcessor.java b/core/src/main/java/org/acegisecurity/captcha/TestOnceAfterMaxRequestsCaptchaChannelProcessor.java index e2503e64d8..b97b9ea45e 100644 --- a/core/src/main/java/org/acegisecurity/captcha/TestOnceAfterMaxRequestsCaptchaChannelProcessor.java +++ b/core/src/main/java/org/acegisecurity/captcha/TestOnceAfterMaxRequestsCaptchaChannelProcessor.java @@ -31,14 +31,13 @@ public class TestOnceAfterMaxRequestsCaptchaChannelProcessor extends CaptchaChan //~ Constructors =================================================================================================== public TestOnceAfterMaxRequestsCaptchaChannelProcessor() { - super(); this.setKeyword(DEFAULT_KEYWORD); } //~ Methods ======================================================================================================== boolean isContextValidConcerningHumanity(CaptchaSecurityContext context) { - if (context.isHuman() || (context.getHumanRestrictedResourcesRequestsCount() < getThresold())) { + if (context.isHuman() || (context.getHumanRestrictedResourcesRequestsCount() < getThreshold())) { logger.debug("context is valid concerning humanity or request count < thresold"); return true; diff --git a/core/src/test/java/org/acegisecurity/captcha/AlwaysTestAfterMaxRequestsCaptchaChannelProcessorTests.java b/core/src/test/java/org/acegisecurity/captcha/AlwaysTestAfterMaxRequestsCaptchaChannelProcessorTests.java index 2b3afeff7d..3d9c4b04ab 100644 --- a/core/src/test/java/org/acegisecurity/captcha/AlwaysTestAfterMaxRequestsCaptchaChannelProcessorTests.java +++ b/core/src/test/java/org/acegisecurity/captcha/AlwaysTestAfterMaxRequestsCaptchaChannelProcessorTests.java @@ -15,13 +15,10 @@ package org.acegisecurity.captcha; -import junit.framework.*; - -import org.acegisecurity.captcha.AlwaysTestAfterMaxRequestsCaptchaChannelProcessor; +import junit.framework.TestCase; /** - * DOCUMENT ME! * * @author $author$ * @version $Revision$ @@ -45,16 +42,16 @@ public class AlwaysTestAfterMaxRequestsCaptchaChannelProcessorTests extends Test CaptchaSecurityContextImpl context = new CaptchaSecurityContextImpl(); assertTrue(alwaysTestAfterMaxRequestsCaptchaChannelProcessor.isContextValidConcerningHumanity(context)); - context.incrementHumanRestrictedRessoucesRequestsCount(); + context.incrementHumanRestrictedResourcesRequestsCount(); alwaysTestAfterMaxRequestsCaptchaChannelProcessor.setThresold(-1); assertFalse(alwaysTestAfterMaxRequestsCaptchaChannelProcessor.isContextValidConcerningHumanity(context)); alwaysTestAfterMaxRequestsCaptchaChannelProcessor.setThresold(3); assertTrue(alwaysTestAfterMaxRequestsCaptchaChannelProcessor.isContextValidConcerningHumanity(context)); - context.incrementHumanRestrictedRessoucesRequestsCount(); + context.incrementHumanRestrictedResourcesRequestsCount(); assertTrue(alwaysTestAfterMaxRequestsCaptchaChannelProcessor.isContextValidConcerningHumanity(context)); - context.incrementHumanRestrictedRessoucesRequestsCount(); + context.incrementHumanRestrictedResourcesRequestsCount(); assertFalse(alwaysTestAfterMaxRequestsCaptchaChannelProcessor.isContextValidConcerningHumanity(context)); } diff --git a/core/src/test/java/org/acegisecurity/captcha/AlwaysTestAfterTimeInMillisCaptchaChannelProcessorTests.java b/core/src/test/java/org/acegisecurity/captcha/AlwaysTestAfterTimeInMillisCaptchaChannelProcessorTests.java index bcf5528a4e..2d68999e9f 100644 --- a/core/src/test/java/org/acegisecurity/captcha/AlwaysTestAfterTimeInMillisCaptchaChannelProcessorTests.java +++ b/core/src/test/java/org/acegisecurity/captcha/AlwaysTestAfterTimeInMillisCaptchaChannelProcessorTests.java @@ -61,7 +61,7 @@ public class AlwaysTestAfterTimeInMillisCaptchaChannelProcessorTests extends Tes context.setHuman(); while ((System.currentTimeMillis() - context.getLastPassedCaptchaDateInMillis()) < alwaysTestAfterTimeInMillisCaptchaChannelProcessor - .getThresold()) { + .getThreshold()) { assertTrue(alwaysTestAfterTimeInMillisCaptchaChannelProcessor.isContextValidConcerningHumanity(context)); context.incrementHumanRestrictedRessoucesRequestsCount(); diff --git a/core/src/test/java/org/acegisecurity/captcha/AlwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessorTests.java b/core/src/test/java/org/acegisecurity/captcha/AlwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessorTests.java index 3df075928e..e26491e671 100644 --- a/core/src/test/java/org/acegisecurity/captcha/AlwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessorTests.java +++ b/core/src/test/java/org/acegisecurity/captcha/AlwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessorTests.java @@ -74,7 +74,7 @@ public class AlwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessorTe context.setHuman(); while ((System.currentTimeMillis() - context.getLastPassedCaptchaDateInMillis()) < (10 * alwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessor - .getThresold())) { + .getThreshold())) { assertTrue(alwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessor .isContextValidConcerningHumanity(context)); } @@ -98,14 +98,14 @@ public class AlwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessorTe int i = 0; while ((System.currentTimeMillis() - context.getLastPassedCaptchaDateInMillis()) < (100 * alwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessor - .getThresold())) { + .getThreshold())) { System.out.println((System.currentTimeMillis() - context.getLastPassedCaptchaDateInMillis())); context.incrementHumanRestrictedRessoucesRequestsCount(); i++; while ((System.currentTimeMillis() - context.getLastPassedCaptchaDateInMillis()) < (alwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessor - .getThresold() * i)) {} + .getThreshold() * i)) {} System.out.println((System.currentTimeMillis() - context.getLastPassedCaptchaDateInMillis())); diff --git a/core/src/test/java/org/acegisecurity/captcha/CaptchaChannelProcessorTemplateTests.java b/core/src/test/java/org/acegisecurity/captcha/CaptchaChannelProcessorTemplateTests.java index 5bf61eb992..8737ae826c 100644 --- a/core/src/test/java/org/acegisecurity/captcha/CaptchaChannelProcessorTemplateTests.java +++ b/core/src/test/java/org/acegisecurity/captcha/CaptchaChannelProcessorTemplateTests.java @@ -122,9 +122,9 @@ public class CaptchaChannelProcessorTemplateTests extends TestCase { processor.setKeyword("X"); assertEquals("X", processor.getKeyword()); - assertEquals(0, processor.getThresold()); + assertEquals(0, processor.getThreshold()); processor.setThresold(1); - assertEquals(1, processor.getThresold()); + assertEquals(1, processor.getThreshold()); assertTrue(processor.getEntryPoint() == null); processor.setEntryPoint(new CaptchaEntryPoint()); diff --git a/core/src/test/java/org/acegisecurity/captcha/CaptchaSecurityContextImplTests.java b/core/src/test/java/org/acegisecurity/captcha/CaptchaSecurityContextImplTests.java index de9491a0eb..0dccdfa1e3 100644 --- a/core/src/test/java/org/acegisecurity/captcha/CaptchaSecurityContextImplTests.java +++ b/core/src/test/java/org/acegisecurity/captcha/CaptchaSecurityContextImplTests.java @@ -48,7 +48,7 @@ public class CaptchaSecurityContextImplTests extends SecurityContextImplTests { context1 = new CaptchaSecurityContextImpl(); assertEquals(context1, context2); - context1.incrementHumanRestrictedRessoucesRequestsCount(); + context1.incrementHumanRestrictedResourcesRequestsCount(); assertNotSame(context1, context2); } @@ -66,7 +66,7 @@ public class CaptchaSecurityContextImplTests extends SecurityContextImplTests { context1 = new CaptchaSecurityContextImpl(); assertEquals(context1.hashCode(), context2.hashCode()); - context1.incrementHumanRestrictedRessoucesRequestsCount(); + context1.incrementHumanRestrictedResourcesRequestsCount(); assertTrue(context1 != context2); } @@ -75,7 +75,7 @@ public class CaptchaSecurityContextImplTests extends SecurityContextImplTests { context.setHuman(); assertEquals("should be human", true, context.isHuman()); assertEquals("should be 0", 0, context.getHumanRestrictedResourcesRequestsCount()); - context.incrementHumanRestrictedRessoucesRequestsCount(); + context.incrementHumanRestrictedResourcesRequestsCount(); assertEquals("should be 1", 1, context.getHumanRestrictedResourcesRequestsCount()); } @@ -84,7 +84,7 @@ public class CaptchaSecurityContextImplTests extends SecurityContextImplTests { context.setHuman(); assertEquals("should be human", true, context.isHuman()); assertEquals("should be 0", 0, context.getHumanRestrictedResourcesRequestsCount()); - context.incrementHumanRestrictedRessoucesRequestsCount(); + context.incrementHumanRestrictedResourcesRequestsCount(); assertEquals("should be 1", 1, context.getHumanRestrictedResourcesRequestsCount()); long now = System.currentTimeMillis(); diff --git a/core/src/test/java/org/acegisecurity/captcha/TestOnceAfterMaxRequestsCaptchaChannelProcessorTests.java b/core/src/test/java/org/acegisecurity/captcha/TestOnceAfterMaxRequestsCaptchaChannelProcessorTests.java index d51e81046a..3995979ea7 100644 --- a/core/src/test/java/org/acegisecurity/captcha/TestOnceAfterMaxRequestsCaptchaChannelProcessorTests.java +++ b/core/src/test/java/org/acegisecurity/captcha/TestOnceAfterMaxRequestsCaptchaChannelProcessorTests.java @@ -45,20 +45,20 @@ public class TestOnceAfterMaxRequestsCaptchaChannelProcessorTests extends TestCa CaptchaSecurityContextImpl context = new CaptchaSecurityContextImpl(); assertTrue(testOnceAfterMaxRequestsCaptchaChannelProcessor.isContextValidConcerningHumanity(context)); - context.incrementHumanRestrictedRessoucesRequestsCount(); + context.incrementHumanRestrictedResourcesRequestsCount(); testOnceAfterMaxRequestsCaptchaChannelProcessor.setThresold(-1); assertFalse(testOnceAfterMaxRequestsCaptchaChannelProcessor.isContextValidConcerningHumanity(context)); testOnceAfterMaxRequestsCaptchaChannelProcessor.setThresold(3); assertTrue(testOnceAfterMaxRequestsCaptchaChannelProcessor.isContextValidConcerningHumanity(context)); - context.incrementHumanRestrictedRessoucesRequestsCount(); + context.incrementHumanRestrictedResourcesRequestsCount(); assertTrue(testOnceAfterMaxRequestsCaptchaChannelProcessor.isContextValidConcerningHumanity(context)); - context.incrementHumanRestrictedRessoucesRequestsCount(); + context.incrementHumanRestrictedResourcesRequestsCount(); assertFalse(testOnceAfterMaxRequestsCaptchaChannelProcessor.isContextValidConcerningHumanity(context)); context.setHuman(); - for (int i = 0; i < (2 * testOnceAfterMaxRequestsCaptchaChannelProcessor.getThresold()); i++) { + for (int i = 0; i < (2 * testOnceAfterMaxRequestsCaptchaChannelProcessor.getThreshold()); i++) { assertTrue(testOnceAfterMaxRequestsCaptchaChannelProcessor.isContextValidConcerningHumanity(context)); } }