mirror of
https://github.com/librecaptcha/lc-core.git
synced 2025-01-13 06:53:19 -05:00
Add supportedParams method
Signed-off-by: Rahul Rudragoudar <rr83019@gmail.com>
This commit is contained in:
parent
a30a977572
commit
2c0f3deb8a
@ -6,6 +6,8 @@ import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import lc.captchas.interfaces.Challenge;
|
||||
import lc.captchas.interfaces.ChallengeProvider;
|
||||
import lc.misc.HelperFunctions;
|
||||
@ -16,6 +18,15 @@ public class FontFunCaptcha implements ChallengeProvider {
|
||||
return "FontFunCaptcha";
|
||||
}
|
||||
|
||||
public HashMap<String, List<String>> supportedParameters() {
|
||||
HashMap<String, List<String>> supportedParams = new HashMap<String, List<String>>();
|
||||
supportedParams.put("supportedLevels", List.of("medium"));
|
||||
supportedParams.put("supportedMedia", List.of("image/png"));
|
||||
supportedParams.put("supportedInputType", List.of("text"));
|
||||
|
||||
return supportedParams;
|
||||
}
|
||||
|
||||
public void configure(String config) {
|
||||
// TODO: Add custom config
|
||||
}
|
||||
|
@ -6,6 +6,9 @@ import java.awt.RenderingHints;
|
||||
import java.awt.Color;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import javax.imageio.stream.ImageOutputStream;
|
||||
import javax.imageio.stream.MemoryCacheImageOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -52,6 +55,15 @@ public class GifCaptcha implements ChallengeProvider {
|
||||
// TODO: Add custom config
|
||||
}
|
||||
|
||||
public HashMap<String, List<String>> supportedParameters() {
|
||||
HashMap<String, List<String>> supportedParams = new HashMap<String, List<String>>();
|
||||
supportedParams.put("supportedLevels", List.of("hard"));
|
||||
supportedParams.put("supportedMedia", List.of("image/gif"));
|
||||
supportedParams.put("supportedInputType", List.of("text"));
|
||||
|
||||
return supportedParams;
|
||||
}
|
||||
|
||||
public Challenge returnChallenge() {
|
||||
String secret = HelperFunctions.randomString(6);
|
||||
return new Challenge(gifCaptcha(secret), "image/gif", secret.toLowerCase());
|
||||
|
@ -10,6 +10,9 @@ import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ConvolveOp;
|
||||
import java.awt.image.Kernel;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import lc.misc.HelperFunctions;
|
||||
import lc.captchas.interfaces.Challenge;
|
||||
import lc.captchas.interfaces.ChallengeProvider;
|
||||
@ -24,6 +27,15 @@ public class ShadowTextCaptcha implements ChallengeProvider {
|
||||
// TODO: Add custom config
|
||||
}
|
||||
|
||||
public HashMap<String, List<String>> supportedParameters() {
|
||||
HashMap<String, List<String>> supportedParams = new HashMap<String, List<String>>();
|
||||
supportedParams.put("supportedLevels", List.of("easy"));
|
||||
supportedParams.put("supportedMedia", List.of("image/png"));
|
||||
supportedParams.put("supportedInputType", List.of("text"));
|
||||
|
||||
return supportedParams;
|
||||
}
|
||||
|
||||
public boolean checkAnswer(String secret, String answer) {
|
||||
return answer.toLowerCase().equals(secret);
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
package lc.captchas.interfaces;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
public interface ChallengeProvider {
|
||||
public String getId();
|
||||
|
||||
@ -8,4 +11,6 @@ public interface ChallengeProvider {
|
||||
public boolean checkAnswer(String secret, String answer);
|
||||
|
||||
public void configure(String config);
|
||||
|
||||
public Map<String, List<String>> supportedParameters();
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ import java.awt.Font
|
||||
import java.awt.Color
|
||||
import lc.captchas.interfaces.ChallengeProvider
|
||||
import lc.captchas.interfaces.Challenge
|
||||
import scala.jdk.CollectionConverters.MapHasAsJava
|
||||
import java.util.{List => JavaList, Map => JavaMap}
|
||||
|
||||
class FilterChallenge extends ChallengeProvider {
|
||||
def getId = "FilterChallenge"
|
||||
@ -15,6 +17,16 @@ class FilterChallenge extends ChallengeProvider {
|
||||
// TODO: add custom config
|
||||
}
|
||||
|
||||
def supportedParameters(): JavaMap[String, JavaList[String]] = {
|
||||
val supportedParams = Map(
|
||||
"supportedLevels" -> JavaList.of("medium", "hard"),
|
||||
"supportedMedia" -> JavaList.of("image/png"),
|
||||
"supportedInputType" -> JavaList.of("text")
|
||||
).asJava
|
||||
|
||||
supportedParams
|
||||
}
|
||||
|
||||
def returnChallenge(): Challenge = {
|
||||
val filterTypes = List(new FilterType1, new FilterType2)
|
||||
val r = new scala.util.Random
|
||||
|
@ -9,6 +9,8 @@ import java.awt.image.BufferedImage
|
||||
import java.awt.Color
|
||||
import lc.captchas.interfaces.ChallengeProvider
|
||||
import lc.captchas.interfaces.Challenge
|
||||
import scala.jdk.CollectionConverters.MapHasAsJava
|
||||
import java.util.{List => JavaList, Map => JavaMap}
|
||||
|
||||
class LabelCaptcha extends ChallengeProvider {
|
||||
private var knownFiles = new File("known").list.toList
|
||||
@ -27,6 +29,16 @@ class LabelCaptcha extends ChallengeProvider {
|
||||
// TODO: add custom config
|
||||
}
|
||||
|
||||
def supportedParameters(): JavaMap[String, JavaList[String]] = {
|
||||
val supportedParams = Map(
|
||||
"supportedLevels" -> JavaList.of("hard"),
|
||||
"supportedMedia" -> JavaList.of("image/png"),
|
||||
"supportedInputType" -> JavaList.of("text")
|
||||
).asJava
|
||||
|
||||
supportedParams
|
||||
}
|
||||
|
||||
def returnChallenge(): Challenge =
|
||||
synchronized {
|
||||
val r = scala.util.Random.nextInt(knownFiles.length)
|
||||
|
@ -10,6 +10,8 @@ import javax.imageio.stream.MemoryCacheImageOutputStream;
|
||||
import lc.captchas.interfaces.ChallengeProvider
|
||||
import lc.captchas.interfaces.Challenge
|
||||
import lc.misc.GifSequenceWriter
|
||||
import scala.jdk.CollectionConverters.MapHasAsJava
|
||||
import java.util.{List => JavaList, Map => JavaMap}
|
||||
|
||||
class Drop {
|
||||
var x = 0
|
||||
@ -35,6 +37,16 @@ class RainDropsCP extends ChallengeProvider {
|
||||
// TODO: add custom config
|
||||
}
|
||||
|
||||
def supportedParameters(): JavaMap[String, JavaList[String]] = {
|
||||
val supportedParams = Map(
|
||||
"supportedLevels" -> JavaList.of("medium", "easy"),
|
||||
"supportedMedia" -> JavaList.of("image/gif"),
|
||||
"supportedInputType" -> JavaList.of("text")
|
||||
).asJava
|
||||
|
||||
supportedParams
|
||||
}
|
||||
|
||||
private def extendDrops(drops: Array[Drop], steps: Int, xOffset: Int) = {
|
||||
drops.map(d => {
|
||||
val nd = new Drop()
|
||||
|
Loading…
Reference in New Issue
Block a user