提交 b6d30a87 编写于 作者: M MaxKey

kaptcha

上级 e31a83b6
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();
}
}
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
\ No newline at end of file
kaptcha.word.impl=com.google.code.kaptcha.text.impl.RandomColorWordRenderer
kaptcha.textproducer.impl=com.google.code.kaptcha.impl.UniqueTextCreator
\ No newline at end of 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;
}
/**
......
......@@ -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() {
......
......@@ -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
......
......@@ -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;
......
......@@ -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));
}
......
......@@ -45,6 +45,7 @@ import org.springframework.http.MediaType;
*
*/
@Controller
@RequestMapping(value = "/login")
public class LoginEntryPoint {
private static Logger _logger = LoggerFactory.getLogger(LoginEntryPoint.class);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册