mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-08 18:08:35 +08:00
kaptcha
This commit is contained in:
parent
e31a83b679
commit
b6d30a8730
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,13 +1,14 @@
|
|||||||
kaptcha.image.width=80
|
kaptcha.image.width=120
|
||||||
kaptcha.image.height=40
|
kaptcha.image.height=40
|
||||||
kaptcha.border=no
|
kaptcha.border=no
|
||||||
#kaptcha.obscurificator.impl=com.google.code.kaptcha.impl.ShadowGimpy
|
#kaptcha.obscurificator.impl=com.google.code.kaptcha.impl.ShadowGimpy
|
||||||
kaptcha.obscurificator.impl=com.google.code.kaptcha.impl.Ripple
|
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.string=0123456789
|
||||||
kaptcha.textproducer.char.length=4
|
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.DefaultNoise
|
||||||
kaptcha.noise.impl=com.google.code.kaptcha.impl.LightNoise
|
kaptcha.noise.impl=com.google.code.kaptcha.impl.LightNoise
|
||||||
#kaptcha.noise.color=white
|
#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
|
||||||
@ -65,7 +65,10 @@ public class AuthJwtService {
|
|||||||
* @return AuthJwt
|
* @return AuthJwt
|
||||||
*/
|
*/
|
||||||
public AuthJwt genAuthJwt(Authentication authentication) {
|
public AuthJwt genAuthJwt(Authentication authentication) {
|
||||||
return new AuthJwt(genJwt(authentication), authentication);
|
if(authentication != null) {
|
||||||
|
return new AuthJwt(genJwt(authentication), authentication);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -141,6 +141,9 @@ public class Apps extends JpaBaseEntity implements Serializable {
|
|||||||
@Column
|
@Column
|
||||||
private String adapter;
|
private String adapter;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
private String frequently;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
protected int sortIndex;
|
protected int sortIndex;
|
||||||
@Column
|
@Column
|
||||||
@ -248,7 +251,16 @@ public class Apps extends JpaBaseEntity implements Serializable {
|
|||||||
this.secret = secret;
|
this.secret = secret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
|
public String getFrequently() {
|
||||||
|
return frequently;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFrequently(String frequently) {
|
||||||
|
this.frequently = frequently;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* @return the icon
|
* @return the icon
|
||||||
*/
|
*/
|
||||||
public byte[] getIcon() {
|
public byte[] getIcon() {
|
||||||
|
|||||||
@ -106,6 +106,7 @@ public class AppsOAuth20Details extends Apps {
|
|||||||
this.setAdapter(application.getAdapter());
|
this.setAdapter(application.getAdapter());
|
||||||
this.setAdapterId(application.getAdapterId());
|
this.setAdapterId(application.getAdapterId());
|
||||||
this.setAdapterName(application.getAdapterName());
|
this.setAdapterName(application.getAdapterName());
|
||||||
|
this.setFrequently(application.getFrequently());
|
||||||
|
|
||||||
this.clientSecret = baseClientDetails.getClientSecret();
|
this.clientSecret = baseClientDetails.getClientSecret();
|
||||||
this.scope = StringUtils
|
this.scope = StringUtils
|
||||||
|
|||||||
@ -38,6 +38,8 @@ public class InstitutionsRepository {
|
|||||||
private static final String SELECT_STATEMENT =
|
private static final String SELECT_STATEMENT =
|
||||||
"select * from mxk_institutions where id = ? or domain = ? " ;
|
"select * from mxk_institutions where id = ? or domain = ? " ;
|
||||||
|
|
||||||
|
private static final String DEFAULT_INSTID = "1";
|
||||||
|
|
||||||
protected static final Cache<String, Institutions> institutionsStore =
|
protected static final Cache<String, Institutions> institutionsStore =
|
||||||
Caffeine.newBuilder()
|
Caffeine.newBuilder()
|
||||||
.expireAfterWrite(60, TimeUnit.MINUTES)
|
.expireAfterWrite(60, TimeUnit.MINUTES)
|
||||||
@ -54,7 +56,17 @@ public class InstitutionsRepository {
|
|||||||
|
|
||||||
public Institutions get(String instIdOrDomain) {
|
public Institutions get(String instIdOrDomain) {
|
||||||
_logger.trace(" instId {}" , instIdOrDomain);
|
_logger.trace(" instId {}" , instIdOrDomain);
|
||||||
Institutions inst = institutionsStore.getIfPresent(mapper.get(instIdOrDomain)==null ? "1" : mapper.get(instIdOrDomain) );
|
Institutions inst = getByInstIdOrDomain(instIdOrDomain);
|
||||||
|
if(inst == null) {//use default inst
|
||||||
|
inst = getByInstIdOrDomain(DEFAULT_INSTID);
|
||||||
|
institutionsStore.put(instIdOrDomain, inst);
|
||||||
|
}
|
||||||
|
return inst;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Institutions getByInstIdOrDomain(String instIdOrDomain) {
|
||||||
|
_logger.trace(" instId {}" , instIdOrDomain);
|
||||||
|
Institutions inst = institutionsStore.getIfPresent(mapper.get(instIdOrDomain)==null ? DEFAULT_INSTID : mapper.get(instIdOrDomain) );
|
||||||
if(inst == null) {
|
if(inst == null) {
|
||||||
List<Institutions> institutions =
|
List<Institutions> institutions =
|
||||||
jdbcTemplate.query(SELECT_STATEMENT,new InstitutionsRowMapper(),instIdOrDomain,instIdOrDomain);
|
jdbcTemplate.query(SELECT_STATEMENT,new InstitutionsRowMapper(),instIdOrDomain,instIdOrDomain);
|
||||||
@ -62,8 +74,10 @@ public class InstitutionsRepository {
|
|||||||
if (institutions != null && institutions.size() > 0) {
|
if (institutions != null && institutions.size() > 0) {
|
||||||
inst = institutions.get(0);
|
inst = institutions.get(0);
|
||||||
}
|
}
|
||||||
institutionsStore.put(inst.getDomain(), inst);
|
if(inst != null ) {
|
||||||
mapper.put(inst.getId(), inst.getDomain());
|
institutionsStore.put(inst.getDomain(), inst);
|
||||||
|
mapper.put(inst.getId(), inst.getDomain());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return inst;
|
return inst;
|
||||||
|
|||||||
@ -155,7 +155,7 @@ public class LoginEntryPoint {
|
|||||||
String authType = loginCredential.getAuthType();
|
String authType = loginCredential.getAuthType();
|
||||||
_logger.debug("Login AuthN Type " + authType);
|
_logger.debug("Login AuthN Type " + authType);
|
||||||
if (StringUtils.isNotBlank(authType)){
|
if (StringUtils.isNotBlank(authType)){
|
||||||
Authentication authentication = authenticationProvider.doAuthenticate(loginCredential);
|
Authentication authentication = authenticationProvider.authenticate(loginCredential);
|
||||||
if(authentication != null) {
|
if(authentication != null) {
|
||||||
authJwtMessage = new Message<AuthJwt>(authJwtService.genAuthJwt(authentication));
|
authJwtMessage = new Message<AuthJwt>(authJwtService.genAuthJwt(authentication));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,6 +45,7 @@ import org.springframework.http.MediaType;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
|
@RequestMapping(value = "/login")
|
||||||
public class LoginEntryPoint {
|
public class LoginEntryPoint {
|
||||||
private static Logger _logger = LoggerFactory.getLogger(LoginEntryPoint.class);
|
private static Logger _logger = LoggerFactory.getLogger(LoginEntryPoint.class);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user