SEC-368: Extra spelling corrections in captcha. Also general tidying up of comments and corrections of log messages

This commit is contained in:
Luke Taylor 2008-03-17 11:06:32 +00:00
parent 4586183f17
commit bd5172ffbc
13 changed files with 52 additions and 73 deletions

View File

@ -19,8 +19,11 @@
package org.springframework.security.captcha; package org.springframework.security.captcha;
/** /**
* <p>return false if ny CaptchaChannelProcessorTemplate of mapped urls has been requested more than thresold; <br> * Return false if the number of requests for captcha protcted URLs for the user
* Default keyword : REQUIRES_CAPTCHA_ABOVE_THRESOLD_REQUESTS</p> * exceeds the threshold value.
*
* <br/>
* Default keyword : <tt>REQUIRES_CAPTCHA_ABOVE_THRESHOLD_REQUESTS</tt>
* *
* @author Marc-Antoine Garrigue * @author Marc-Antoine Garrigue
* @version $Id$ * @version $Id$
@ -33,9 +36,6 @@ public class AlwaysTestAfterMaxRequestsCaptchaChannelProcessor extends CaptchaCh
//~ Constructors =================================================================================================== //~ Constructors ===================================================================================================
/**
* Constructor
*/
public AlwaysTestAfterMaxRequestsCaptchaChannelProcessor() { public AlwaysTestAfterMaxRequestsCaptchaChannelProcessor() {
this.setKeyword(DEFAULT_KEYWORD); this.setKeyword(DEFAULT_KEYWORD);
} }
@ -43,11 +43,8 @@ public class AlwaysTestAfterMaxRequestsCaptchaChannelProcessor extends CaptchaCh
//~ Methods ======================================================================================================== //~ Methods ========================================================================================================
/** /**
* Verify whether the context is valid concerning humanity
* *
* @param context * @return false if the number of requests for captcha protected URLs exceeds the threshold.
*
* @return true if valid, false otherwise
*/ */
boolean isContextValidConcerningHumanity(CaptchaSecurityContext context) { boolean isContextValidConcerningHumanity(CaptchaSecurityContext context) {
if (context.getHumanRestrictedResourcesRequestsCount() < getThreshold()) { if (context.getHumanRestrictedResourcesRequestsCount() < getThreshold()) {

View File

@ -16,8 +16,8 @@
package org.springframework.security.captcha; package org.springframework.security.captcha;
/** /**
* <p>return false if thresold is greater than millis since last captcha test has occured;<br> * Return false if the time in millis since the last captcha test is less than the threshold;<br/>
* Default keyword : REQUIRES_CAPTCHA_AFTER_THRESOLD_IN_MILLIS</p> * Default keyword : <tt>REQUIRES_CAPTCHA_AFTER_THRESHOLD_IN_MILLIS</tt>.
* *
* @author Marc-Antoine Garrigue * @author Marc-Antoine Garrigue
* @version $Id$ * @version $Id$
@ -30,9 +30,6 @@ public class AlwaysTestAfterTimeInMillisCaptchaChannelProcessor extends CaptchaC
//~ Constructors =================================================================================================== //~ Constructors ===================================================================================================
/**
* Constructor
*/
public AlwaysTestAfterTimeInMillisCaptchaChannelProcessor() { public AlwaysTestAfterTimeInMillisCaptchaChannelProcessor() {
this.setKeyword(DEFAULT_KEYWORD); this.setKeyword(DEFAULT_KEYWORD);
@ -41,19 +38,19 @@ public class AlwaysTestAfterTimeInMillisCaptchaChannelProcessor extends CaptchaC
//~ Methods ======================================================================================================== //~ Methods ========================================================================================================
/** /**
* Verify wheter the context is valid concerning humanity * Returns false if the time (in milliseconds) since the last captcha validation is greater than the
* threshold value.
* *
* @param context the CaptchaSecurityContext * @param context the CaptchaSecurityContext
* *
* @return true if valid, false otherwise
*/ */
boolean isContextValidConcerningHumanity(CaptchaSecurityContext context) { boolean isContextValidConcerningHumanity(CaptchaSecurityContext context) {
if ((System.currentTimeMillis() - context.getLastPassedCaptchaDateInMillis()) < getThreshold()) { if ((System.currentTimeMillis() - context.getLastPassedCaptchaDateInMillis()) < getThreshold()) {
logger.debug("context is valid : last passed captcha date - current time < thresold"); logger.debug("context is valid : current time - last passed captcha date < threshold");
return true; return true;
} else { } else {
logger.debug("context is not valid : last passed captcha date - current time > thresold"); logger.debug("context is not valid : current time - last passed captcha date > threshold");
return false; return false;
} }

View File

@ -19,10 +19,10 @@ import org.springframework.util.Assert;
/** /**
* <p>return false if thresold is lower than average time millis between any CaptchaChannelProcessorTemplate mapped * Return false if the average time in millis between any CaptchaChannelProcessorTemplate mapped
* urls requests and is human;<br> * urls requests is greater than the threshold value or the context is not human;<br />
* Default keyword : REQUIRES_CAPTCHA_BELOW_AVERAGE_TIME_IN_MILLIS_REQUESTS <br> * Default keyword : <tt>REQUIRES_CAPTCHA_BELOW_AVERAGE_TIME_IN_MILLIS_REQUESTS</tt> <br>
* Note : before first humanity check</p> * Note : before first humanity check
* *
* @author Marc-Antoine Garrigue * @author Marc-Antoine Garrigue
* @version $Id$ * @version $Id$
@ -35,9 +35,6 @@ public class AlwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessor e
//~ Constructors =================================================================================================== //~ Constructors ===================================================================================================
/**
* Constructor
*/
public AlwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessor() { public AlwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessor() {
this.setKeyword(DEFAULT_KEYWORD); this.setKeyword(DEFAULT_KEYWORD);
} }
@ -45,7 +42,7 @@ public class AlwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessor e
//~ Methods ======================================================================================================== //~ Methods ========================================================================================================
/** /**
* Verify if thresold is &gt; 0 * Verify that threshold is &gt; 0
* *
* @throws Exception if false * @throws Exception if false
*/ */
@ -55,11 +52,7 @@ public class AlwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessor e
} }
/** /**
* Verify wheter the context is valid concerning humanity
* *
* @param context
*
* @return true if valid, false otherwise
*/ */
boolean isContextValidConcerningHumanity(CaptchaSecurityContext context) { boolean isContextValidConcerningHumanity(CaptchaSecurityContext context) {
int req = context.getHumanRestrictedResourcesRequestsCount(); int req = context.getHumanRestrictedResourcesRequestsCount();
@ -74,11 +67,11 @@ public class AlwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessor e
} }
if (context.isHuman() && (average > thresold)) { if (context.isHuman() && (average > thresold)) {
logger.debug("context is valid : average time between requests < thresold && is human"); logger.debug("context is valid : average time between requests < threshold && is human");
return true; return true;
} else { } else {
logger.debug("context is not valid : request count > thresold or is not human"); logger.debug("context is not valid : average time between requests > threshold or is not human");
return false; return false;
} }

View File

@ -40,21 +40,21 @@ import javax.servlet.ServletException;
/** /**
* <p>CaptchaChannel template : Ensures the user has enough human privileges by review of the {@link * CaptchaChannel template : Ensures the user has enough human privileges by review of the {@link
* CaptchaSecurityContext} and using an abstract routine {@link * CaptchaSecurityContext} and using an abstract routine {@link
* #isContextValidConcerningHumanity(CaptchaSecurityContext)} (implemented by sub classes)</p> * #isContextValidConcerningHumanity(CaptchaSecurityContext)} (implemented by sub classes)
* <P>The component uses 2 main parameters for its configuration : * <p>The component uses 2 main parameters for its configuration :
* <ul> * <ul>
* <li>a keyword to be mapped to urls in the {@link * <li>a keyword to be mapped to urls in the {@link
* org.springframework.security.securechannel.ChannelProcessingFilter} configuration<br> * org.springframework.security.securechannel.ChannelProcessingFilter} configuration<br>
* default value provided by sub classes.</li> * default value provided by sub classes.</li>
* <li>and a thresold : used by the routine {@link * <li>and a threshold : used by the routine {@link
* #isContextValidConcerningHumanity(CaptchaSecurityContext)} to evaluate whether the {@link * #isContextValidConcerningHumanity(CaptchaSecurityContext)} to evaluate whether the {@link
* CaptchaSecurityContext} is valid default value = 0</li> * CaptchaSecurityContext} is valid default value = 0</li>
* </ul> * </ul>
* </p> * </p>
* *
* @author marc antoine Garrigue * @author Marc-Antoine Garrigue
* @version $Id$ * @version $Id$
*/ */
public abstract class CaptchaChannelProcessorTemplate implements ChannelProcessor, InitializingBean { public abstract class CaptchaChannelProcessorTemplate implements ChannelProcessor, InitializingBean {

View File

@ -47,7 +47,6 @@ import javax.servlet.http.HttpServletResponse;
* The captcha entry point : redirect to the captcha test page. * The captcha entry point : redirect to the captcha test page.
* <p> * <p>
* This entry point can force the use of SSL : see {@link #getForceHttps()} * This entry point can force the use of SSL : see {@link #getForceHttps()}
* </p>
* <p> * <p>
* This entry point allows internal OR external redirect : see {@link #setOutsideWebApp(boolean)}<br /> * This entry point allows internal OR external redirect : see {@link #setOutsideWebApp(boolean)}<br />
* / Original request can be added to the redirect path using a custom translation : see * / Original request can be added to the redirect path using a custom translation : see
@ -82,7 +81,7 @@ import javax.servlet.http.HttpServletResponse;
* </pre> * </pre>
* </p> * </p>
* *
* @author marc antoine Garrigue * @author Marc-Antoine Garrigue
* @version $Id$ * @version $Id$
*/ */
public class CaptchaEntryPoint implements ChannelEntryPoint, InitializingBean { public class CaptchaEntryPoint implements ChannelEntryPoint, InitializingBean {
@ -326,10 +325,8 @@ public class CaptchaEntryPoint implements ChannelEntryPoint, InitializingBean {
this.captchaFormUrl = captchaFormUrl; this.captchaFormUrl = captchaFormUrl;
} }
// ~ Methods
// ================================================================
/** /**
* Set to true to force captcha form access to be via https. If this value is ture (the default is false), * Set to true to force captcha form access to be via https. If this value is true (the default is false),
* and the incoming request for the protected resource which triggered the interceptor was not already * and the incoming request for the protected resource which triggered the interceptor was not already
* <code>https</code>, then * <code>https</code>, then
* *

View File

@ -19,41 +19,39 @@ import org.springframework.security.context.SecurityContext;
/** /**
* Interface that add humanity concerns to the SecurityContext * Interface that adds humanity concerns to the SecurityContext
* *
* @author marc antoine garrigue * @author Marc-Antoine Garrigue
* @version $Id$
*/ */
public interface CaptchaSecurityContext extends SecurityContext { public interface CaptchaSecurityContext extends SecurityContext {
//~ Methods ======================================================================================================== //~ Methods ========================================================================================================
/** /**
* DOCUMENT ME!
* *
* @return number of human restricted resources requests since the last passed captcha. * @return the number of human restricted resources requested since the last passed captcha.
*/ */
int getHumanRestrictedResourcesRequestsCount(); int getHumanRestrictedResourcesRequestsCount();
/** /**
* DOCUMENT ME!
* *
* @return the date of the last passed Captcha in millis, 0 if the user never passed captcha. * @return the date of the last passed Captcha in millis, 0 if the user never passed captcha.
*/ */
long getLastPassedCaptchaDateInMillis(); long getLastPassedCaptchaDateInMillis();
/** /**
* Method to increment the human Restricted Resrouces Requests Count; * Increments the human Restricted Resources Requests Count.
*/ */
void incrementHumanRestrictedResourcesRequestsCount(); void incrementHumanRestrictedResourcesRequestsCount();
/** /**
* DOCUMENT ME!
* *
* @return true if the current user has already passed a captcha. * @return true if the current user has already passed a captcha.
*/ */
boolean isHuman(); boolean isHuman();
/** /**
* set human attribute, should called after captcha validation. * set human attribute, should be called after captcha validation.
*/ */
void setHuman(); void setHuman();
} }

View File

@ -21,7 +21,8 @@ import org.springframework.security.context.SecurityContextImpl;
/** /**
* Default CaptchaSecurityContext implementation * Default CaptchaSecurityContext implementation
* *
* @author mag * @author Marc-Antoine Garrigue
* @version $Id$
*/ */
public class CaptchaSecurityContextImpl extends SecurityContextImpl implements CaptchaSecurityContext { public class CaptchaSecurityContextImpl extends SecurityContextImpl implements CaptchaSecurityContext {
//~ Instance fields ================================================================================================ //~ Instance fields ================================================================================================
@ -33,7 +34,6 @@ public class CaptchaSecurityContextImpl extends SecurityContextImpl implements C
//~ Constructors =================================================================================================== //~ Constructors ===================================================================================================
public CaptchaSecurityContextImpl() { public CaptchaSecurityContextImpl() {
super();
human = false; human = false;
lastPassedCaptchaDate = 0; lastPassedCaptchaDate = 0;
humanRestrictedResourcesRequestsCount = 0; humanRestrictedResourcesRequestsCount = 0;
@ -84,7 +84,7 @@ public class CaptchaSecurityContextImpl extends SecurityContextImpl implements C
} }
/** /**
* Method to increment the human Restricted Resrouces Requests Count; * Method to increment the human Restricted Resources Requests Count;
*/ */
public void incrementHumanRestrictedResourcesRequestsCount() { public void incrementHumanRestrictedResourcesRequestsCount() {
humanRestrictedResourcesRequestsCount++; humanRestrictedResourcesRequestsCount++;

View File

@ -18,14 +18,13 @@ package org.springframework.security.captcha;
/** /**
* Provide a common interface for captcha validation. * Provide a common interface for captcha validation.
* *
* @author marc antoine Garrigue * @author Marc-Antoine Garrigue
* @version $Id$ * @version $Id$
*/ */
public interface CaptchaServiceProxy { public interface CaptchaServiceProxy {
//~ Methods ======================================================================================================== //~ Methods ========================================================================================================
/** /**
* DOCUMENT ME!
* *
* @param id the id token * @param id the id token
* @param captchaResponse the user response * @param captchaResponse the user response

View File

@ -30,12 +30,15 @@ import javax.servlet.http.HttpSession;
/** /**
* Filter for web integration of the {@link CaptchaServiceProxy}. <br> * Filter for web integration of the {@link CaptchaServiceProxy}.
* It basically intercept calls containing the specific validation parameter, use the {@link CaptchaServiceProxy} to * <p>
* validate the request, and update the {@link CaptchaSecurityContext} if the request passed the validation. <br> * It basically intercept calls containing the specific validation parameter, uses the {@link CaptchaServiceProxy} to
* validate the request, and update the {@link CaptchaSecurityContext} if the request passed the validation.
* <p>
* This Filter should be placed after the ContextIntegration filter and before the {@link * This Filter should be placed after the ContextIntegration filter and before the {@link
* CaptchaChannelProcessorTemplate} filter in the filter stack in order to update the {@link CaptchaSecurityContext} * CaptchaChannelProcessorTemplate} filter in the filter stack in order to update the {@link CaptchaSecurityContext}
* before the humanity verification routine occurs. <br> * before the humanity verification routine occurs.
* <p>
* This filter should only be used in conjunction with the {@link CaptchaSecurityContext}<br> * This filter should only be used in conjunction with the {@link CaptchaSecurityContext}<br>
* *
* @author marc antoine Garrigue * @author marc antoine Garrigue

View File

@ -16,9 +16,9 @@
package org.springframework.security.captcha; package org.springframework.security.captcha;
/** /**
* <p>return false if ny CaptchaChannelProcessorTemplate mapped urls has been requested more than thresold and * Return false if any CaptchaChannelProcessorTemplate mapped urls have been requested more than threshold and
* humanity is false; <br> * humanity is false; <br>
* Default keyword : REQUIRES_CAPTCHA_ONCE_ABOVE_THRESOLD_REQUESTS</p> * Default keyword : REQUIRES_CAPTCHA_ONCE_ABOVE_THRESHOLD_REQUESTS</p>
* *
* @author Marc-Antoine Garrigue * @author Marc-Antoine Garrigue
* @version $Id$ * @version $Id$
@ -26,7 +26,7 @@ package org.springframework.security.captcha;
public class TestOnceAfterMaxRequestsCaptchaChannelProcessor extends CaptchaChannelProcessorTemplate { public class TestOnceAfterMaxRequestsCaptchaChannelProcessor extends CaptchaChannelProcessorTemplate {
//~ Static fields/initializers ===================================================================================== //~ Static fields/initializers =====================================================================================
public static final String DEFAULT_KEYWORD = "REQUIRES_CAPTCHA_ONCE_ABOVE_THRESOLD_REQUESTS"; public static final String DEFAULT_KEYWORD = "REQUIRES_CAPTCHA_ONCE_ABOVE_THRESHOLD_REQUESTS";
//~ Constructors =================================================================================================== //~ Constructors ===================================================================================================
@ -38,11 +38,11 @@ public class TestOnceAfterMaxRequestsCaptchaChannelProcessor extends CaptchaChan
boolean isContextValidConcerningHumanity(CaptchaSecurityContext context) { boolean isContextValidConcerningHumanity(CaptchaSecurityContext context) {
if (context.isHuman() || (context.getHumanRestrictedResourcesRequestsCount() < getThreshold())) { if (context.isHuman() || (context.getHumanRestrictedResourcesRequestsCount() < getThreshold())) {
logger.debug("context is valid concerning humanity or request count < thresold"); logger.debug("context is valid concerning humanity or request count < threshold");
return true; return true;
} else { } else {
logger.debug("context is not valid concerning humanity and request count > thresold"); logger.debug("context is not valid concerning humanity and request count > threshold");
return false; return false;
} }

View File

@ -19,9 +19,7 @@ import junit.framework.TestCase;
/** /**
* * @author Marc-Antoine Garrigue
* @author $author$
* @version $Revision: 2142 $
*/ */
public class AlwaysTestAfterMaxRequestsCaptchaChannelProcessorTests extends TestCase { public class AlwaysTestAfterMaxRequestsCaptchaChannelProcessorTests extends TestCase {
//~ Instance fields ================================================================================================ //~ Instance fields ================================================================================================

View File

@ -16,9 +16,7 @@
package org.springframework.security.captcha; package org.springframework.security.captcha;
/** /**
* DOCUMENT ME! * @author Marc-Antoine Garrigue
*
* @author marc antoine Garrigue
* @version $Id$ * @version $Id$
*/ */
public class MockCaptchaServiceProxy implements CaptchaServiceProxy { public class MockCaptchaServiceProxy implements CaptchaServiceProxy {

View File

@ -21,9 +21,8 @@ import org.springframework.security.captcha.TestOnceAfterMaxRequestsCaptchaChann
/** /**
* DOCUMENT ME!
* *
* @author $author$ * @author Marc-Antoine Garrigue
* @version $Revision: 2142 $ * @version $Revision: 2142 $
*/ */
public class TestOnceAfterMaxRequestsCaptchaChannelProcessorTests extends TestCase { public class TestOnceAfterMaxRequestsCaptchaChannelProcessorTests extends TestCase {