Add supportedParams method

Signed-off-by: Rahul Rudragoudar <rr83019@gmail.com>
This commit is contained in:
Rahul Rudragoudar
2021-03-11 21:23:24 +05:30
parent a30a977572
commit 2c0f3deb8a
7 changed files with 76 additions and 0 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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()