Skip to content
This repository was archived by the owner on May 10, 2022. It is now read-only.

Commit 03a179a

Browse files
committed
✄ upgrade
1 parent 6b17318 commit 03a179a

File tree

3 files changed

+35
-20
lines changed

3 files changed

+35
-20
lines changed

pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@
1111
</parent>
1212

1313
<artifactId>blade-patchca</artifactId>
14-
<version>1.0.4</version>
14+
<version>1.0.5</version>
1515
<name>blade-patchca</name>
1616
<url>https://github.com/bladejava/blade-patchca</url>
1717

1818
<dependencies>
1919
<dependency>
2020
<groupId>com.bladejava</groupId>
2121
<artifactId>blade-core</artifactId>
22-
<version>1.6.6</version>
22+
<version>1.7.0-alpha</version>
23+
<scope>provided</scope>
2324
</dependency>
2425
<dependency>
2526
<groupId>javax.servlet</groupId>

src/main/java/com/blade/patchca/DefaultPatchca.java

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
package com.blade.patchca;
22

3-
import java.awt.Color;
4-
import java.io.File;
5-
import java.io.FileNotFoundException;
6-
import java.io.FileOutputStream;
7-
import java.io.IOException;
8-
import java.io.OutputStream;
9-
import java.util.Random;
10-
113
import com.blade.kit.StringKit;
12-
import com.blade.kit.json.ParseException;
134
import com.blade.mvc.http.Request;
145
import com.blade.mvc.http.Response;
156
import com.blade.mvc.http.wrapper.Session;
@@ -23,6 +14,10 @@
2314
import org.slf4j.Logger;
2415
import org.slf4j.LoggerFactory;
2516

17+
import java.awt.*;
18+
import java.io.*;
19+
import java.util.Random;
20+
2621
/**
2722
* DefaultPatchca
2823
*/
@@ -36,9 +31,7 @@ public class DefaultPatchca implements Patchca {
3631
private RandomWordFactory wf;
3732

3833
public DefaultPatchca() {
39-
cs = new ConfigurableCaptchaService();
40-
// cs.setColorFactory(new SingleColorFactory(new Color(25, 60, 170)));
41-
cs.setColorFactory(new ColorFactory() {
34+
this(new ColorFactory() {
4235
@Override
4336
public Color getColor(int x) {
4437
int[] c = new int[3];
@@ -53,6 +46,11 @@ public Color getColor(int x) {
5346
return new Color(c[0], c[1], c[2]);
5447
}
5548
});
49+
}
50+
51+
public DefaultPatchca(ColorFactory colorFactory) {
52+
cs = new ConfigurableCaptchaService();
53+
cs.setColorFactory(colorFactory);
5654
wf = new RandomWordFactory();
5755
wf.setCharacters("23456789abcdefghigkmnpqrstuvwxyzABCDEFGHIGKLMNPQRSTUVWXYZ");
5856
wf.setMinLength(4);
@@ -61,37 +59,37 @@ public Color getColor(int x) {
6159
cs.setFilterFactory(new DiffuseRippleFilterFactory());
6260
}
6361

64-
public DefaultPatchca length(int lenth){
62+
public Patchca length(int lenth){
6563
wf.setMaxLength(lenth);
6664
wf.setMinLength(lenth);
6765
cs.setWordFactory(wf);
6866
return this;
6967
}
7068

71-
public DefaultPatchca length(int min, int max){
69+
public Patchca length(int min, int max){
7270
wf.setMinLength(min);
7371
wf.setMaxLength(max);
7472
cs.setWordFactory(wf);
7573
return this;
7674
}
7775

78-
public DefaultPatchca size(int width, int height){
76+
public Patchca size(int width, int height){
7977
cs.setWidth(width);
8078
cs.setHeight(height);
8179
return this;
8280
}
8381

84-
public DefaultPatchca color(ColorFactory colorFactory){
82+
public Patchca color(ColorFactory colorFactory){
8583
cs.setColorFactory(colorFactory);
8684
return this;
8785
}
8886

89-
public DefaultPatchca word(WordFactory wordFactory){
87+
public Patchca word(WordFactory wordFactory){
9088
cs.setWordFactory(wordFactory);
9189
return this;
9290
}
9391

94-
public DefaultPatchca filter(FilterFactory filterFactory){
92+
public Patchca filter(FilterFactory filterFactory){
9593
cs.setFilterFactory(filterFactory);
9694
return this;
9795
}

src/main/java/com/blade/patchca/Patchca.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import com.blade.mvc.http.Request;
44
import com.blade.mvc.http.Response;
5+
import org.patchca.color.ColorFactory;
6+
import org.patchca.filter.FilterFactory;
7+
import org.patchca.word.WordFactory;
58

69
import java.io.File;
710

@@ -20,4 +23,17 @@ public interface Patchca {
2023
String token(Response response) throws PatchcaException;
2124

2225
File create(String imgPath, String imgType) throws PatchcaException;
26+
27+
Patchca length(int lenth);
28+
29+
Patchca length(int min, int max);
30+
31+
Patchca size(int width, int height);
32+
33+
Patchca color(ColorFactory colorFactory);
34+
35+
Patchca word(WordFactory wordFactory);
36+
37+
Patchca filter(FilterFactory filterFactory);
38+
2339
}

0 commit comments

Comments
 (0)