kaptcha
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
||||
package com.google.code.kaptcha.impl;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.code.kaptcha.text.TextProducer;
|
||||
import com.google.code.kaptcha.util.Configurable;
|
||||
|
||||
public class UniqueTextCreator extends Configurable implements TextProducer{
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
int length = getConfig().getTextProducerCharLength();
|
||||
char[] chars = getConfig().getTextProducerCharString();
|
||||
Random rand = new Random();
|
||||
StringBuffer text = new StringBuffer();
|
||||
int i = 0;
|
||||
while ( i < length){
|
||||
char word= chars[rand.nextInt(chars.length)];
|
||||
if(text.indexOf(word + "") <= -1 ) {
|
||||
text.append(word);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
}
|
||||
+5
-4
@@ -1,13 +1,14 @@
|
||||
kaptcha.image.width=80
|
||||
kaptcha.image.width=120
|
||||
kaptcha.image.height=40
|
||||
kaptcha.border=no
|
||||
#kaptcha.obscurificator.impl=com.google.code.kaptcha.impl.ShadowGimpy
|
||||
kaptcha.obscurificator.impl=com.google.code.kaptcha.impl.Ripple
|
||||
kaptcha.textproducer.font.size=23
|
||||
kaptcha.textproducer.font.size=30
|
||||
kaptcha.textproducer.char.string=0123456789
|
||||
kaptcha.textproducer.char.length=4
|
||||
kaptcha.textproducer.char.space=3
|
||||
kaptcha.textproducer.char.space=6
|
||||
#kaptcha.noise.impl=com.google.code.kaptcha.impl.DefaultNoise
|
||||
kaptcha.noise.impl=com.google.code.kaptcha.impl.LightNoise
|
||||
#kaptcha.noise.color=white
|
||||
kaptcha.word.impl=com.google.code.kaptcha.text.impl.RandomColorWordRenderer
|
||||
kaptcha.word.impl=com.google.code.kaptcha.text.impl.RandomColorWordRenderer
|
||||
kaptcha.textproducer.impl=com.google.code.kaptcha.impl.UniqueTextCreator
|
||||
+4
-1
@@ -65,7 +65,10 @@ public class AuthJwtService {
|
||||
* @return AuthJwt
|
||||
*/
|
||||
public AuthJwt genAuthJwt(Authentication authentication) {
|
||||
return new AuthJwt(genJwt(authentication), authentication);
|
||||
if(authentication != null) {
|
||||
return new AuthJwt(genJwt(authentication), authentication);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user