Skip to content

Commit

Permalink
Atualiza projetos captcha
Browse files Browse the repository at this point in the history
Signed-off-by: Manoel Campos <[email protected]>
  • Loading branch information
manoelcampos committed Feb 10, 2025
1 parent 25c27f3 commit 24bcb90
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion estruturais/01-adapter/captcha-adapters-v1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<!-- https://github.com/logicsquad/nanocaptcha -->
<groupId>net.logicsquad</groupId>
<artifactId>nanocaptcha</artifactId>
<version>1.5</version>
<version>2.1</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package io.github.manoelcampos.captchaadapters.adapter;

import com.mewebstudio.captcha.Captcha;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.SessionScope;

/**
* @author Manoel Campos
* @see <a href="https://github.com/mewebstudio/java-captcha-generator">Captcha Generator</a>
*/
@SessionScope
@Component
public class CaptchaGeneratorAdapter extends AbstractCaptchaAdapter {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package io.github.manoelcampos.captchaadapters.adapter;

import net.logicsquad.nanocaptcha.image.ImageCaptcha;
import org.springframework.web.context.annotation.SessionScope;
import org.springframework.stereotype.Component;

/**
* @author Manoel Campos
* @see <a href="https://github.com/logicsquad/nanocaptcha">Nano Captcha</a>
*/
@SessionScope
@Component
public class NanoCaptchaAdapter extends AbstractCaptchaAdapter {

@Override
public byte[] gerar() {
final var captcha = new ImageCaptcha.Builder(200, 50).addContent().build();
final var captcha = ImageCaptcha.create();
this.codigo = captcha.getContent();
return bufferedImageToByteArray(captcha.getImage());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package io.github.manoelcampos.captchaadapters.controllers;

import io.github.manoelcampos.captchaadapters.adapter.CaptchaAdapter;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.annotation.SessionScope;

/**
Expand All @@ -12,9 +15,9 @@
@RestController
@RequestMapping("/captcha")
@SessionScope
@AllArgsConstructor
public class CaptchaController {
private final CaptchaAdapter captcha;
@Autowired
private CaptchaAdapter captcha;

@GetMapping(value = "/gerar", produces = MediaType.IMAGE_PNG_VALUE)
public byte[] gerar(){
Expand Down
2 changes: 1 addition & 1 deletion estruturais/01-adapter/captcha-v1-sem-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<!-- https://github.com/logicsquad/nanocaptcha -->
<groupId>net.logicsquad</groupId>
<artifactId>nanocaptcha</artifactId>
<version>1.5</version>
<version>2.1</version>
</dependency>

<dependency>
Expand Down

0 comments on commit 24bcb90

Please sign in to comment.