This commit is contained in:
MaxKey 2022-04-22 22:00:39 +08:00
parent e31a83b679
commit b6d30a8730
8 changed files with 70 additions and 11 deletions

View File

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

View File

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

View File

@ -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;
}
/**

View File

@ -141,6 +141,9 @@ public class Apps extends JpaBaseEntity implements Serializable {
@Column
private String adapter;
@Column
private String frequently;
@Column
protected int sortIndex;
@Column
@ -157,7 +160,7 @@ public class Apps extends JpaBaseEntity implements Serializable {
protected String description;
@Column
private String instId;
private String instName;
protected String loginDateTime;
@ -248,7 +251,16 @@ public class Apps extends JpaBaseEntity implements Serializable {
this.secret = secret;
}
/**
public String getFrequently() {
return frequently;
}
public void setFrequently(String frequently) {
this.frequently = frequently;
}
/**
* @return the icon
*/
public byte[] getIcon() {

View File

@ -106,6 +106,7 @@ public class AppsOAuth20Details extends Apps {
this.setAdapter(application.getAdapter());
this.setAdapterId(application.getAdapterId());
this.setAdapterName(application.getAdapterName());
this.setFrequently(application.getFrequently());
this.clientSecret = baseClientDetails.getClientSecret();
this.scope = StringUtils

View File

@ -37,6 +37,8 @@ public class InstitutionsRepository {
private static final String SELECT_STATEMENT =
"select * from mxk_institutions where id = ? or domain = ? " ;
private static final String DEFAULT_INSTID = "1";
protected static final Cache<String, Institutions> institutionsStore =
Caffeine.newBuilder()
@ -54,7 +56,17 @@ public class InstitutionsRepository {
public Institutions get(String 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) {
List<Institutions> institutions =
jdbcTemplate.query(SELECT_STATEMENT,new InstitutionsRowMapper(),instIdOrDomain,instIdOrDomain);
@ -62,8 +74,10 @@ public class InstitutionsRepository {
if (institutions != null && institutions.size() > 0) {
inst = institutions.get(0);
}
institutionsStore.put(inst.getDomain(), inst);
mapper.put(inst.getId(), inst.getDomain());
if(inst != null ) {
institutionsStore.put(inst.getDomain(), inst);
mapper.put(inst.getId(), inst.getDomain());
}
}
return inst;

View File

@ -155,7 +155,7 @@ public class LoginEntryPoint {
String authType = loginCredential.getAuthType();
_logger.debug("Login AuthN Type " + authType);
if (StringUtils.isNotBlank(authType)){
Authentication authentication = authenticationProvider.doAuthenticate(loginCredential);
Authentication authentication = authenticationProvider.authenticate(loginCredential);
if(authentication != null) {
authJwtMessage = new Message<AuthJwt>(authJwtService.genAuthJwt(authentication));
}

View File

@ -45,6 +45,7 @@ import org.springframework.http.MediaType;
*
*/
@Controller
@RequestMapping(value = "/login")
public class LoginEntryPoint {
private static Logger _logger = LoggerFactory.getLogger(LoginEntryPoint.class);