From c00680f63173fbbe6bd6bb7dc491e03f35159925 Mon Sep 17 00:00:00 2001 From: Rahul Rudragoudar Date: Tue, 2 Mar 2021 21:32:45 +0530 Subject: [PATCH] Add config method Signed-off-by: Rahul Rudragoudar --- src/main/java/lc/captchas/FontFunCaptcha.java | 4 ++++ src/main/java/lc/captchas/GifCaptcha.java | 4 ++++ src/main/java/lc/captchas/ShadowTextCaptcha.java | 4 ++++ src/main/java/lc/captchas/interfaces/ChallengeProvider.java | 2 +- src/main/scala/lc/captchas/FilterChallenge.scala | 5 +++++ src/main/scala/lc/captchas/LabelCaptcha.scala | 4 ++++ src/main/scala/lc/captchas/RainDropsCaptcha.scala | 4 ++++ 7 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main/java/lc/captchas/FontFunCaptcha.java b/src/main/java/lc/captchas/FontFunCaptcha.java index a69998b..e4379fc 100644 --- a/src/main/java/lc/captchas/FontFunCaptcha.java +++ b/src/main/java/lc/captchas/FontFunCaptcha.java @@ -16,6 +16,10 @@ public class FontFunCaptcha implements ChallengeProvider { return "FontFunCaptcha"; } + public void configure(String config) { + // TODO: Add custom config + } + private String getFontName(String path, String level) { File file = new File(path + level + "/"); FilenameFilter txtFileFilter = diff --git a/src/main/java/lc/captchas/GifCaptcha.java b/src/main/java/lc/captchas/GifCaptcha.java index 92a87ec..9352167 100644 --- a/src/main/java/lc/captchas/GifCaptcha.java +++ b/src/main/java/lc/captchas/GifCaptcha.java @@ -48,6 +48,10 @@ public class GifCaptcha implements ChallengeProvider { return null; } + public void configure(String config) { + // TODO: Add custom config + } + public Challenge returnChallenge() { String secret = HelperFunctions.randomString(6); return new Challenge(gifCaptcha(secret), "image/gif", secret.toLowerCase()); diff --git a/src/main/java/lc/captchas/ShadowTextCaptcha.java b/src/main/java/lc/captchas/ShadowTextCaptcha.java index 0128e97..3462df2 100644 --- a/src/main/java/lc/captchas/ShadowTextCaptcha.java +++ b/src/main/java/lc/captchas/ShadowTextCaptcha.java @@ -20,6 +20,10 @@ public class ShadowTextCaptcha implements ChallengeProvider { return "ShadowTextCaptcha"; } + public void configure(String config) { + // TODO: Add custom config + } + public boolean checkAnswer(String secret, String answer) { return answer.toLowerCase().equals(secret); } diff --git a/src/main/java/lc/captchas/interfaces/ChallengeProvider.java b/src/main/java/lc/captchas/interfaces/ChallengeProvider.java index ef8e7d0..09ad8c0 100644 --- a/src/main/java/lc/captchas/interfaces/ChallengeProvider.java +++ b/src/main/java/lc/captchas/interfaces/ChallengeProvider.java @@ -7,5 +7,5 @@ public interface ChallengeProvider { public boolean checkAnswer(String secret, String answer); - // TODO: def configure(): Unit + public void configure(String config); } diff --git a/src/main/scala/lc/captchas/FilterChallenge.scala b/src/main/scala/lc/captchas/FilterChallenge.scala index 0a1ef61..80c8d6f 100644 --- a/src/main/scala/lc/captchas/FilterChallenge.scala +++ b/src/main/scala/lc/captchas/FilterChallenge.scala @@ -10,6 +10,11 @@ import lc.captchas.interfaces.Challenge class FilterChallenge extends ChallengeProvider { def getId = "FilterChallenge" + + def configure(config: String): Unit = { + // TODO: add custom config + } + def returnChallenge(): Challenge = { val filterTypes = List(new FilterType1, new FilterType2) val r = new scala.util.Random diff --git a/src/main/scala/lc/captchas/LabelCaptcha.scala b/src/main/scala/lc/captchas/LabelCaptcha.scala index afbc5e0..9b86568 100644 --- a/src/main/scala/lc/captchas/LabelCaptcha.scala +++ b/src/main/scala/lc/captchas/LabelCaptcha.scala @@ -23,6 +23,10 @@ class LabelCaptcha extends ChallengeProvider { def getId = "LabelCaptcha" + def configure(config: String): Unit = { + // TODO: add custom config + } + def returnChallenge(): Challenge = synchronized { val r = scala.util.Random.nextInt(knownFiles.length) diff --git a/src/main/scala/lc/captchas/RainDropsCaptcha.scala b/src/main/scala/lc/captchas/RainDropsCaptcha.scala index da12829..214a525 100644 --- a/src/main/scala/lc/captchas/RainDropsCaptcha.scala +++ b/src/main/scala/lc/captchas/RainDropsCaptcha.scala @@ -31,6 +31,10 @@ class RainDropsCP extends ChallengeProvider { def getId = "FilterChallenge" + def configure(config: String): Unit = { + // TODO: add custom config + } + private def extendDrops(drops: Array[Drop], steps: Int, xOffset: Int) = { drops.map(d => { val nd = new Drop()