v1.2.1 GA

This commit is contained in:
shimingxy 2020-03-25 01:14:02 +08:00
parent 4163acf289
commit 7e1fb358da
3 changed files with 23 additions and 11 deletions

View File

@ -251,7 +251,6 @@ subprojects {
compile group: 'com.alibaba', name: 'druid', version: '1.1.21' compile group: 'com.alibaba', name: 'druid', version: '1.1.21'
compile group: 'redis.clients', name: 'jedis', version: '3.2.0' compile group: 'redis.clients', name: 'jedis', version: '3.2.0'
compile group: 'org.ehcache', name: 'ehcache', version: '3.8.1' compile group: 'org.ehcache', name: 'ehcache', version: '3.8.1'
compile group: 'javax.cache', name: 'cache-api', version: '1.1.0'
//mybatis //mybatis
compile group: 'org.mybatis', name: 'mybatis', version: '3.5.4' compile group: 'org.mybatis', name: 'mybatis', version: '3.5.4'
compile group: 'org.mybatis', name: 'mybatis-spring', version: '2.0.4' compile group: 'org.mybatis', name: 'mybatis-spring', version: '2.0.4'

View File

@ -1,22 +1,30 @@
package org.maxkey.authz.cas.endpoint.ticket.service; package org.maxkey.authz.cas.endpoint.ticket.service;
import java.util.concurrent.ConcurrentHashMap; import java.time.Duration;
import org.ehcache.UserManagedCache;
import org.ehcache.config.builders.ExpiryPolicyBuilder;
import org.ehcache.config.builders.UserManagedCacheBuilder;
import org.maxkey.authz.cas.endpoint.ticket.Ticket; import org.maxkey.authz.cas.endpoint.ticket.Ticket;
public class InMemoryTicketServices extends RandomServiceTicketServices { public class InMemoryTicketServices extends RandomServiceTicketServices {
protected final static ConcurrentHashMap<String, Ticket> authorizationTicketStore = new ConcurrentHashMap<String, Ticket>(); protected final static UserManagedCache<String, Ticket> casTicketStore =
UserManagedCacheBuilder.newUserManagedCacheBuilder(String.class, Ticket.class)
.withExpiry(ExpiryPolicyBuilder.timeToLiveExpiration(Duration.ofSeconds(60)))
.build(true);
@Override @Override
protected void store(String ticketId, Ticket ticket) { protected void store(String ticketId, Ticket ticket) {
this.authorizationTicketStore.put(ticketId, ticket); casTicketStore.put(ticketId, ticket);
} }
@Override @Override
public Ticket remove(String ticketId) { public Ticket remove(String ticketId) {
Ticket ticket = this.authorizationTicketStore.remove(ticketId); Ticket ticket=casTicketStore.get(ticketId);
casTicketStore.remove(ticketId);
return ticket; return ticket;
} }

View File

@ -1,7 +1,10 @@
package org.maxkey.authz.oauth2.provider.code; package org.maxkey.authz.oauth2.provider.code;
import java.util.concurrent.ConcurrentHashMap; import java.time.Duration;
import org.ehcache.UserManagedCache;
import org.ehcache.config.builders.ExpiryPolicyBuilder;
import org.ehcache.config.builders.UserManagedCacheBuilder;
import org.maxkey.authz.oauth2.provider.OAuth2Authentication; import org.maxkey.authz.oauth2.provider.OAuth2Authentication;
/** /**
@ -11,17 +14,19 @@ import org.maxkey.authz.oauth2.provider.OAuth2Authentication;
* @author Dave Syer * @author Dave Syer
*/ */
public class InMemoryAuthorizationCodeServices extends RandomValueAuthorizationCodeServices { public class InMemoryAuthorizationCodeServices extends RandomValueAuthorizationCodeServices {
protected final static UserManagedCache<String, OAuth2Authentication> authorizationCodeStore =
protected final ConcurrentHashMap<String, OAuth2Authentication> authorizationCodeStore = new ConcurrentHashMap<String, OAuth2Authentication>(); UserManagedCacheBuilder.newUserManagedCacheBuilder(String.class, OAuth2Authentication.class)
.withExpiry(ExpiryPolicyBuilder.timeToLiveExpiration(Duration.ofSeconds(60)))
.build(true);
@Override @Override
protected void store(String code, OAuth2Authentication authentication) { protected void store(String code, OAuth2Authentication authentication) {
this.authorizationCodeStore.put(code, authentication); authorizationCodeStore.put(code, authentication);
} }
@Override @Override
public OAuth2Authentication remove(String code) { public OAuth2Authentication remove(String code) {
OAuth2Authentication auth = this.authorizationCodeStore.remove(code); OAuth2Authentication auth = authorizationCodeStore.get(code);
authorizationCodeStore.remove(code);
return auth; return auth;
} }