mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-06 17:08:29 +08:00
Factorys
This commit is contained in:
parent
3bee9b5896
commit
aad4e7e878
@ -0,0 +1,31 @@
|
||||
package org.maxkey.authn.online;
|
||||
|
||||
import org.maxkey.constants.ConstantsPersistence;
|
||||
import org.maxkey.persistence.redis.RedisConnectionFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
public class OnlineTicketServicesFactory {
|
||||
private static final Logger _logger =
|
||||
LoggerFactory.getLogger(OnlineTicketServicesFactory.class);
|
||||
|
||||
public OnlineTicketServices getService(
|
||||
int persistence,
|
||||
JdbcTemplate jdbcTemplate,
|
||||
RedisConnectionFactory redisConnFactory){
|
||||
|
||||
OnlineTicketServices onlineTicketServices = null;
|
||||
if (persistence == ConstantsPersistence.INMEMORY) {
|
||||
onlineTicketServices = new InMemoryOnlineTicketServices();
|
||||
_logger.debug("InMemoryOnlineTicketServices");
|
||||
} else if (persistence == ConstantsPersistence.JDBC) {
|
||||
_logger.debug("OnlineTicketServices not support ");
|
||||
} else if (persistence == ConstantsPersistence.REDIS) {
|
||||
onlineTicketServices = new RedisOnlineTicketServices(redisConnFactory);
|
||||
_logger.debug("RedisOnlineTicketServices");
|
||||
}
|
||||
|
||||
return onlineTicketServices;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package org.maxkey.authn.support.rememberme;
|
||||
|
||||
import org.maxkey.constants.ConstantsPersistence;
|
||||
import org.maxkey.persistence.redis.RedisConnectionFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
public class RemeberMeServiceFactory {
|
||||
private static final Logger _logger =
|
||||
LoggerFactory.getLogger(RemeberMeServiceFactory.class);
|
||||
|
||||
public AbstractRemeberMeService getService(
|
||||
int persistence,
|
||||
JdbcTemplate jdbcTemplate,
|
||||
RedisConnectionFactory redisConnFactory){
|
||||
|
||||
AbstractRemeberMeService remeberMeService = null;
|
||||
if (persistence == ConstantsPersistence.INMEMORY) {
|
||||
remeberMeService = new InMemoryRemeberMeService();
|
||||
_logger.debug("InMemoryRemeberMeService");
|
||||
} else if (persistence == ConstantsPersistence.JDBC) {
|
||||
//remeberMeService = new JdbcRemeberMeService(jdbcTemplate);
|
||||
_logger.debug("JdbcRemeberMeService not support ");
|
||||
} else if (persistence == ConstantsPersistence.REDIS) {
|
||||
remeberMeService = new RedisRemeberMeService(redisConnFactory);
|
||||
_logger.debug("RedisRemeberMeService");
|
||||
}
|
||||
return remeberMeService;
|
||||
}
|
||||
}
|
||||
@ -23,15 +23,12 @@ import javax.sql.DataSource;
|
||||
import org.maxkey.authn.AbstractAuthenticationProvider;
|
||||
import org.maxkey.authn.RealmAuthenticationProvider;
|
||||
import org.maxkey.authn.SavedRequestAwareAuthenticationSuccessHandler;
|
||||
import org.maxkey.authn.online.InMemoryOnlineTicketServices;
|
||||
import org.maxkey.authn.online.OnlineTicketServices;
|
||||
import org.maxkey.authn.online.RedisOnlineTicketServices;
|
||||
import org.maxkey.authn.online.OnlineTicketServicesFactory;
|
||||
import org.maxkey.authn.realm.AbstractAuthenticationRealm;
|
||||
import org.maxkey.authn.support.rememberme.AbstractRemeberMeService;
|
||||
import org.maxkey.authn.support.rememberme.InMemoryRemeberMeService;
|
||||
import org.maxkey.authn.support.rememberme.RedisRemeberMeService;
|
||||
import org.maxkey.authn.support.rememberme.RemeberMeServiceFactory;
|
||||
import org.maxkey.configuration.ApplicationConfig;
|
||||
import org.maxkey.constants.ConstantsPersistence;
|
||||
import org.maxkey.constants.ConstantsProperties;
|
||||
import org.maxkey.crypto.password.LdapShaPasswordEncoder;
|
||||
import org.maxkey.crypto.password.Md4PasswordEncoder;
|
||||
@ -84,7 +81,7 @@ public class AuthenticationAutoConfiguration implements InitializingBean {
|
||||
AbstractRemeberMeService remeberMeService,
|
||||
OnlineTicketServices onlineTicketServices
|
||||
) {
|
||||
|
||||
_logger.debug("init authenticationProvider .");
|
||||
return new RealmAuthenticationProvider(
|
||||
authenticationRealm,
|
||||
applicationConfig,
|
||||
@ -121,6 +118,7 @@ public class AuthenticationAutoConfiguration implements InitializingBean {
|
||||
*/
|
||||
@Bean(name = "passwordEncoder")
|
||||
public PasswordEncoder passwordEncoder() {
|
||||
_logger.debug("init passwordEncoder .");
|
||||
String idForEncode = "bcrypt";
|
||||
Map<String ,PasswordEncoder > encoders = new HashMap<String ,PasswordEncoder>();
|
||||
encoders.put(idForEncode, new BCryptPasswordEncoder());
|
||||
@ -157,18 +155,7 @@ public class AuthenticationAutoConfiguration implements InitializingBean {
|
||||
@Value("${config.login.remeberme.validity}") int validity,
|
||||
JdbcTemplate jdbcTemplate,
|
||||
RedisConnectionFactory redisConnFactory) {
|
||||
AbstractRemeberMeService remeberMeService = null;
|
||||
if (persistence == ConstantsPersistence.INMEMORY) {
|
||||
remeberMeService = new InMemoryRemeberMeService();
|
||||
_logger.debug("InMemoryRemeberMeService");
|
||||
} else if (persistence == ConstantsPersistence.JDBC) {
|
||||
//remeberMeService = new JdbcRemeberMeService(jdbcTemplate);
|
||||
_logger.debug("JdbcRemeberMeService not support ");
|
||||
} else if (persistence == ConstantsPersistence.REDIS) {
|
||||
remeberMeService = new RedisRemeberMeService(redisConnFactory);
|
||||
_logger.debug("RedisRemeberMeService");
|
||||
}
|
||||
return remeberMeService;
|
||||
return new RemeberMeServiceFactory().getService(persistence, jdbcTemplate, redisConnFactory);
|
||||
}
|
||||
|
||||
@Bean(name = "onlineTicketServices")
|
||||
@ -176,17 +163,7 @@ public class AuthenticationAutoConfiguration implements InitializingBean {
|
||||
@Value("${config.server.persistence}") int persistence,
|
||||
JdbcTemplate jdbcTemplate,
|
||||
RedisConnectionFactory redisConnFactory) {
|
||||
OnlineTicketServices onlineTicketServices = null;
|
||||
if (persistence == ConstantsPersistence.INMEMORY) {
|
||||
onlineTicketServices = new InMemoryOnlineTicketServices();
|
||||
_logger.debug("InMemoryOnlineTicketServices");
|
||||
} else if (persistence == ConstantsPersistence.JDBC) {
|
||||
_logger.debug("OnlineTicketServices not support ");
|
||||
} else if (persistence == ConstantsPersistence.REDIS) {
|
||||
onlineTicketServices = new RedisOnlineTicketServices(redisConnFactory);
|
||||
_logger.debug("RedisOnlineTicketServices");
|
||||
}
|
||||
return onlineTicketServices;
|
||||
return new OnlineTicketServicesFactory().getService(persistence, jdbcTemplate, redisConnFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -8,6 +8,5 @@ dependencies {
|
||||
|
||||
compile project(":maxkey-common")
|
||||
compile project(":maxkey-core")
|
||||
compile project(":maxkey-persistence")
|
||||
|
||||
}
|
||||
@ -222,7 +222,7 @@ public class InitializeContext extends HttpServlet {
|
||||
_logger.info("+ Version "
|
||||
+ WebContext.properties.getProperty("application.formatted-version"));
|
||||
_logger.info("+");
|
||||
_logger.info("+ ©Copyright 2018-2020 https://www.maxkey.top/");
|
||||
_logger.info("+ "+ Character.toString(0xA9) + "Copyright 2018-2021 https://www.maxkey.top/");
|
||||
_logger.info("+ Licensed under the Apache License, Version 2.0 ");
|
||||
_logger.info("-----------------------------------------------------------");
|
||||
}
|
||||
|
||||
10
maxkey-core/src/test/java/org/maxkey/CopyrightC.java
Normal file
10
maxkey-core/src/test/java/org/maxkey/CopyrightC.java
Normal file
@ -0,0 +1,10 @@
|
||||
package org.maxkey;
|
||||
|
||||
public class CopyrightC {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
System.out.println(Character.toString(0xA9));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package org.maxkey.authz.cas.endpoint.ticket.service;
|
||||
|
||||
import org.maxkey.constants.ConstantsPersistence;
|
||||
import org.maxkey.persistence.redis.RedisConnectionFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
public class TicketGrantingTicketServicesFactory {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(TicketGrantingTicketServicesFactory.class);
|
||||
|
||||
public TicketServices getService(
|
||||
int persistence,
|
||||
JdbcTemplate jdbcTemplate,
|
||||
RedisConnectionFactory redisConnFactory) {
|
||||
TicketServices casTicketServices = null;
|
||||
if (persistence == ConstantsPersistence.INMEMORY) {
|
||||
casTicketServices = new InMemoryTicketGrantingTicketServices();
|
||||
_logger.debug("InMemoryTicketGrantingTicketServices");
|
||||
} else if (persistence == ConstantsPersistence.JDBC) {
|
||||
//
|
||||
//casTicketServices = new JdbcTicketGrantingTicketServices(jdbcTemplate);
|
||||
_logger.debug("JdbcTicketGrantingTicketServices not support ");
|
||||
} else if (persistence == ConstantsPersistence.REDIS) {
|
||||
casTicketServices = new RedisTicketGrantingTicketServices(redisConnFactory);
|
||||
_logger.debug("RedisTicketServices");
|
||||
}
|
||||
return casTicketServices;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package org.maxkey.authz.cas.endpoint.ticket.service;
|
||||
|
||||
import org.maxkey.constants.ConstantsPersistence;
|
||||
import org.maxkey.persistence.redis.RedisConnectionFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
public class TicketServicesFactory {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(TicketServicesFactory.class);
|
||||
|
||||
public TicketServices getService(
|
||||
int persistence,
|
||||
JdbcTemplate jdbcTemplate,
|
||||
RedisConnectionFactory redisConnFactory) {
|
||||
TicketServices casTicketServices = null;
|
||||
if (persistence == ConstantsPersistence.INMEMORY) {
|
||||
casTicketServices = new InMemoryTicketServices();
|
||||
_logger.debug("InMemoryTicketServices");
|
||||
} else if (persistence == ConstantsPersistence.JDBC) {
|
||||
//casTicketServices = new JdbcTicketServices(jdbcTemplate);
|
||||
_logger.debug("JdbcTicketServices not support ");
|
||||
} else if (persistence == ConstantsPersistence.REDIS) {
|
||||
casTicketServices = new RedisTicketServices(redisConnFactory);
|
||||
_logger.debug("RedisTicketServices");
|
||||
}
|
||||
return casTicketServices;
|
||||
}
|
||||
}
|
||||
@ -17,12 +17,9 @@
|
||||
|
||||
package org.maxkey.autoconfigure;
|
||||
|
||||
import org.maxkey.authz.cas.endpoint.ticket.service.InMemoryTicketGrantingTicketServices;
|
||||
import org.maxkey.authz.cas.endpoint.ticket.service.InMemoryTicketServices;
|
||||
import org.maxkey.authz.cas.endpoint.ticket.service.RedisTicketGrantingTicketServices;
|
||||
import org.maxkey.authz.cas.endpoint.ticket.service.RedisTicketServices;
|
||||
import org.maxkey.authz.cas.endpoint.ticket.service.TicketGrantingTicketServicesFactory;
|
||||
import org.maxkey.authz.cas.endpoint.ticket.service.TicketServices;
|
||||
import org.maxkey.constants.ConstantsPersistence;
|
||||
import org.maxkey.authz.cas.endpoint.ticket.service.TicketServicesFactory;
|
||||
import org.maxkey.constants.ConstantsProperties;
|
||||
import org.maxkey.persistence.redis.RedisConnectionFactory;
|
||||
import org.slf4j.Logger;
|
||||
@ -55,18 +52,8 @@ public class CasAutoConfiguration implements InitializingBean {
|
||||
@Value("${config.login.remeberme.validity}") int validity,
|
||||
JdbcTemplate jdbcTemplate,
|
||||
RedisConnectionFactory redisConnFactory) {
|
||||
TicketServices casTicketServices = null;
|
||||
if (persistence == ConstantsPersistence.INMEMORY) {
|
||||
casTicketServices = new InMemoryTicketServices();
|
||||
_logger.debug("InMemoryTicketServices");
|
||||
} else if (persistence == ConstantsPersistence.JDBC) {
|
||||
//casTicketServices = new JdbcTicketServices(jdbcTemplate);
|
||||
_logger.debug("JdbcTicketServices not support ");
|
||||
} else if (persistence == ConstantsPersistence.REDIS) {
|
||||
casTicketServices = new RedisTicketServices(redisConnFactory);
|
||||
_logger.debug("RedisTicketServices");
|
||||
}
|
||||
return casTicketServices;
|
||||
_logger.debug("init casTicketServices.");
|
||||
return new TicketServicesFactory().getService(persistence, jdbcTemplate, redisConnFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,19 +68,8 @@ public class CasAutoConfiguration implements InitializingBean {
|
||||
@Value("${config.login.remeberme.validity}") int validity,
|
||||
JdbcTemplate jdbcTemplate,
|
||||
RedisConnectionFactory redisConnFactory) {
|
||||
TicketServices casTicketServices = null;
|
||||
if (persistence == ConstantsPersistence.INMEMORY) {
|
||||
casTicketServices = new InMemoryTicketGrantingTicketServices();
|
||||
_logger.debug("InMemoryTicketGrantingTicketServices");
|
||||
} else if (persistence == ConstantsPersistence.JDBC) {
|
||||
//
|
||||
//casTicketServices = new JdbcTicketGrantingTicketServices(jdbcTemplate);
|
||||
_logger.debug("JdbcTicketGrantingTicketServices not support ");
|
||||
} else if (persistence == ConstantsPersistence.REDIS) {
|
||||
casTicketServices = new RedisTicketGrantingTicketServices(redisConnFactory);
|
||||
_logger.debug("RedisTicketServices");
|
||||
}
|
||||
return casTicketServices;
|
||||
_logger.debug("init casTicketGrantingTicketServices.");
|
||||
return new TicketGrantingTicketServicesFactory().getService(persistence, jdbcTemplate, redisConnFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
package org.maxkey.authz.oauth2.provider.code;
|
||||
|
||||
import org.maxkey.constants.ConstantsPersistence;
|
||||
import org.maxkey.persistence.redis.RedisConnectionFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
public class AuthorizationCodeServicesFactory {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(AuthorizationCodeServicesFactory.class);
|
||||
|
||||
public AuthorizationCodeServices getService(
|
||||
int persistence,
|
||||
JdbcTemplate jdbcTemplate,
|
||||
RedisConnectionFactory redisConnFactory) {
|
||||
AuthorizationCodeServices authorizationCodeServices = null;
|
||||
if (persistence == ConstantsPersistence.INMEMORY) {
|
||||
authorizationCodeServices = new InMemoryAuthorizationCodeServices();
|
||||
_logger.debug("InMemoryAuthorizationCodeServices");
|
||||
} else if (persistence == ConstantsPersistence.JDBC) {
|
||||
//authorizationCodeServices = new JdbcAuthorizationCodeServices(jdbcTemplate);
|
||||
_logger.debug("JdbcAuthorizationCodeServices not support ");
|
||||
} else if (persistence == ConstantsPersistence.REDIS) {
|
||||
authorizationCodeServices = new RedisAuthorizationCodeServices(redisConnFactory);
|
||||
_logger.debug("RedisAuthorizationCodeServices");
|
||||
}
|
||||
return authorizationCodeServices;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package org.maxkey.authz.oauth2.provider.token.store;
|
||||
|
||||
import org.maxkey.authz.oauth2.provider.token.TokenStore;
|
||||
import org.maxkey.constants.ConstantsPersistence;
|
||||
import org.maxkey.persistence.redis.RedisConnectionFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
public class TokenStoreFactory {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(TokenStoreFactory.class);
|
||||
|
||||
public TokenStore getTokenStore(
|
||||
int persistence,
|
||||
JdbcTemplate jdbcTemplate,
|
||||
RedisConnectionFactory redisConnFactory) {
|
||||
TokenStore tokenStore = null;
|
||||
if (persistence == ConstantsPersistence.INMEMORY) {
|
||||
tokenStore = new InMemoryTokenStore();
|
||||
_logger.debug("InMemoryTokenStore");
|
||||
} else if (persistence == ConstantsPersistence.JDBC) {
|
||||
//tokenStore = new JdbcTokenStore(jdbcTemplate);
|
||||
_logger.debug("JdbcTokenStore not support ");
|
||||
} else if (persistence == ConstantsPersistence.REDIS) {
|
||||
tokenStore = new RedisTokenStore(redisConnFactory);
|
||||
_logger.debug("RedisTokenStore");
|
||||
}
|
||||
return tokenStore;
|
||||
}
|
||||
}
|
||||
@ -33,18 +33,15 @@ import org.maxkey.authz.oauth2.provider.approval.controller.OAuth20UserApprovalH
|
||||
import org.maxkey.authz.oauth2.provider.client.ClientDetailsUserDetailsService;
|
||||
import org.maxkey.authz.oauth2.provider.client.JdbcClientDetailsService;
|
||||
import org.maxkey.authz.oauth2.provider.code.AuthorizationCodeServices;
|
||||
import org.maxkey.authz.oauth2.provider.code.InMemoryAuthorizationCodeServices;
|
||||
import org.maxkey.authz.oauth2.provider.code.RedisAuthorizationCodeServices;
|
||||
import org.maxkey.authz.oauth2.provider.code.AuthorizationCodeServicesFactory;
|
||||
import org.maxkey.authz.oauth2.provider.endpoint.TokenEndpointAuthenticationFilter;
|
||||
import org.maxkey.authz.oauth2.provider.request.DefaultOAuth2RequestFactory;
|
||||
import org.maxkey.authz.oauth2.provider.token.TokenStore;
|
||||
import org.maxkey.authz.oauth2.provider.token.DefaultTokenServices;
|
||||
import org.maxkey.authz.oauth2.provider.token.store.InMemoryTokenStore;
|
||||
import org.maxkey.authz.oauth2.provider.token.store.JwtAccessTokenConverter;
|
||||
import org.maxkey.authz.oauth2.provider.token.store.RedisTokenStore;
|
||||
import org.maxkey.authz.oauth2.provider.token.store.TokenStoreFactory;
|
||||
import org.maxkey.authz.oidc.idtoken.OIDCIdTokenEnhancer;
|
||||
import org.maxkey.configuration.oidc.OIDCProviderMetadataDetails;
|
||||
import org.maxkey.constants.ConstantsPersistence;
|
||||
import org.maxkey.constants.ConstantsProperties;
|
||||
import org.maxkey.crypto.jose.keystore.JWKSetKeyStore;
|
||||
import org.maxkey.crypto.jwt.encryption.service.impl.DefaultJwtEncryptionAndDecryptionService;
|
||||
@ -212,19 +209,8 @@ public class Oauth20AutoConfiguration implements InitializingBean {
|
||||
public AuthorizationCodeServices oauth20AuthorizationCodeServices(
|
||||
@Value("${config.server.persistence}") int persistence,
|
||||
JdbcTemplate jdbcTemplate,
|
||||
RedisConnectionFactory redisConnFactory) {
|
||||
AuthorizationCodeServices authorizationCodeServices = null;
|
||||
if (persistence == ConstantsPersistence.INMEMORY) {
|
||||
authorizationCodeServices = new InMemoryAuthorizationCodeServices();
|
||||
_logger.debug("InMemoryAuthorizationCodeServices");
|
||||
} else if (persistence == ConstantsPersistence.JDBC) {
|
||||
//authorizationCodeServices = new JdbcAuthorizationCodeServices(jdbcTemplate);
|
||||
_logger.debug("JdbcAuthorizationCodeServices not support ");
|
||||
} else if (persistence == ConstantsPersistence.REDIS) {
|
||||
authorizationCodeServices = new RedisAuthorizationCodeServices(redisConnFactory);
|
||||
_logger.debug("RedisAuthorizationCodeServices");
|
||||
}
|
||||
return authorizationCodeServices;
|
||||
RedisConnectionFactory redisConnFactory) {
|
||||
return new AuthorizationCodeServicesFactory().getService(persistence, jdbcTemplate, redisConnFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -237,18 +223,8 @@ public class Oauth20AutoConfiguration implements InitializingBean {
|
||||
@Value("${config.server.persistence}") int persistence,
|
||||
JdbcTemplate jdbcTemplate,
|
||||
RedisConnectionFactory redisConnFactory) {
|
||||
TokenStore tokenStore = null;
|
||||
if (persistence == ConstantsPersistence.INMEMORY) {
|
||||
tokenStore = new InMemoryTokenStore();
|
||||
_logger.debug("InMemoryTokenStore");
|
||||
} else if (persistence == ConstantsPersistence.JDBC) {
|
||||
//tokenStore = new JdbcTokenStore(jdbcTemplate);
|
||||
_logger.debug("JdbcTokenStore not support ");
|
||||
} else if (persistence == ConstantsPersistence.REDIS) {
|
||||
tokenStore = new RedisTokenStore(redisConnFactory);
|
||||
_logger.debug("RedisTokenStore");
|
||||
}
|
||||
return tokenStore;
|
||||
|
||||
return new TokenStoreFactory().getTokenStore(persistence, jdbcTemplate, redisConnFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user