@Bean public to default

This commit is contained in:
shimingxy 2024-08-19 16:24:47 +08:00
parent b7b0cd21c6
commit b6f9828ff7
24 changed files with 291 additions and 291 deletions

View File

@ -40,7 +40,7 @@ public class MvcCurrentUserAutoConfiguration implements WebMvcConfigurer {
} }
@Bean @Bean
public CurrentUserMethodArgumentResolver currentUserMethodArgumentResolver() { CurrentUserMethodArgumentResolver currentUserMethodArgumentResolver() {
return new CurrentUserMethodArgumentResolver(); return new CurrentUserMethodArgumentResolver();
} }

View File

@ -37,13 +37,13 @@ public class SessionAutoConfiguration {
@Bean(name = "savedRequestSuccessHandler") @Bean(name = "savedRequestSuccessHandler")
public SavedRequestAwareAuthenticationSuccessHandler SavedRequestAwareAuthenticationSuccessHandler
savedRequestAwareAuthenticationSuccessHandler() { savedRequestAwareAuthenticationSuccessHandler() {
return new SavedRequestAwareAuthenticationSuccessHandler(); return new SavedRequestAwareAuthenticationSuccessHandler();
} }
@Bean @Bean
public SessionManager sessionManager( SessionManager sessionManager(
@Value("${maxkey.server.persistence}") int persistence, @Value("${maxkey.server.persistence}") int persistence,
JdbcTemplate jdbcTemplate, JdbcTemplate jdbcTemplate,
RedisConnectionFactory redisConnFactory, RedisConnectionFactory redisConnFactory,
@ -55,7 +55,7 @@ public class SessionAutoConfiguration {
} }
@Bean @Bean
public HttpSessionListenerAdapter httpSessionListenerAdapter() { HttpSessionListenerAdapter httpSessionListenerAdapter() {
return new HttpSessionListenerAdapter(); return new HttpSessionListenerAdapter();
} }

View File

@ -40,7 +40,7 @@ public class TokenAutoConfiguration{
LoggerFactory.getLogger(TokenAutoConfiguration.class); LoggerFactory.getLogger(TokenAutoConfiguration.class);
@Bean @Bean
public AuthTokenService authTokenService( AuthTokenService authTokenService(
AuthJwkConfig authJwkConfig, AuthJwkConfig authJwkConfig,
RedisConnectionFactory redisConnFactory, RedisConnectionFactory redisConnFactory,
MomentaryService momentaryService, MomentaryService momentaryService,
@ -63,7 +63,7 @@ public class TokenAutoConfiguration{
} }
@Bean @Bean
public AuthRefreshTokenService refreshTokenService(AuthJwkConfig authJwkConfig) throws JOSEException { AuthRefreshTokenService refreshTokenService(AuthJwkConfig authJwkConfig) throws JOSEException {
return new AuthRefreshTokenService(authJwkConfig); return new AuthRefreshTokenService(authJwkConfig);
} }

View File

@ -12,7 +12,6 @@ import org.dromara.maxkey.authn.session.SessionManager;
import org.dromara.maxkey.constants.ConstsLoginType; import org.dromara.maxkey.constants.ConstsLoginType;
import org.dromara.maxkey.crypto.password.PasswordReciprocal; import org.dromara.maxkey.crypto.password.PasswordReciprocal;
import org.dromara.maxkey.entity.idm.UserInfo; import org.dromara.maxkey.entity.idm.UserInfo;
;
import org.dromara.maxkey.web.WebConstants; import org.dromara.maxkey.web.WebConstants;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

View File

@ -47,7 +47,7 @@ public class AuthnProviderAutoConfiguration {
static final Logger _logger = LoggerFactory.getLogger(AuthnProviderAutoConfiguration.class); static final Logger _logger = LoggerFactory.getLogger(AuthnProviderAutoConfiguration.class);
@Bean @Bean
public AbstractAuthenticationProvider authenticationProvider( AbstractAuthenticationProvider authenticationProvider(
NormalAuthenticationProvider normalAuthenticationProvider, NormalAuthenticationProvider normalAuthenticationProvider,
MobileAuthenticationProvider mobileAuthenticationProvider, MobileAuthenticationProvider mobileAuthenticationProvider,
TrustedAuthenticationProvider trustedAuthenticationProvider, TrustedAuthenticationProvider trustedAuthenticationProvider,
@ -63,7 +63,7 @@ public class AuthnProviderAutoConfiguration {
} }
@Bean @Bean
public NormalAuthenticationProvider normalAuthenticationProvider( NormalAuthenticationProvider normalAuthenticationProvider(
AbstractAuthenticationRealm authenticationRealm, AbstractAuthenticationRealm authenticationRealm,
ApplicationConfig applicationConfig, ApplicationConfig applicationConfig,
SessionManager sessionManager, SessionManager sessionManager,

View File

@ -42,14 +42,14 @@ public class JwtAuthnAutoConfiguration {
* @return * @return
*/ */
@Bean @Bean
public JWKSetKeyStore jwtLoginJwkSetKeyStore() { JWKSetKeyStore jwtLoginJwkSetKeyStore() {
JWKSetKeyStore jwkSetKeyStore = new JWKSetKeyStore(); JWKSetKeyStore jwkSetKeyStore = new JWKSetKeyStore();
ClassPathResource classPathResource = new ClassPathResource("/config/loginjwkkeystore.jwks"); ClassPathResource classPathResource = new ClassPathResource("/config/loginjwkkeystore.jwks");
jwkSetKeyStore.setLocation(classPathResource); jwkSetKeyStore.setLocation(classPathResource);
_logger.debug("JWT Login JwkSet KeyStore init."); _logger.debug("JWT Login JwkSet KeyStore init.");
return jwkSetKeyStore; return jwkSetKeyStore;
} }
/** /**
* jwt Login ValidationService. * jwt Login ValidationService.
* @return * @return
@ -58,9 +58,9 @@ public class JwtAuthnAutoConfiguration {
* @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
*/ */
@Bean @Bean
public DefaultJwtSigningAndValidationService jwtLoginValidationService( DefaultJwtSigningAndValidationService jwtLoginValidationService(
@Qualifier("jwtLoginJwkSetKeyStore") JWKSetKeyStore jwtLoginJwkSetKeyStore) @Qualifier("jwtLoginJwkSetKeyStore") JWKSetKeyStore jwtLoginJwkSetKeyStore)
throws NoSuchAlgorithmException, InvalidKeySpecException, JOSEException { throws NoSuchAlgorithmException, InvalidKeySpecException, JOSEException {
DefaultJwtSigningAndValidationService jwtSignerValidationService = DefaultJwtSigningAndValidationService jwtSignerValidationService =
new DefaultJwtSigningAndValidationService(jwtLoginJwkSetKeyStore); new DefaultJwtSigningAndValidationService(jwtLoginJwkSetKeyStore);
jwtSignerValidationService.setDefaultSignerKeyId("maxkey_rsa"); jwtSignerValidationService.setDefaultSignerKeyId("maxkey_rsa");
@ -74,7 +74,7 @@ public class JwtAuthnAutoConfiguration {
* @return * @return
*/ */
@Bean @Bean
public JwtLoginService jwtLoginService( JwtLoginService jwtLoginService(
@Value("${maxkey.login.jwt.issuer}") @Value("${maxkey.login.jwt.issuer}")
String issuer, String issuer,
@Qualifier("jwtLoginValidationService") @Qualifier("jwtLoginValidationService")

View File

@ -37,7 +37,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
}) })
public class CasAutoConfiguration implements InitializingBean { public class CasAutoConfiguration implements InitializingBean {
private static final Logger _logger = LoggerFactory.getLogger(CasAutoConfiguration.class); private static final Logger _logger = LoggerFactory.getLogger(CasAutoConfiguration.class);
/** /**
* TicketServices. * TicketServices.
* @param persistence int * @param persistence int
@ -45,7 +45,7 @@ public class CasAutoConfiguration implements InitializingBean {
* @return casTicketServices * @return casTicketServices
*/ */
@Bean(name = "casTicketServices") @Bean(name = "casTicketServices")
public TicketServices casTicketServices( TicketServices casTicketServices(
@Value("${maxkey.server.persistence}") int persistence, @Value("${maxkey.server.persistence}") int persistence,
@Value("${maxkey.login.remeberme.validity}") int validity, @Value("${maxkey.login.remeberme.validity}") int validity,
JdbcTemplate jdbcTemplate, JdbcTemplate jdbcTemplate,
@ -53,7 +53,7 @@ public class CasAutoConfiguration implements InitializingBean {
_logger.debug("init casTicketServices."); _logger.debug("init casTicketServices.");
return new TicketServicesFactory().getService(persistence, jdbcTemplate, redisConnFactory); return new TicketServicesFactory().getService(persistence, jdbcTemplate, redisConnFactory);
} }
/** /**
* TicketServices. * TicketServices.
* @param persistence int * @param persistence int
@ -61,7 +61,7 @@ public class CasAutoConfiguration implements InitializingBean {
* @return casTicketServices * @return casTicketServices
*/ */
@Bean(name = "casTicketGrantingTicketServices") @Bean(name = "casTicketGrantingTicketServices")
public TicketServices casTicketGrantingTicketServices( TicketServices casTicketGrantingTicketServices(
@Value("${maxkey.server.persistence}") int persistence, @Value("${maxkey.server.persistence}") int persistence,
@Value("${maxkey.login.remeberme.validity}") int validity, @Value("${maxkey.login.remeberme.validity}") int validity,
JdbcTemplate jdbcTemplate, JdbcTemplate jdbcTemplate,
@ -69,9 +69,9 @@ public class CasAutoConfiguration implements InitializingBean {
_logger.debug("init casTicketGrantingTicketServices."); _logger.debug("init casTicketGrantingTicketServices.");
return new TicketGrantingTicketServicesFactory().getService(persistence, jdbcTemplate, redisConnFactory); return new TicketGrantingTicketServicesFactory().getService(persistence, jdbcTemplate, redisConnFactory);
} }
@Bean(name = "casProxyGrantingTicketServices") @Bean(name = "casProxyGrantingTicketServices")
public TicketServices casProxyGrantingTicketServices( TicketServices casProxyGrantingTicketServices(
@Value("${maxkey.server.persistence}") int persistence, @Value("${maxkey.server.persistence}") int persistence,
@Value("${maxkey.login.remeberme.validity}") int validity, @Value("${maxkey.login.remeberme.validity}") int validity,
JdbcTemplate jdbcTemplate, JdbcTemplate jdbcTemplate,

View File

@ -74,9 +74,9 @@ import jakarta.servlet.Filter;
}) })
public class Oauth20AutoConfiguration implements InitializingBean { public class Oauth20AutoConfiguration implements InitializingBean {
private static final Logger _logger = LoggerFactory.getLogger(Oauth20AutoConfiguration.class); private static final Logger _logger = LoggerFactory.getLogger(Oauth20AutoConfiguration.class);
@Bean @Bean
public FilterRegistrationBean<Filter> tokenEndpointAuthenticationFilter() { FilterRegistrationBean<Filter> tokenEndpointAuthenticationFilter() {
_logger.debug("TokenEndpointAuthenticationFilter init "); _logger.debug("TokenEndpointAuthenticationFilter init ");
FilterRegistrationBean<Filter> registration = new FilterRegistrationBean<>(); FilterRegistrationBean<Filter> registration = new FilterRegistrationBean<>();
registration.setFilter(new TokenEndpointAuthenticationFilter()); registration.setFilter(new TokenEndpointAuthenticationFilter());
@ -87,14 +87,14 @@ public class Oauth20AutoConfiguration implements InitializingBean {
registration.setOrder(1); registration.setOrder(1);
return registration; return registration;
} }
/** /**
* OIDCProviderMetadataDetails. * OIDCProviderMetadataDetails.
* Self-issued Provider Metadata * Self-issued Provider Metadata
* http://openid.net/specs/openid-connect-core-1_0.html#SelfIssued * http://openid.net/specs/openid-connect-core-1_0.html#SelfIssued
*/ */
@Bean(name = "oidcProviderMetadata") @Bean(name = "oidcProviderMetadata")
public OIDCProviderMetadataDetails oidcProviderMetadata( OIDCProviderMetadataDetails oidcProviderMetadata(
@Value("${maxkey.oidc.metadata.issuer}") @Value("${maxkey.oidc.metadata.issuer}")
String issuer, String issuer,
@Value("${maxkey.oidc.metadata.authorizationEndpoint}") @Value("${maxkey.oidc.metadata.authorizationEndpoint}")
@ -117,14 +117,14 @@ public class Oauth20AutoConfiguration implements InitializingBean {
* @return * @return
*/ */
@Bean(name = "jwkSetKeyStore") @Bean(name = "jwkSetKeyStore")
public JWKSetKeyStore jwkSetKeyStore() { JWKSetKeyStore jwkSetKeyStore() {
JWKSetKeyStore jwkSetKeyStore = new JWKSetKeyStore(); JWKSetKeyStore jwkSetKeyStore = new JWKSetKeyStore();
ClassPathResource classPathResource = new ClassPathResource("/config/keystore.jwks"); ClassPathResource classPathResource = new ClassPathResource("/config/keystore.jwks");
jwkSetKeyStore.setLocation(classPathResource); jwkSetKeyStore.setLocation(classPathResource);
_logger.debug("JWKSet KeyStore init."); _logger.debug("JWKSet KeyStore init.");
return jwkSetKeyStore; return jwkSetKeyStore;
} }
/** /**
* jwtSetKeyStore. * jwtSetKeyStore.
* @return * @return
@ -133,10 +133,10 @@ public class Oauth20AutoConfiguration implements InitializingBean {
* @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
*/ */
@Bean(name = "jwtSignerValidationService") @Bean(name = "jwtSignerValidationService")
public DefaultJwtSigningAndValidationService jwtSignerValidationService( DefaultJwtSigningAndValidationService jwtSignerValidationService(
@Qualifier("jwkSetKeyStore") @Qualifier("jwkSetKeyStore")
JWKSetKeyStore jwkSetKeyStore) JWKSetKeyStore jwkSetKeyStore)
throws NoSuchAlgorithmException, InvalidKeySpecException, JOSEException { throws NoSuchAlgorithmException, InvalidKeySpecException, JOSEException {
DefaultJwtSigningAndValidationService jwtSignerValidationService = DefaultJwtSigningAndValidationService jwtSignerValidationService =
new DefaultJwtSigningAndValidationService(jwkSetKeyStore); new DefaultJwtSigningAndValidationService(jwkSetKeyStore);
jwtSignerValidationService.setDefaultSignerKeyId("maxkey_rsa"); jwtSignerValidationService.setDefaultSignerKeyId("maxkey_rsa");
@ -144,7 +144,7 @@ public class Oauth20AutoConfiguration implements InitializingBean {
_logger.debug("JWT Signer and Validation Service init."); _logger.debug("JWT Signer and Validation Service init.");
return jwtSignerValidationService; return jwtSignerValidationService;
} }
/** /**
* jwtSetKeyStore. * jwtSetKeyStore.
* @return * @return
@ -153,10 +153,10 @@ public class Oauth20AutoConfiguration implements InitializingBean {
* @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
*/ */
@Bean(name = "jwtEncryptionService") @Bean(name = "jwtEncryptionService")
public DefaultJwtEncryptionAndDecryptionService jwtEncryptionService( DefaultJwtEncryptionAndDecryptionService jwtEncryptionService(
@Qualifier("jwkSetKeyStore") @Qualifier("jwkSetKeyStore")
JWKSetKeyStore jwkSetKeyStore) JWKSetKeyStore jwkSetKeyStore)
throws NoSuchAlgorithmException, InvalidKeySpecException, JOSEException { throws NoSuchAlgorithmException, InvalidKeySpecException, JOSEException {
DefaultJwtEncryptionAndDecryptionService jwtEncryptionService = DefaultJwtEncryptionAndDecryptionService jwtEncryptionService =
new DefaultJwtEncryptionAndDecryptionService(jwkSetKeyStore); new DefaultJwtEncryptionAndDecryptionService(jwkSetKeyStore);
jwtEncryptionService.setDefaultAlgorithm(JWEAlgorithm.RSA_OAEP_256);//RSA1_5 jwtEncryptionService.setDefaultAlgorithm(JWEAlgorithm.RSA_OAEP_256);//RSA1_5
@ -165,13 +165,13 @@ public class Oauth20AutoConfiguration implements InitializingBean {
_logger.debug("JWT Encryption and Decryption Service init."); _logger.debug("JWT Encryption and Decryption Service init.");
return jwtEncryptionService; return jwtEncryptionService;
} }
/** /**
* tokenEnhancer. * tokenEnhancer.
* @return * @return
*/ */
@Bean(name = "tokenEnhancer") @Bean(name = "tokenEnhancer")
public OIDCIdTokenEnhancer tokenEnhancer( OIDCIdTokenEnhancer tokenEnhancer(
OIDCProviderMetadataDetails oidcProviderMetadata, OIDCProviderMetadataDetails oidcProviderMetadata,
ClientDetailsService oauth20JdbcClientDetailsService) { ClientDetailsService oauth20JdbcClientDetailsService) {
OIDCIdTokenEnhancer tokenEnhancer = new OIDCIdTokenEnhancer(); OIDCIdTokenEnhancer tokenEnhancer = new OIDCIdTokenEnhancer();
@ -180,6 +180,7 @@ public class Oauth20AutoConfiguration implements InitializingBean {
_logger.debug("OIDC IdToken Enhancer init."); _logger.debug("OIDC IdToken Enhancer init.");
return tokenEnhancer; return tokenEnhancer;
} }
//以上部分为了支持OpenID Connect 1.0 //以上部分为了支持OpenID Connect 1.0
@ -189,57 +190,57 @@ public class Oauth20AutoConfiguration implements InitializingBean {
* @return oauth20AuthorizationCodeServices * @return oauth20AuthorizationCodeServices
*/ */
@Bean(name = "oauth20AuthorizationCodeServices") @Bean(name = "oauth20AuthorizationCodeServices")
public AuthorizationCodeServices oauth20AuthorizationCodeServices( AuthorizationCodeServices oauth20AuthorizationCodeServices(
@Value("${maxkey.server.persistence}") int persistence, @Value("${maxkey.server.persistence}") int persistence,
JdbcTemplate jdbcTemplate, JdbcTemplate jdbcTemplate,
RedisConnectionFactory redisConnFactory) { RedisConnectionFactory redisConnFactory) {
_logger.debug("OAuth 2 Authorization Code Services init."); _logger.debug("OAuth 2 Authorization Code Services init.");
return new AuthorizationCodeServicesFactory().getService(persistence, jdbcTemplate, redisConnFactory); return new AuthorizationCodeServicesFactory().getService(persistence, jdbcTemplate, redisConnFactory);
} }
/** /**
* TokenStore. * TokenStore.
* @param persistence int * @param persistence int
* @return oauth20TokenStore * @return oauth20TokenStore
*/ */
@Bean(name = "oauth20TokenStore") @Bean(name = "oauth20TokenStore")
public TokenStore oauth20TokenStore( TokenStore oauth20TokenStore(
@Value("${maxkey.server.persistence}") int persistence, @Value("${maxkey.server.persistence}") int persistence,
JdbcTemplate jdbcTemplate, JdbcTemplate jdbcTemplate,
RedisConnectionFactory redisConnFactory) { RedisConnectionFactory redisConnFactory) {
_logger.debug("OAuth 2 TokenStore init."); _logger.debug("OAuth 2 TokenStore init.");
return new TokenStoreFactory().getTokenStore(persistence, jdbcTemplate, redisConnFactory); return new TokenStoreFactory().getTokenStore(persistence, jdbcTemplate, redisConnFactory);
} }
/** /**
* jwtAccessTokenConverter. * jwtAccessTokenConverter.
* @return converter * @return converter
*/ */
@Bean(name = "converter") @Bean(name = "converter")
public JwtAccessTokenConverter jwtAccessTokenConverter() { JwtAccessTokenConverter jwtAccessTokenConverter() {
JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter(); JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter();
_logger.debug("OAuth 2 Jwt AccessToken Converter init."); _logger.debug("OAuth 2 Jwt AccessToken Converter init.");
return jwtAccessTokenConverter; return jwtAccessTokenConverter;
} }
/** /**
* clientDetailsService. * clientDetailsService.
* @return oauth20JdbcClientDetailsService * @return oauth20JdbcClientDetailsService
*/ */
@Bean(name = "oauth20JdbcClientDetailsService") @Bean(name = "oauth20JdbcClientDetailsService")
public JdbcClientDetailsService jdbcClientDetailsService(DataSource dataSource,@Qualifier("passwordReciprocal") PasswordEncoder passwordReciprocal) { JdbcClientDetailsService jdbcClientDetailsService(DataSource dataSource, @Qualifier("passwordReciprocal") PasswordEncoder passwordReciprocal) {
JdbcClientDetailsService clientDetailsService = new JdbcClientDetailsService(dataSource); JdbcClientDetailsService clientDetailsService = new JdbcClientDetailsService(dataSource);
//clientDetailsService.setPasswordEncoder(passwordReciprocal); //clientDetailsService.setPasswordEncoder(passwordReciprocal);
_logger.debug("OAuth 2 Jdbc ClientDetails Service init."); _logger.debug("OAuth 2 Jdbc ClientDetails Service init.");
return clientDetailsService; return clientDetailsService;
} }
/** /**
* clientDetailsUserDetailsService. * clientDetailsUserDetailsService.
* @return oauth20TokenServices * @return oauth20TokenServices
*/ */
@Bean(name = "oauth20TokenServices") @Bean(name = "oauth20TokenServices")
public DefaultTokenServices defaultTokenServices( DefaultTokenServices defaultTokenServices(
JdbcClientDetailsService oauth20JdbcClientDetailsService, JdbcClientDetailsService oauth20JdbcClientDetailsService,
TokenStore oauth20TokenStore, TokenStore oauth20TokenStore,
OIDCIdTokenEnhancer tokenEnhancer) { OIDCIdTokenEnhancer tokenEnhancer) {
@ -251,45 +252,45 @@ public class Oauth20AutoConfiguration implements InitializingBean {
_logger.debug("OAuth 2 Token Services init."); _logger.debug("OAuth 2 Token Services init.");
return tokenServices; return tokenServices;
} }
/** /**
* TokenApprovalStore. * TokenApprovalStore.
* @return oauth20ApprovalStore * @return oauth20ApprovalStore
*/ */
@Bean(name = "oauth20ApprovalStore") @Bean(name = "oauth20ApprovalStore")
public TokenApprovalStore tokenApprovalStore( TokenApprovalStore tokenApprovalStore(
TokenStore oauth20TokenStore) { TokenStore oauth20TokenStore) {
TokenApprovalStore tokenApprovalStore = new TokenApprovalStore(); TokenApprovalStore tokenApprovalStore = new TokenApprovalStore();
tokenApprovalStore.setTokenStore(oauth20TokenStore); tokenApprovalStore.setTokenStore(oauth20TokenStore);
_logger.debug("OAuth 2 Approval Store init."); _logger.debug("OAuth 2 Approval Store init.");
return tokenApprovalStore; return tokenApprovalStore;
} }
/** /**
* OAuth2RequestFactory. * OAuth2RequestFactory.
* @return oAuth2RequestFactory * @return oAuth2RequestFactory
*/ */
@Bean(name = "oAuth2RequestFactory") @Bean(name = "oAuth2RequestFactory")
public DefaultOAuth2RequestFactory oauth2RequestFactory( DefaultOAuth2RequestFactory oauth2RequestFactory(
JdbcClientDetailsService oauth20JdbcClientDetailsService) { JdbcClientDetailsService oauth20JdbcClientDetailsService) {
DefaultOAuth2RequestFactory oauth2RequestFactory = DefaultOAuth2RequestFactory oauth2RequestFactory =
new DefaultOAuth2RequestFactory(oauth20JdbcClientDetailsService); new DefaultOAuth2RequestFactory(oauth20JdbcClientDetailsService);
_logger.debug("OAuth 2 Request Factory init."); _logger.debug("OAuth 2 Request Factory init.");
return oauth2RequestFactory; return oauth2RequestFactory;
} }
/** /**
* OAuth20UserApprovalHandler. * OAuth20UserApprovalHandler.
* @return oauth20UserApprovalHandler * @return oauth20UserApprovalHandler
*/ */
@Bean(name = "oauth20UserApprovalHandler") @Bean(name = "oauth20UserApprovalHandler")
public OAuth20UserApprovalHandler oauth20UserApprovalHandler( OAuth20UserApprovalHandler oauth20UserApprovalHandler(
JdbcClientDetailsService oauth20JdbcClientDetailsService, JdbcClientDetailsService oauth20JdbcClientDetailsService,
DefaultOAuth2RequestFactory oAuth2RequestFactory, DefaultOAuth2RequestFactory oAuth2RequestFactory,
TokenApprovalStore oauth20ApprovalStore TokenApprovalStore oauth20ApprovalStore
) { ) {
OAuth20UserApprovalHandler userApprovalHandler = new OAuth20UserApprovalHandler(); OAuth20UserApprovalHandler userApprovalHandler = new OAuth20UserApprovalHandler();
userApprovalHandler.setApprovalStore(oauth20ApprovalStore); userApprovalHandler.setApprovalStore(oauth20ApprovalStore);
userApprovalHandler.setRequestFactory(oAuth2RequestFactory); userApprovalHandler.setRequestFactory(oAuth2RequestFactory);
@ -297,17 +298,17 @@ public class Oauth20AutoConfiguration implements InitializingBean {
_logger.debug("OAuth 2 User Approval Handler init."); _logger.debug("OAuth 2 User Approval Handler init.");
return userApprovalHandler; return userApprovalHandler;
} }
/** /**
* ProviderManager. * ProviderManager.
* @return oauth20UserAuthenticationManager * @return oauth20UserAuthenticationManager
*/ */
@Bean(name = "oauth20UserAuthenticationManager") @Bean(name = "oauth20UserAuthenticationManager")
public ProviderManager oauth20UserAuthenticationManager( ProviderManager oauth20UserAuthenticationManager(
@Qualifier("passwordEncoder") @Qualifier("passwordEncoder")
PasswordEncoder passwordEncoder, PasswordEncoder passwordEncoder,
LoginRepository loginRepository LoginRepository loginRepository
) { ) {
OAuth2UserDetailsService userDetailsService =new OAuth2UserDetailsService(); OAuth2UserDetailsService userDetailsService =new OAuth2UserDetailsService();
userDetailsService.setLoginRepository(loginRepository); userDetailsService.setLoginRepository(loginRepository);
@ -319,17 +320,17 @@ public class Oauth20AutoConfiguration implements InitializingBean {
_logger.debug("OAuth 2 User Authentication Manager init."); _logger.debug("OAuth 2 User Authentication Manager init.");
return authenticationManager; return authenticationManager;
} }
/** /**
* ProviderManager. * ProviderManager.
* @return oauth20ClientAuthenticationManager * @return oauth20ClientAuthenticationManager
*/ */
@Bean(name = "oauth20ClientAuthenticationManager") @Bean(name = "oauth20ClientAuthenticationManager")
public ProviderManager oauth20ClientAuthenticationManager( ProviderManager oauth20ClientAuthenticationManager(
JdbcClientDetailsService oauth20JdbcClientDetailsService, JdbcClientDetailsService oauth20JdbcClientDetailsService,
@Qualifier("passwordReciprocal") @Qualifier("passwordReciprocal")
PasswordEncoder passwordReciprocal PasswordEncoder passwordReciprocal
) { ) {
ClientDetailsUserDetailsService cientDetailsUserDetailsService = ClientDetailsUserDetailsService cientDetailsUserDetailsService =
new ClientDetailsUserDetailsService(oauth20JdbcClientDetailsService); new ClientDetailsUserDetailsService(oauth20JdbcClientDetailsService);

View File

@ -60,76 +60,76 @@ import org.springframework.ui.velocity.VelocityEngineFactoryBean;
}) })
public class Saml20AutoConfiguration implements InitializingBean { public class Saml20AutoConfiguration implements InitializingBean {
private static final Logger _logger = LoggerFactory.getLogger(Saml20AutoConfiguration.class); private static final Logger _logger = LoggerFactory.getLogger(Saml20AutoConfiguration.class);
/** /**
* samlBootstrapInitializer. * samlBootstrapInitializer.
* @return samlBootstrapInitializer * @return samlBootstrapInitializer
* @throws ConfigurationException * @throws ConfigurationException
*/ */
@Bean(name = "samlBootstrapInitializer") @Bean(name = "samlBootstrapInitializer")
public String samlBootstrapInitializer() throws ConfigurationException { String samlBootstrapInitializer() throws ConfigurationException {
org.opensaml.DefaultBootstrap.bootstrap(); org.opensaml.DefaultBootstrap.bootstrap();
return ""; return "";
} }
/** /**
* TimeService. * TimeService.
* @return timeService * @return timeService
*/ */
@Bean(name = "timeService") @Bean(name = "timeService")
public TimeService TimeService() { TimeService TimeService() {
TimeService timeService = new TimeService(); TimeService timeService = new TimeService();
return timeService; return timeService;
} }
/** /**
* IDService. * IDService.
* @return idService * @return idService
*/ */
@Bean(name = "idService") @Bean(name = "idService")
public IDService idService() { IDService idService() {
IDService idService = new IDService(); IDService idService = new IDService();
return idService; return idService;
} }
/** /**
* EndpointGenerator. * EndpointGenerator.
* @return endpointGenerator * @return endpointGenerator
*/ */
@Bean(name = "endpointGenerator") @Bean(name = "endpointGenerator")
public EndpointGenerator endpointGenerator() { EndpointGenerator endpointGenerator() {
EndpointGenerator generator = new EndpointGenerator(); EndpointGenerator generator = new EndpointGenerator();
return generator; return generator;
} }
/** /**
* AuthnResponseGenerator. * AuthnResponseGenerator.
* @return authnResponseGenerator * @return authnResponseGenerator
*/ */
@Bean(name = "authnResponseGenerator") @Bean(name = "authnResponseGenerator")
public AuthnResponseGenerator authnResponseGenerator(TimeService timeService,IDService idService, AuthnResponseGenerator authnResponseGenerator(TimeService timeService, IDService idService,
@Value("${maxkey.saml.v20.idp.issuer}") String issuerEntityName) { @Value("${maxkey.saml.v20.idp.issuer}") String issuerEntityName) {
_logger.debug("issuerEntityName {}" , issuerEntityName); _logger.debug("issuerEntityName {}" , issuerEntityName);
AuthnResponseGenerator generator = new AuthnResponseGenerator(issuerEntityName,timeService,idService); AuthnResponseGenerator generator = new AuthnResponseGenerator(issuerEntityName,timeService,idService);
return generator; return generator;
} }
/** /**
* IssuerEntityName. * IssuerEntityName.
* @return issuerEntityName * @return issuerEntityName
*/ */
@Bean(name = "issuerEntityName") @Bean(name = "issuerEntityName")
public String issuerEntityName( String issuerEntityName(
@Value("${maxkey.saml.v20.idp.issuer}") String issuerEntityName) { @Value("${maxkey.saml.v20.idp.issuer}") String issuerEntityName) {
return issuerEntityName; return issuerEntityName;
} }
/** /**
* Saml20Metadata. * Saml20Metadata.
* @return saml20Metadata * @return saml20Metadata
*/ */
@Bean(name = "saml20Metadata") @Bean(name = "saml20Metadata")
public Saml20Metadata saml20Metadata( Saml20Metadata saml20Metadata(
@Value("${maxkey.saml.v20.metadata.orgName}") String orgName, @Value("${maxkey.saml.v20.metadata.orgName}") String orgName,
@Value("${maxkey.saml.v20.metadata.orgDisplayName}") String orgDisplayName, @Value("${maxkey.saml.v20.metadata.orgDisplayName}") String orgDisplayName,
@Value("${maxkey.saml.v20.metadata.orgURL}") String orgURL, @Value("${maxkey.saml.v20.metadata.orgURL}") String orgURL,
@ -157,31 +157,31 @@ public class Saml20AutoConfiguration implements InitializingBean {
* @return samlValidaotrSuite * @return samlValidaotrSuite
*/ */
@Bean(name = "samlValidaotrSuite") @Bean(name = "samlValidaotrSuite")
public SAML2ValidatorSuite validatorSuite() { SAML2ValidatorSuite validatorSuite() {
SAML2ValidatorSuite validatorSuite = new SAML2ValidatorSuite(); SAML2ValidatorSuite validatorSuite = new SAML2ValidatorSuite();
return validatorSuite; return validatorSuite;
} }
/** /**
* MapBasedStorageService. * MapBasedStorageService.
* @return mapBasedStorageService * @return mapBasedStorageService
*/ */
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@Bean(name = "mapBasedStorageService") @Bean(name = "mapBasedStorageService")
public MapBasedStorageService mapBasedStorageService() { MapBasedStorageService mapBasedStorageService() {
MapBasedStorageService mapBasedStorageService = new MapBasedStorageService(); MapBasedStorageService mapBasedStorageService = new MapBasedStorageService();
return mapBasedStorageService; return mapBasedStorageService;
} }
/** /**
* VelocityEngineFactoryBean. * VelocityEngineFactoryBean.
* @return velocityEngine * @return velocityEngine
* @throws IOException * @throws IOException
* @throws VelocityException * @throws VelocityException
*/ */
@SuppressWarnings({ "deprecation"}) @SuppressWarnings({"deprecation"})
@Bean(name = "velocityEngine") @Bean(name = "velocityEngine")
public VelocityEngine velocityEngine() throws VelocityException, IOException { VelocityEngine velocityEngine() throws VelocityException, IOException {
VelocityEngineFactoryBean factory = new VelocityEngineFactoryBean(); VelocityEngineFactoryBean factory = new VelocityEngineFactoryBean();
factory.setPreferFileSystemAccess(false); factory.setPreferFileSystemAccess(false);
Properties velocityProperties = new Properties(); Properties velocityProperties = new Properties();
@ -191,138 +191,138 @@ public class Saml20AutoConfiguration implements InitializingBean {
factory.setVelocityProperties(velocityProperties); factory.setVelocityProperties(velocityProperties);
return factory.createVelocityEngine(); return factory.createVelocityEngine();
} }
/** /**
* ReplayCache. * ReplayCache.
* @return replayCache * @return replayCache
*/ */
@Bean(name = "replayCache") @Bean(name = "replayCache")
public ReplayCache replayCache(MapBasedStorageService<String, ReplayCacheEntry> mapBasedStorageService, ReplayCache replayCache(MapBasedStorageService<String, ReplayCacheEntry> mapBasedStorageService,
@Value("${maxkey.saml.v20.replay.cache.life.in.millis}") long duration) { @Value("${maxkey.saml.v20.replay.cache.life.in.millis}") long duration) {
ReplayCache replayCache = new ReplayCache(mapBasedStorageService,duration); ReplayCache replayCache = new ReplayCache(mapBasedStorageService,duration);
return replayCache; return replayCache;
} }
/** /**
* MessageReplayRule. * MessageReplayRule.
* @return messageReplayRule * @return messageReplayRule
*/ */
@Bean(name = "messageReplayRule") @Bean(name = "messageReplayRule")
public MessageReplayRule messageReplayRule(ReplayCache replayCache) { MessageReplayRule messageReplayRule(ReplayCache replayCache) {
MessageReplayRule messageReplayRule = new MessageReplayRule(replayCache); MessageReplayRule messageReplayRule = new MessageReplayRule(replayCache);
return messageReplayRule; return messageReplayRule;
} }
/** /**
* BasicParserPool. * BasicParserPool.
* @return samlParserPool * @return samlParserPool
*/ */
@Bean(name = "samlParserPool") @Bean(name = "samlParserPool")
public BasicParserPool samlParserPool( BasicParserPool samlParserPool(
@Value("${maxkey.saml.v20.max.parser.pool.size}") int maxPoolSize) { @Value("${maxkey.saml.v20.max.parser.pool.size}") int maxPoolSize) {
BasicParserPool samlParserPool = new BasicParserPool(); BasicParserPool samlParserPool = new BasicParserPool();
samlParserPool.setMaxPoolSize(maxPoolSize); samlParserPool.setMaxPoolSize(maxPoolSize);
return samlParserPool; return samlParserPool;
} }
/** /**
* IssueInstantRule. * IssueInstantRule.
* @return issueInstantRule * @return issueInstantRule
*/ */
@Bean(name = "issueInstantRule") @Bean(name = "issueInstantRule")
public IssueInstantRule issueInstantRule( IssueInstantRule issueInstantRule(
@Value("${maxkey.saml.v20.issue.instant.check.clock.skew.in.seconds}") int newClockSkew, @Value("${maxkey.saml.v20.issue.instant.check.clock.skew.in.seconds}") int newClockSkew,
@Value("${maxkey.saml.v20.issue.instant.check.validity.time.in.seconds}") int newExpires) { @Value("${maxkey.saml.v20.issue.instant.check.validity.time.in.seconds}") int newExpires) {
IssueInstantRule decoder = new IssueInstantRule(newClockSkew,newExpires); IssueInstantRule decoder = new IssueInstantRule(newClockSkew,newExpires);
decoder.setRequiredRule(true); decoder.setRequiredRule(true);
return decoder; return decoder;
} }
/** /**
* OpenHTTPPostSimpleSignDecoder. * OpenHTTPPostSimpleSignDecoder.
* @return openHTTPPostSimpleSignDecoder * @return openHTTPPostSimpleSignDecoder
*/ */
@Bean(name = "openHTTPPostSimpleSignDecoder") @Bean(name = "openHTTPPostSimpleSignDecoder")
public OpenHTTPPostSimpleSignDecoder openHTTPPostSimpleSignDecoder(BasicParserPool samlParserPool, OpenHTTPPostSimpleSignDecoder openHTTPPostSimpleSignDecoder(BasicParserPool samlParserPool,
@Value("${maxkey.saml.v20.idp.receiver.endpoint}") String receiverEndpoint) { @Value("${maxkey.saml.v20.idp.receiver.endpoint}") String receiverEndpoint) {
OpenHTTPPostSimpleSignDecoder decoder = new OpenHTTPPostSimpleSignDecoder(samlParserPool); OpenHTTPPostSimpleSignDecoder decoder = new OpenHTTPPostSimpleSignDecoder(samlParserPool);
decoder.setReceiverEndpoint(receiverEndpoint); decoder.setReceiverEndpoint(receiverEndpoint);
return decoder; return decoder;
} }
/** /**
* OpenHTTPPostDecoder. * OpenHTTPPostDecoder.
* @return openHTTPPostDecoder * @return openHTTPPostDecoder
*/ */
@Bean(name = "openHTTPPostDecoder") @Bean(name = "openHTTPPostDecoder")
public OpenHTTPPostDecoder openHTTPPostDecoder(BasicParserPool samlParserPool, OpenHTTPPostDecoder openHTTPPostDecoder(BasicParserPool samlParserPool,
@Value("${maxkey.saml.v20.idp.receiver.endpoint}") String receiverEndpoint) { @Value("${maxkey.saml.v20.idp.receiver.endpoint}") String receiverEndpoint) {
OpenHTTPPostDecoder decoder = new OpenHTTPPostDecoder(samlParserPool); OpenHTTPPostDecoder decoder = new OpenHTTPPostDecoder(samlParserPool);
decoder.setReceiverEndpoint(receiverEndpoint); decoder.setReceiverEndpoint(receiverEndpoint);
return decoder; return decoder;
} }
/** /**
* OpenHTTPRedirectDecoder. * OpenHTTPRedirectDecoder.
* @return openHTTPRedirectDecoder * @return openHTTPRedirectDecoder
*/ */
@Bean(name = "openHTTPRedirectDecoder") @Bean(name = "openHTTPRedirectDecoder")
public OpenHTTPRedirectDecoder openHTTPRedirectDecoder(BasicParserPool samlParserPool, OpenHTTPRedirectDecoder openHTTPRedirectDecoder(BasicParserPool samlParserPool,
@Value("${maxkey.saml.v20.idp.receiver.endpoint}") String receiverEndpoint) { @Value("${maxkey.saml.v20.idp.receiver.endpoint}") String receiverEndpoint) {
OpenHTTPRedirectDecoder decoder = new OpenHTTPRedirectDecoder(samlParserPool); OpenHTTPRedirectDecoder decoder = new OpenHTTPRedirectDecoder(samlParserPool);
decoder.setReceiverEndpoint(receiverEndpoint); decoder.setReceiverEndpoint(receiverEndpoint);
return decoder; return decoder;
} }
/** /**
* ExtractPostBindingAdapter. * ExtractPostBindingAdapter.
* @return extractPostBindingAdapter * @return extractPostBindingAdapter
*/ */
@Bean(name = "extractPostBindingAdapter") @Bean(name = "extractPostBindingAdapter")
public ExtractPostBindingAdapter extractPostBindingAdapter(OpenHTTPPostDecoder openHTTPPostDecoder, ExtractPostBindingAdapter extractPostBindingAdapter(OpenHTTPPostDecoder openHTTPPostDecoder,
@Qualifier("keyStoreLoader") KeyStoreLoader keyStoreLoader,IssueInstantRule issueInstantRule,MessageReplayRule messageReplayRule) { @Qualifier("keyStoreLoader") KeyStoreLoader keyStoreLoader, IssueInstantRule issueInstantRule, MessageReplayRule messageReplayRule) {
ExtractPostBindingAdapter adapter = new ExtractPostBindingAdapter(openHTTPPostDecoder); ExtractPostBindingAdapter adapter = new ExtractPostBindingAdapter(openHTTPPostDecoder);
adapter.setIssueInstantRule(issueInstantRule); adapter.setIssueInstantRule(issueInstantRule);
adapter.setKeyStoreLoader(keyStoreLoader); adapter.setKeyStoreLoader(keyStoreLoader);
adapter.setMessageReplayRule(messageReplayRule); adapter.setMessageReplayRule(messageReplayRule);
return adapter; return adapter;
} }
/** /**
* ExtractRedirectBindingAdapter. * ExtractRedirectBindingAdapter.
* @return extractRedirectBindingAdapter * @return extractRedirectBindingAdapter
*/ */
@Bean(name = "extractRedirectBindingAdapter") @Bean(name = "extractRedirectBindingAdapter")
public ExtractRedirectBindingAdapter extractRedirectBindingAdapter(OpenHTTPRedirectDecoder openHTTPRedirectDecoder, ExtractRedirectBindingAdapter extractRedirectBindingAdapter(OpenHTTPRedirectDecoder openHTTPRedirectDecoder,
@Qualifier("keyStoreLoader") KeyStoreLoader keyStoreLoader,IssueInstantRule issueInstantRule,MessageReplayRule messageReplayRule) { @Qualifier("keyStoreLoader") KeyStoreLoader keyStoreLoader, IssueInstantRule issueInstantRule, MessageReplayRule messageReplayRule) {
ExtractRedirectBindingAdapter adapter = new ExtractRedirectBindingAdapter(openHTTPRedirectDecoder); ExtractRedirectBindingAdapter adapter = new ExtractRedirectBindingAdapter(openHTTPRedirectDecoder);
adapter.setIssueInstantRule(issueInstantRule); adapter.setIssueInstantRule(issueInstantRule);
adapter.setKeyStoreLoader(keyStoreLoader); adapter.setKeyStoreLoader(keyStoreLoader);
adapter.setMessageReplayRule(messageReplayRule); adapter.setMessageReplayRule(messageReplayRule);
return adapter; return adapter;
} }
/** /**
* PostSimpleSignBindingAdapter. * PostSimpleSignBindingAdapter.
* @return postSimpleSignBindingAdapter * @return postSimpleSignBindingAdapter
*/ */
@Bean(name = "postSimpleSignBindingAdapter") @Bean(name = "postSimpleSignBindingAdapter")
public PostSimpleSignBindingAdapter postSimpleSignBindingAdapter(VelocityEngine velocityEngine, PostSimpleSignBindingAdapter postSimpleSignBindingAdapter(VelocityEngine velocityEngine,
@Value("${maxkey.saml.v20.idp.issuer}") String issuerEntityName) { @Value("${maxkey.saml.v20.idp.issuer}") String issuerEntityName) {
PostSimpleSignBindingAdapter adapter = new PostSimpleSignBindingAdapter(); PostSimpleSignBindingAdapter adapter = new PostSimpleSignBindingAdapter();
adapter.setVelocityEngine(velocityEngine); adapter.setVelocityEngine(velocityEngine);
adapter.setIssuerEntityName(issuerEntityName); adapter.setIssuerEntityName(issuerEntityName);
return adapter; return adapter;
} }
/** /**
* PostBindingAdapter. * PostBindingAdapter.
* @return postBindingAdapter * @return postBindingAdapter
*/ */
@Bean(name = "postBindingAdapter") @Bean(name = "postBindingAdapter")
public PostBindingAdapter postBindingAdapter(VelocityEngine velocityEngine, PostBindingAdapter postBindingAdapter(VelocityEngine velocityEngine,
@Value("${maxkey.saml.v20.idp.issuer}") String issuerEntityName) { @Value("${maxkey.saml.v20.idp.issuer}") String issuerEntityName) {
PostBindingAdapter adapter = new PostBindingAdapter(); PostBindingAdapter adapter = new PostBindingAdapter();
adapter.setVelocityEngine(velocityEngine); adapter.setVelocityEngine(velocityEngine);
adapter.setIssuerEntityName(issuerEntityName); adapter.setIssuerEntityName(issuerEntityName);

View File

@ -121,7 +121,7 @@ public class IpLocationAutoConfiguration {
* @throws Exception * @throws Exception
*/ */
@Bean @Bean
public IpLocationParser ipLocationParser( IpLocationParser ipLocationParser(
@Value("${maxkey.login.iplocation:true}") boolean isIplocation, @Value("${maxkey.login.iplocation:true}") boolean isIplocation,
@Value("${maxkey.login.iplocation.online.provider:none}") String onlineProvider, @Value("${maxkey.login.iplocation.online.provider:none}") String onlineProvider,
@Value("${maxkey.login.iplocation.offline.provider:Ip2Region}") String offlineProvider) throws Exception { @Value("${maxkey.login.iplocation.offline.provider:Ip2Region}") String offlineProvider) throws Exception {

View File

@ -33,10 +33,10 @@ import org.springframework.context.annotation.Bean;
public class OneTimePasswordAutoConfiguration { public class OneTimePasswordAutoConfiguration {
private static final Logger _logger = private static final Logger _logger =
LoggerFactory.getLogger(OneTimePasswordAutoConfiguration.class); LoggerFactory.getLogger(OneTimePasswordAutoConfiguration.class);
@Bean(name = "mailOtpAuthnService") @Bean(name = "mailOtpAuthnService")
public MailOtpAuthnService mailOtpAuthnService( MailOtpAuthnService mailOtpAuthnService(
@Value("${maxkey.server.persistence}") int persistence, @Value("${maxkey.server.persistence}") int persistence,
CnfEmailSendersService emailSendersService, CnfEmailSendersService emailSendersService,
RedisConnectionFactory redisConnFactory) { RedisConnectionFactory redisConnFactory) {

View File

@ -33,10 +33,10 @@ import org.springframework.context.annotation.Bean;
@AutoConfiguration @AutoConfiguration
public class SmsAutoConfiguration { public class SmsAutoConfiguration {
private static final Logger _logger = LoggerFactory.getLogger(SmsAutoConfiguration.class); private static final Logger _logger = LoggerFactory.getLogger(SmsAutoConfiguration.class);
@Bean(name = "smsOtpAuthnService") @Bean(name = "smsOtpAuthnService")
public SmsOtpAuthnService smsOtpAuthnService( SmsOtpAuthnService smsOtpAuthnService(
@Value("${maxkey.server.persistence}") int persistence, @Value("${maxkey.server.persistence}") int persistence,
CnfSmsProviderService smsProviderService, CnfSmsProviderService smsProviderService,
CnfEmailSendersService emailSendersService, CnfEmailSendersService emailSendersService,

View File

@ -58,27 +58,27 @@ public class ApplicationAutoConfiguration {
static final Logger _logger = LoggerFactory.getLogger(ApplicationAutoConfiguration.class); static final Logger _logger = LoggerFactory.getLogger(ApplicationAutoConfiguration.class);
@Bean @Bean
public PasswordReciprocal passwordReciprocal() { PasswordReciprocal passwordReciprocal() {
return new PasswordReciprocal(); return new PasswordReciprocal();
} }
@Bean @Bean
public DataSourceTransactionManager transactionManager(DataSource dataSource) { DataSourceTransactionManager transactionManager(DataSource dataSource) {
return new DataSourceTransactionManager(dataSource); return new DataSourceTransactionManager(dataSource);
} }
@Bean @Bean
public InstitutionsRepository institutionsRepository(JdbcTemplate jdbcTemplate) { InstitutionsRepository institutionsRepository(JdbcTemplate jdbcTemplate) {
return new InstitutionsRepository(jdbcTemplate); return new InstitutionsRepository(jdbcTemplate);
} }
/** /**
* Authentication Password Encoder . * Authentication Password Encoder .
* @return * @return
*/ */
@Bean @Bean
public PasswordEncoder passwordEncoder( PasswordEncoder passwordEncoder(
@Value("${maxkey.crypto.password.encoder:bcrypt}") String idForEncode) { @Value("${maxkey.crypto.password.encoder:bcrypt}") String idForEncode) {
Map<String ,PasswordEncoder > encoders = new HashMap<>(); Map<String ,PasswordEncoder > encoders = new HashMap<>();
encoders.put("bcrypt", new BCryptPasswordEncoder()); encoders.put("bcrypt", new BCryptPasswordEncoder());
encoders.put("plain", NoOpPasswordEncoder.getInstance()); encoders.put("plain", NoOpPasswordEncoder.getInstance());
@ -111,13 +111,13 @@ public class ApplicationAutoConfiguration {
return passwordEncoder; return passwordEncoder;
} }
/** /**
* keyStoreLoader . * keyStoreLoader .
* @return * @return
*/ */
@Bean @Bean
public KeyStoreLoader keyStoreLoader( KeyStoreLoader keyStoreLoader(
@Value("${maxkey.saml.v20.idp.issuing.entity.id}") String entityName, @Value("${maxkey.saml.v20.idp.issuing.entity.id}") String entityName,
@Value("${maxkey.saml.v20.idp.keystore.password}") String keystorePassword, @Value("${maxkey.saml.v20.idp.keystore.password}") String keystorePassword,
@Value("${maxkey.saml.v20.idp.keystore}") Resource keystoreFile) { @Value("${maxkey.saml.v20.idp.keystore}") Resource keystoreFile) {
@ -127,13 +127,13 @@ public class ApplicationAutoConfiguration {
keyStoreLoader.setKeystoreFile(keystoreFile); keyStoreLoader.setKeystoreFile(keystoreFile);
return keyStoreLoader; return keyStoreLoader;
} }
/** /**
* spKeyStoreLoader . * spKeyStoreLoader .
* @return * @return
*/ */
@Bean @Bean
public KeyStoreLoader serviceProviderKeyStoreLoader( KeyStoreLoader serviceProviderKeyStoreLoader(
@Value("${maxkey.saml.v20.sp.issuing.entity.id}") String entityName, @Value("${maxkey.saml.v20.sp.issuing.entity.id}") String entityName,
@Value("${maxkey.saml.v20.sp.keystore.password}") String keystorePassword, @Value("${maxkey.saml.v20.sp.keystore.password}") String keystorePassword,
@Value("${maxkey.saml.v20.sp.keystore}") Resource keystoreFile) { @Value("${maxkey.saml.v20.sp.keystore}") Resource keystoreFile) {
@ -143,23 +143,23 @@ public class ApplicationAutoConfiguration {
keyStoreLoader.setKeystoreFile(keystoreFile); keyStoreLoader.setKeystoreFile(keystoreFile);
return keyStoreLoader; return keyStoreLoader;
} }
/** /**
* spKeyStoreLoader . * spKeyStoreLoader .
* @return * @return
*/ */
@Bean @Bean
public String spIssuingEntityName( String spIssuingEntityName(
@Value("${maxkey.saml.v20.sp.issuing.entity.id}") String spIssuingEntityName) { @Value("${maxkey.saml.v20.sp.issuing.entity.id}") String spIssuingEntityName) {
return spIssuingEntityName; return spIssuingEntityName;
} }
/** /**
* Id Generator . * Id Generator .
* @return * @return
*/ */
@Bean @Bean
public IdGenerator idGenerator( IdGenerator idGenerator(
@Value("${maxkey.id.strategy:SnowFlake}") String strategy, @Value("${maxkey.id.strategy:SnowFlake}") String strategy,
@Value("${maxkey.id.datacenterId:0}") int datacenterId, @Value("${maxkey.id.datacenterId:0}") int datacenterId,
@Value("${maxkey.id.machineId:0}") int machineId) { @Value("${maxkey.id.machineId:0}") int machineId) {
@ -170,11 +170,11 @@ public class ApplicationAutoConfiguration {
return idGenerator; return idGenerator;
} }
@Bean @Bean
public MomentaryService momentaryService( MomentaryService momentaryService(
RedisConnectionFactory redisConnFactory, RedisConnectionFactory redisConnFactory,
@Value("${maxkey.server.persistence}") int persistence) { @Value("${maxkey.server.persistence}") int persistence) {
MomentaryService momentaryService; MomentaryService momentaryService;
if (persistence == ConstsPersistence.REDIS) { if (persistence == ConstsPersistence.REDIS) {
momentaryService = new RedisMomentaryService(redisConnFactory); momentaryService = new RedisMomentaryService(redisConnFactory);

View File

@ -73,14 +73,14 @@ public class MvcAutoConfiguration implements WebMvcConfigurer {
@Value("${spring.jackson.date-format:yyyy-MM-dd HH:mm:ss}") @Value("${spring.jackson.date-format:yyyy-MM-dd HH:mm:ss}")
private String pattern; private String pattern;
/** /**
* 消息处理可以直接使用properties的key值返回的是对应的value值 * 消息处理可以直接使用properties的key值返回的是对应的value值
* messageSource . * messageSource .
* @return messageSource * @return messageSource
*/ */
@Bean (name = "messageSource") @Bean(name = "messageSource")
public ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource( ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource(
@Value("${spring.messages.basename:classpath:messages/message}") @Value("${spring.messages.basename:classpath:messages/message}")
String messagesBasename) { String messagesBasename) {
_logger.debug("Basename {}" , messagesBasename); _logger.debug("Basename {}" , messagesBasename);
@ -91,48 +91,48 @@ public class MvcAutoConfiguration implements WebMvcConfigurer {
messageSource.setUseCodeAsDefaultMessage(false); messageSource.setUseCodeAsDefaultMessage(false);
return messageSource; return messageSource;
} }
/** /**
* Locale Change Interceptor and Resolver definition . * Locale Change Interceptor and Resolver definition .
* @return localeChangeInterceptor * @return localeChangeInterceptor
*/ */
//@Primary //@Primary
@Bean (name = "localeChangeInterceptor") @Bean(name = "localeChangeInterceptor")
public LocaleChangeInterceptor localeChangeInterceptor() { LocaleChangeInterceptor localeChangeInterceptor() {
LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor(); LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
localeChangeInterceptor.setParamName("language"); localeChangeInterceptor.setParamName("language");
return localeChangeInterceptor; return localeChangeInterceptor;
} }
/** /**
* handlerMapping . * handlerMapping .
* @return handlerMapping * @return handlerMapping
*/ */
@Bean (name = "handlerMapping") @Bean(name = "handlerMapping")
public RequestMappingHandlerMapping requestMappingHandlerMapping( RequestMappingHandlerMapping requestMappingHandlerMapping(
LocaleChangeInterceptor localeChangeInterceptor) { LocaleChangeInterceptor localeChangeInterceptor) {
RequestMappingHandlerMapping requestMappingHandlerMapping = new RequestMappingHandlerMapping(); RequestMappingHandlerMapping requestMappingHandlerMapping = new RequestMappingHandlerMapping();
requestMappingHandlerMapping.setInterceptors(localeChangeInterceptor); requestMappingHandlerMapping.setInterceptors(localeChangeInterceptor);
return requestMappingHandlerMapping; return requestMappingHandlerMapping;
} }
/** /**
* jaxb2Marshaller . * jaxb2Marshaller .
* @return jaxb2Marshaller * @return jaxb2Marshaller
*/ */
@Bean (name = "jaxb2Marshaller") @Bean(name = "jaxb2Marshaller")
public Jaxb2Marshaller jaxb2Marshaller() { Jaxb2Marshaller jaxb2Marshaller() {
Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller(); Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
jaxb2Marshaller.setClassesToBeBound(org.dromara.maxkey.entity.xml.UserInfoXML.class);; jaxb2Marshaller.setClassesToBeBound(org.dromara.maxkey.entity.xml.UserInfoXML.class);;
return jaxb2Marshaller; return jaxb2Marshaller;
} }
/** /**
* marshallingHttpMessageConverter . * marshallingHttpMessageConverter .
* @return marshallingHttpMessageConverter * @return marshallingHttpMessageConverter
*/ */
@Bean (name = "marshallingHttpMessageConverter") @Bean(name = "marshallingHttpMessageConverter")
public MarshallingHttpMessageConverter marshallingHttpMessageConverter( MarshallingHttpMessageConverter marshallingHttpMessageConverter(
Jaxb2Marshaller jaxb2Marshaller) { Jaxb2Marshaller jaxb2Marshaller) {
MarshallingHttpMessageConverter marshallingHttpMessageConverter = new MarshallingHttpMessageConverter(); MarshallingHttpMessageConverter marshallingHttpMessageConverter = new MarshallingHttpMessageConverter();
marshallingHttpMessageConverter.setMarshaller(jaxb2Marshaller); marshallingHttpMessageConverter.setMarshaller(jaxb2Marshaller);
@ -145,13 +145,13 @@ public class MvcAutoConfiguration implements WebMvcConfigurer {
marshallingHttpMessageConverter.setSupportedMediaTypes(mediaTypesList); marshallingHttpMessageConverter.setSupportedMediaTypes(mediaTypesList);
return marshallingHttpMessageConverter; return marshallingHttpMessageConverter;
} }
/** /**
* mappingJacksonHttpMessageConverter . * mappingJacksonHttpMessageConverter .
* @return mappingJacksonHttpMessageConverter * @return mappingJacksonHttpMessageConverter
*/ */
@Bean (name = "mappingJacksonHttpMessageConverter") @Bean(name = "mappingJacksonHttpMessageConverter")
public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() { MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter = new MappingJackson2HttpMessageConverter(); MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter = new MappingJackson2HttpMessageConverter();
ArrayList<MediaType> mediaTypesList = new ArrayList<>(); ArrayList<MediaType> mediaTypesList = new ArrayList<>();
mediaTypesList.add(MediaType.APPLICATION_JSON); mediaTypesList.add(MediaType.APPLICATION_JSON);
@ -169,32 +169,32 @@ public class MvcAutoConfiguration implements WebMvcConfigurer {
mappingJacksonHttpMessageConverter.setObjectMapper(objectMapper); mappingJacksonHttpMessageConverter.setObjectMapper(objectMapper);
return mappingJacksonHttpMessageConverter; return mappingJacksonHttpMessageConverter;
} }
/** /**
* cookieLocaleResolver . * cookieLocaleResolver .
* @return cookieLocaleResolver * @return cookieLocaleResolver
*/ */
@Bean(name = "cookieLocaleResolver") @Bean(name = "cookieLocaleResolver")
public LocaleResolver cookieLocaleResolver( LocaleResolver cookieLocaleResolver(
@Value("${maxkey.server.domain:maxkey.top}") @Value("${maxkey.server.domain:maxkey.top}")
String domainName String domainName
) { ) {
_logger.debug("DomainName {}" , domainName); _logger.debug("DomainName {}" , domainName);
CookieLocaleResolver cookieLocaleResolver = new CookieLocaleResolver("mxk_locale"); CookieLocaleResolver cookieLocaleResolver = new CookieLocaleResolver("mxk_locale");
cookieLocaleResolver.setCookieDomain(domainName); cookieLocaleResolver.setCookieDomain(domainName);
cookieLocaleResolver.setCookieMaxAge(Duration.ofDays(14)); cookieLocaleResolver.setCookieMaxAge(Duration.ofDays(14));
return cookieLocaleResolver; return cookieLocaleResolver;
} }
/** /**
* AnnotationMethodHandlerAdapter * AnnotationMethodHandlerAdapter
* requestMappingHandlerAdapter . * requestMappingHandlerAdapter .
* @return requestMappingHandlerAdapter * @return requestMappingHandlerAdapter
*/ */
@Bean (name = "addConverterRequestMappingHandlerAdapter") @Bean(name = "addConverterRequestMappingHandlerAdapter")
public RequestMappingHandlerAdapter requestMappingHandlerAdapter( RequestMappingHandlerAdapter requestMappingHandlerAdapter(
@Qualifier("mappingJacksonHttpMessageConverter") @Qualifier("mappingJacksonHttpMessageConverter")
MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter, MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter,
MarshallingHttpMessageConverter marshallingHttpMessageConverter, MarshallingHttpMessageConverter marshallingHttpMessageConverter,
StringHttpMessageConverter stringHttpMessageConverter, StringHttpMessageConverter stringHttpMessageConverter,
@ -212,14 +212,14 @@ public class MvcAutoConfiguration implements WebMvcConfigurer {
requestMappingHandlerAdapter.setMessageConverters(httpMessageConverterList); requestMappingHandlerAdapter.setMessageConverters(httpMessageConverterList);
return requestMappingHandlerAdapter; return requestMappingHandlerAdapter;
} }
/** /**
* restTemplate . * restTemplate .
* @return restTemplate * @return restTemplate
*/ */
@Bean (name = "restTemplate") @Bean(name = "restTemplate")
public RestTemplate restTemplate( RestTemplate restTemplate(
@Qualifier("mappingJacksonHttpMessageConverter") @Qualifier("mappingJacksonHttpMessageConverter")
MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter, MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter,
MarshallingHttpMessageConverter marshallingHttpMessageConverter) { MarshallingHttpMessageConverter marshallingHttpMessageConverter) {
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
@ -236,7 +236,7 @@ public class MvcAutoConfiguration implements WebMvcConfigurer {
* @return webServerFactoryCustomizer * @return webServerFactoryCustomizer
*/ */
@Bean @Bean
public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer() { WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer() {
return new WebServerFactoryCustomizer<ConfigurableWebServerFactory>() { return new WebServerFactoryCustomizer<ConfigurableWebServerFactory>() {
@Override @Override
public void customize(ConfigurableWebServerFactory factory) { public void customize(ConfigurableWebServerFactory factory) {
@ -251,15 +251,15 @@ public class MvcAutoConfiguration implements WebMvcConfigurer {
} }
}; };
} }
@Bean @Bean
public SecurityContextHolderAwareRequestFilter securityContextHolderAwareRequestFilter() { SecurityContextHolderAwareRequestFilter securityContextHolderAwareRequestFilter() {
_logger.debug("securityContextHolderAwareRequestFilter init "); _logger.debug("securityContextHolderAwareRequestFilter init ");
return new SecurityContextHolderAwareRequestFilter(); return new SecurityContextHolderAwareRequestFilter();
} }
@Bean @Bean
public FilterRegistrationBean<CorsFilter> corsFilter() { FilterRegistrationBean<CorsFilter> corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration corsConfiguration = new CorsConfiguration(); CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.setAllowCredentials(true); corsConfiguration.setAllowCredentials(true);
@ -273,9 +273,9 @@ public class MvcAutoConfiguration implements WebMvcConfigurer {
bean.addUrlPatterns("/*"); bean.addUrlPatterns("/*");
return bean; return bean;
} }
@Bean @Bean
public FilterRegistrationBean<Filter> delegatingFilterProxy() { FilterRegistrationBean<Filter> delegatingFilterProxy() {
_logger.debug("delegatingFilterProxy init for /* "); _logger.debug("delegatingFilterProxy init for /* ");
FilterRegistrationBean<Filter> registrationBean = new FilterRegistrationBean<>(); FilterRegistrationBean<Filter> registrationBean = new FilterRegistrationBean<>();
registrationBean.setFilter(new DelegatingFilterProxy("securityContextHolderAwareRequestFilter")); registrationBean.setFilter(new DelegatingFilterProxy("securityContextHolderAwareRequestFilter"));
@ -286,9 +286,9 @@ public class MvcAutoConfiguration implements WebMvcConfigurer {
return registrationBean; return registrationBean;
} }
@Bean @Bean
public FilterRegistrationBean<Filter> webXssRequestFilter() { FilterRegistrationBean<Filter> webXssRequestFilter() {
_logger.debug("webXssRequestFilter init for /* "); _logger.debug("webXssRequestFilter init for /* ");
FilterRegistrationBean<Filter> registrationBean = new FilterRegistrationBean<>(new WebXssRequestFilter()); FilterRegistrationBean<Filter> registrationBean = new FilterRegistrationBean<>(new WebXssRequestFilter());
registrationBean.addUrlPatterns("/*"); registrationBean.addUrlPatterns("/*");
@ -296,11 +296,11 @@ public class MvcAutoConfiguration implements WebMvcConfigurer {
registrationBean.setOrder(3); registrationBean.setOrder(3);
return registrationBean; return registrationBean;
} }
@Bean @Bean
public FilterRegistrationBean<Filter> webInstRequestFilter( FilterRegistrationBean<Filter> webInstRequestFilter(
InstitutionsRepository institutionsRepository, InstitutionsRepository institutionsRepository,
ApplicationConfig applicationConfig) { ApplicationConfig applicationConfig) {
_logger.debug("WebInstRequestFilter init for /* "); _logger.debug("WebInstRequestFilter init for /* ");
FilterRegistrationBean<Filter> registrationBean = FilterRegistrationBean<Filter> registrationBean =
new FilterRegistrationBean<>(new WebInstRequestFilter(institutionsRepository,applicationConfig)); new FilterRegistrationBean<>(new WebInstRequestFilter(institutionsRepository,applicationConfig));

View File

@ -28,7 +28,7 @@ import redis.clients.jedis.JedisPoolConfig;
@AutoConfiguration @AutoConfiguration
public class RedisAutoConfiguration { public class RedisAutoConfiguration {
static final Logger _logger = LoggerFactory.getLogger(RedisAutoConfiguration.class); static final Logger _logger = LoggerFactory.getLogger(RedisAutoConfiguration.class);
/** /**
* RedisConnectionFactory. * RedisConnectionFactory.
* @param host String * @param host String
@ -42,7 +42,7 @@ public class RedisAutoConfiguration {
* @return RedisConnectionFactory * @return RedisConnectionFactory
*/ */
@Bean @Bean
public RedisConnectionFactory redisConnFactory( RedisConnectionFactory redisConnFactory(
@Value("${spring.redis.host}") @Value("${spring.redis.host}")
String host, String host,
@Value("${spring.redis.port:6379}") @Value("${spring.redis.port:6379}")

View File

@ -33,7 +33,7 @@ public class SwaggerAutoConfiguration {
boolean enable; boolean enable;
@Bean @Bean
public GlobalOpenApiCustomizer orderGlobalOpenApiCustomizer() { GlobalOpenApiCustomizer orderGlobalOpenApiCustomizer() {
return openApi -> { return openApi -> {
if (openApi.getTags()!=null){ if (openApi.getTags()!=null){
openApi.getTags().forEach(tag -> { openApi.getTags().forEach(tag -> {
@ -49,9 +49,9 @@ public class SwaggerAutoConfiguration {
}; };
} }
@Bean @Bean
public GroupedOpenApi userApi(){ GroupedOpenApi userApi(){
String[] paths = { String[] paths = {
"/login", "/login",
"/logout", "/logout",
@ -70,9 +70,9 @@ public class SwaggerAutoConfiguration {
.pathsToMatch(paths) .pathsToMatch(paths)
.packagesToScan(packagedToMatch).build(); .packagesToScan(packagedToMatch).build();
} }
@Bean @Bean
public OpenAPI docOpenAPI() { OpenAPI docOpenAPI() {
return new OpenAPI() return new OpenAPI()
.info( .info(
new Info() new Info()

View File

@ -47,13 +47,13 @@ import org.springframework.scheduling.quartz.SchedulerFactoryBean;
public class SynchronizerAutoConfiguration implements InitializingBean { public class SynchronizerAutoConfiguration implements InitializingBean {
private static final Logger _logger = LoggerFactory.getLogger(SynchronizerAutoConfiguration.class); private static final Logger _logger = LoggerFactory.getLogger(SynchronizerAutoConfiguration.class);
public static final String SYNCHRONIZERS_SELECT_STATEMENT = "select * from mxk_synchronizers where status ='1'"; public static final String SYNCHRONIZERS_SELECT_STATEMENT = "select * from mxk_synchronizers where status ='1'";
@Bean(name = "schedulerSynchronizerJobs") @Bean(name = "schedulerSynchronizerJobs")
public String schedulerSynchronizerJobs( String schedulerSynchronizerJobs(
JdbcTemplate jdbcTemplate, JdbcTemplate jdbcTemplate,
SchedulerFactoryBean schedulerFactoryBean, SchedulerFactoryBean schedulerFactoryBean,
@Value("${maxkey.job.cron.enable}") boolean jobCronEnable @Value("${maxkey.job.cron.enable}") boolean jobCronEnable
) throws SchedulerException { ) throws SchedulerException {
Scheduler scheduler = schedulerFactoryBean.getScheduler(); Scheduler scheduler = schedulerFactoryBean.getScheduler();
if(jobCronEnable) { if(jobCronEnable) {

View File

@ -76,10 +76,10 @@ import org.springframework.security.crypto.password.PasswordEncoder;
}) })
public class MaxKeyConfig { public class MaxKeyConfig {
private static final Logger logger = LoggerFactory.getLogger(MaxKeyConfig.class); private static final Logger logger = LoggerFactory.getLogger(MaxKeyConfig.class);
@Bean @Bean
public OtpKeyUriFormat otpKeyUriFormat( OtpKeyUriFormat otpKeyUriFormat(
@Value("${maxkey.otp.policy.type:totp}") @Value("${maxkey.otp.policy.type:totp}")
String type, String type,
@Value("${maxkey.otp.policy.domain:MaxKey.top}") @Value("${maxkey.otp.policy.domain:MaxKey.top}")
@ -95,16 +95,16 @@ public class MaxKeyConfig {
logger.debug("OTP KeyUri Format {}" , otpKeyUriFormat); logger.debug("OTP KeyUri Format {}" , otpKeyUriFormat);
return otpKeyUriFormat; return otpKeyUriFormat;
} }
//可以在此实现其他的登陆认证方式请实现AbstractAuthenticationRealm //可以在此实现其他的登陆认证方式请实现AbstractAuthenticationRealm
@Bean @Bean
public JdbcAuthenticationRealm authenticationRealm( JdbcAuthenticationRealm authenticationRealm(
@Qualifier("passwordEncoder") PasswordEncoder passwordEncoder, @Qualifier("passwordEncoder") PasswordEncoder passwordEncoder,
PasswordPolicyValidator passwordPolicyValidator, PasswordPolicyValidator passwordPolicyValidator,
LoginRepository loginService, LoginRepository loginService,
LoginHistoryRepository loginHistoryService, LoginHistoryRepository loginHistoryService,
UserInfoService userInfoService, UserInfoService userInfoService,
IpLocationParser ipLocationParser, IpLocationParser ipLocationParser,
JdbcTemplate jdbcTemplate, JdbcTemplate jdbcTemplate,
MailOtpAuthnService otpAuthnService, MailOtpAuthnService otpAuthnService,
CnfLdapContextService ldapContextService) { CnfLdapContextService ldapContextService) {
@ -120,9 +120,9 @@ public class MaxKeyConfig {
ldapRealmService ldapRealmService
); );
} }
@Bean @Bean
public TimeBasedOtpAuthn timeBasedOtpAuthn( TimeBasedOtpAuthn timeBasedOtpAuthn(
@Value("${maxkey.otp.policy.digits:6}") @Value("${maxkey.otp.policy.digits:6}")
int digits, int digits,
@Value("${maxkey.otp.policy.period:30}") @Value("${maxkey.otp.policy.period:30}")
@ -131,10 +131,10 @@ public class MaxKeyConfig {
logger.debug("TimeBasedOtpAuthn inited."); logger.debug("TimeBasedOtpAuthn inited.");
return tfaOtpAuthn; return tfaOtpAuthn;
} }
@Bean @Bean
public AbstractOtpAuthn tfaOtpAuthn( AbstractOtpAuthn tfaOtpAuthn(
@Value("${maxkey.login.mfa.type}")String mfaType, @Value("${maxkey.login.mfa.type}") String mfaType,
@Value("${maxkey.otp.policy.digits:6}") @Value("${maxkey.otp.policy.digits:6}")
int digits, int digits,
@Value("${maxkey.otp.policy.period:30}") @Value("${maxkey.otp.policy.period:30}")
@ -152,9 +152,9 @@ public class MaxKeyConfig {
tfaOtpAuthn.initPropertys(); tfaOtpAuthn.initPropertys();
return tfaOtpAuthn; return tfaOtpAuthn;
} }
@Bean @Bean
public MailOtpAuthn mailOtpAuthn( MailOtpAuthn mailOtpAuthn(
EmailConfig emailConfig, EmailConfig emailConfig,
@Value("${spring.mail.properties.mailotp.message.subject}") @Value("${spring.mail.properties.mailotp.message.subject}")
String messageSubject, String messageSubject,
@ -164,7 +164,7 @@ public class MaxKeyConfig {
int messageValidity, int messageValidity,
@Value("${spring.mail.properties.mailotp.message.type}") @Value("${spring.mail.properties.mailotp.message.type}")
String messageType String messageType
) { ) {
if(messageType!= null && messageType.equalsIgnoreCase("html")) { if(messageType!= null && messageType.equalsIgnoreCase("html")) {
Resource resource = new ClassPathResource("messages/email/forgotpassword.html"); Resource resource = new ClassPathResource("messages/email/forgotpassword.html");
try { try {
@ -184,10 +184,10 @@ public class MaxKeyConfig {
logger.debug("MailOtpAuthn inited."); logger.debug("MailOtpAuthn inited.");
return mailOtpAuthn; return mailOtpAuthn;
} }
@Bean @Bean
public RemoteKerberosService kerberosService( RemoteKerberosService kerberosService(
@Value("${maxkey.login.kerberos.default.userdomain}") @Value("${maxkey.login.kerberos.default.userdomain}")
String userDomain, String userDomain,
@Value("${maxkey.login.kerberos.default.fulluserdomain}") @Value("${maxkey.login.kerberos.default.fulluserdomain}")
@ -196,7 +196,7 @@ public class MaxKeyConfig {
String crypto, String crypto,
@Value("${maxkey.login.kerberos.default.redirecturi}") @Value("${maxkey.login.kerberos.default.redirecturi}")
String redirectUri String redirectUri
) { ) {
RemoteKerberosService kerberosService = new RemoteKerberosService(); RemoteKerberosService kerberosService = new RemoteKerberosService();
KerberosProxy kerberosProxy = new KerberosProxy(); KerberosProxy kerberosProxy = new KerberosProxy();

View File

@ -36,18 +36,18 @@ import org.springframework.security.crypto.password.PasswordEncoder;
@AutoConfiguration @AutoConfiguration
public class MaxKeyMgtConfig { public class MaxKeyMgtConfig {
private static final Logger logger = LoggerFactory.getLogger(MaxKeyMgtConfig.class); private static final Logger logger = LoggerFactory.getLogger(MaxKeyMgtConfig.class);
//authenticationRealm for MaxKeyMgtApplication //authenticationRealm for MaxKeyMgtApplication
@Bean @Bean
public JdbcAuthenticationRealm authenticationRealm( JdbcAuthenticationRealm authenticationRealm(
@Qualifier("passwordEncoder") @Qualifier("passwordEncoder")
PasswordEncoder passwordEncoder, PasswordEncoder passwordEncoder,
PasswordPolicyValidator passwordPolicyValidator, PasswordPolicyValidator passwordPolicyValidator,
LoginRepository loginRepository, LoginRepository loginRepository,
LoginHistoryRepository loginHistoryRepository, LoginHistoryRepository loginHistoryRepository,
UserInfoService userInfoService, UserInfoService userInfoService,
IpLocationParser ipLocationParser, IpLocationParser ipLocationParser,
JdbcTemplate jdbcTemplate) { JdbcTemplate jdbcTemplate) {
JdbcAuthenticationRealm authenticationRealm = new JdbcAuthenticationRealm( JdbcAuthenticationRealm authenticationRealm = new JdbcAuthenticationRealm(
passwordEncoder, passwordEncoder,
@ -62,8 +62,8 @@ public class MaxKeyMgtConfig {
return authenticationRealm; return authenticationRealm;
} }
@Bean @Bean
public AbstractOtpAuthn timeBasedOtpAuthn() { AbstractOtpAuthn timeBasedOtpAuthn() {
AbstractOtpAuthn tfaOtpAuthn = new TimeBasedOtpAuthn(); AbstractOtpAuthn tfaOtpAuthn = new TimeBasedOtpAuthn();
logger.debug("TimeBasedOtpAuthn inited."); logger.debug("TimeBasedOtpAuthn inited.");
return tfaOtpAuthn; return tfaOtpAuthn;

View File

@ -40,11 +40,11 @@ import org.springframework.jdbc.core.JdbcTemplate;
@AutoConfiguration @AutoConfiguration
public class MaxKeyMgtListenerConfig { public class MaxKeyMgtListenerConfig {
private static final Logger logger = LoggerFactory.getLogger(MaxKeyMgtListenerConfig.class); private static final Logger logger = LoggerFactory.getLogger(MaxKeyMgtListenerConfig.class);
@Bean @Bean
public String sessionListenerAdapter( String sessionListenerAdapter(
Scheduler scheduler, Scheduler scheduler,
SessionManager sessionManager) throws SchedulerException { SessionManager sessionManager) throws SchedulerException {
new ScheduleAdapterBuilder() new ScheduleAdapterBuilder()
.setScheduler(scheduler) .setScheduler(scheduler)
.setCron("0 0/10 * * * ?") .setCron("0 0/10 * * * ?")
@ -54,11 +54,11 @@ public class MaxKeyMgtListenerConfig {
logger.debug("Session ListenerAdapter inited ."); logger.debug("Session ListenerAdapter inited .");
return "sessionListenerAdapter"; return "sessionListenerAdapter";
} }
@Bean @Bean
public String reorgDeptListenerAdapter( String reorgDeptListenerAdapter(
Scheduler scheduler, Scheduler scheduler,
OrganizationsService organizationsService) throws SchedulerException { OrganizationsService organizationsService) throws SchedulerException {
new ScheduleAdapterBuilder() new ScheduleAdapterBuilder()
.setScheduler(scheduler) .setScheduler(scheduler)
.setCron("0 0/30 * * * ?") .setCron("0 0/30 * * * ?")
@ -68,13 +68,13 @@ public class MaxKeyMgtListenerConfig {
logger.debug("ReorgDept ListenerAdapter inited ."); logger.debug("ReorgDept ListenerAdapter inited .");
return "reorgDeptListenerAdapter"; return "reorgDeptListenerAdapter";
} }
@Bean @Bean
public String dynamicGroupsListenerAdapter( String dynamicGroupsListenerAdapter(
Scheduler scheduler, Scheduler scheduler,
GroupsService groupsService, GroupsService groupsService,
@Value("${maxkey.job.cron.schedule}") String cronSchedule @Value("${maxkey.job.cron.schedule}") String cronSchedule
) throws SchedulerException { ) throws SchedulerException {
new ScheduleAdapterBuilder() new ScheduleAdapterBuilder()
.setScheduler(scheduler) .setScheduler(scheduler)
.setCron(cronSchedule) .setCron(cronSchedule)
@ -85,13 +85,13 @@ public class MaxKeyMgtListenerConfig {
logger.debug("DynamicGroups ListenerAdapter inited ."); logger.debug("DynamicGroups ListenerAdapter inited .");
return "dynamicGroupsListenerAdapter"; return "dynamicGroupsListenerAdapter";
} }
@Bean @Bean
public String provisioningRunnerThread( String provisioningRunnerThread(
ConnectorsService connectorsService, ConnectorsService connectorsService,
JdbcTemplate jdbcTemplate, JdbcTemplate jdbcTemplate,
ApplicationConfig applicationConfig ApplicationConfig applicationConfig
) { ) {
if(applicationConfig.isProvisionSupport()) { if(applicationConfig.isProvisionSupport()) {
ProvisioningRunner runner = new ProvisioningRunner(connectorsService,jdbcTemplate); ProvisioningRunner runner = new ProvisioningRunner(connectorsService,jdbcTemplate);
ProvisioningRunnerThread runnerThread = new ProvisioningRunnerThread(runner); ProvisioningRunnerThread runnerThread = new ProvisioningRunnerThread(runner);

View File

@ -45,23 +45,23 @@ import org.springframework.security.crypto.password.PasswordEncoder;
@AutoConfiguration @AutoConfiguration
public class Oauth20ClientAutoConfiguration { public class Oauth20ClientAutoConfiguration {
private static final Logger logger = LoggerFactory.getLogger(Oauth20ClientAutoConfiguration.class); private static final Logger logger = LoggerFactory.getLogger(Oauth20ClientAutoConfiguration.class);
@Bean @Bean
public JdbcClientDetailsService oauth20JdbcClientDetailsService( JdbcClientDetailsService oauth20JdbcClientDetailsService(
DataSource dataSource , @Qualifier("passwordReciprocal") PasswordEncoder passwordReciprocal) { DataSource dataSource, @Qualifier("passwordReciprocal") PasswordEncoder passwordReciprocal) {
JdbcClientDetailsService clientDetailsService = new JdbcClientDetailsService(dataSource); JdbcClientDetailsService clientDetailsService = new JdbcClientDetailsService(dataSource);
//clientDetailsService.setPasswordEncoder(passwordReciprocal); //clientDetailsService.setPasswordEncoder(passwordReciprocal);
logger.debug("JdbcClientDetailsService inited."); logger.debug("JdbcClientDetailsService inited.");
return clientDetailsService; return clientDetailsService;
} }
/** /**
* TokenStore. * TokenStore.
* @param persistence int * @param persistence int
* @return oauth20TokenStore * @return oauth20TokenStore
*/ */
@Bean @Bean
public TokenStore oauth20TokenStore( TokenStore oauth20TokenStore(
@Value("${maxkey.server.persistence}") int persistence, @Value("${maxkey.server.persistence}") int persistence,
JdbcTemplate jdbcTemplate, JdbcTemplate jdbcTemplate,
RedisConnectionFactory jedisConnectionFactory) { RedisConnectionFactory jedisConnectionFactory) {
@ -76,13 +76,13 @@ public class Oauth20ClientAutoConfiguration {
return tokenStore; return tokenStore;
} }
/** /**
* clientDetailsUserDetailsService. * clientDetailsUserDetailsService.
* @return oauth20TokenServices * @return oauth20TokenServices
*/ */
@Bean @Bean
public DefaultTokenServices oauth20TokenServices( DefaultTokenServices oauth20TokenServices(
JdbcClientDetailsService oauth20JdbcClientDetailsService, JdbcClientDetailsService oauth20JdbcClientDetailsService,
TokenStore oauth20TokenStore) { TokenStore oauth20TokenStore) {
DefaultTokenServices tokenServices = new DefaultTokenServices(); DefaultTokenServices tokenServices = new DefaultTokenServices();
@ -91,17 +91,17 @@ public class Oauth20ClientAutoConfiguration {
tokenServices.setSupportRefreshToken(true); tokenServices.setSupportRefreshToken(true);
return tokenServices; return tokenServices;
} }
/** /**
* ProviderManager. * ProviderManager.
* @return oauth20ClientAuthenticationManager * @return oauth20ClientAuthenticationManager
*/ */
@Bean @Bean
public ProviderManager oauth20ClientAuthenticationManager( ProviderManager oauth20ClientAuthenticationManager(
JdbcClientDetailsService oauth20JdbcClientDetailsService, JdbcClientDetailsService oauth20JdbcClientDetailsService,
@Qualifier("passwordReciprocal") @Qualifier("passwordReciprocal")
PasswordEncoder passwordReciprocal PasswordEncoder passwordReciprocal
) { ) {
ClientDetailsUserDetailsService cientDetailsUserDetailsService = ClientDetailsUserDetailsService cientDetailsUserDetailsService =
new ClientDetailsUserDetailsService(oauth20JdbcClientDetailsService); new ClientDetailsUserDetailsService(oauth20JdbcClientDetailsService);

View File

@ -36,18 +36,18 @@ import org.springframework.security.crypto.password.PasswordEncoder;
@AutoConfiguration @AutoConfiguration
public class MaxKeyOpenApiConfig{ public class MaxKeyOpenApiConfig{
private static final Logger logger = LoggerFactory.getLogger(MaxKeyOpenApiConfig.class); private static final Logger logger = LoggerFactory.getLogger(MaxKeyOpenApiConfig.class);
//authenticationRealm for MaxKeyMgtApplication //authenticationRealm for MaxKeyMgtApplication
@Bean @Bean
public JdbcAuthenticationRealm authenticationRealm( JdbcAuthenticationRealm authenticationRealm(
@Qualifier("passwordEncoder") @Qualifier("passwordEncoder")
PasswordEncoder passwordEncoder, PasswordEncoder passwordEncoder,
PasswordPolicyValidator passwordPolicyValidator, PasswordPolicyValidator passwordPolicyValidator,
LoginRepository loginRepository, LoginRepository loginRepository,
LoginHistoryRepository loginHistoryRepository, LoginHistoryRepository loginHistoryRepository,
UserInfoService userInfoService, UserInfoService userInfoService,
IpLocationParser ipLocationParser, IpLocationParser ipLocationParser,
JdbcTemplate jdbcTemplate) { JdbcTemplate jdbcTemplate) {
JdbcAuthenticationRealm authenticationRealm = new JdbcAuthenticationRealm( JdbcAuthenticationRealm authenticationRealm = new JdbcAuthenticationRealm(
passwordEncoder, passwordEncoder,
@ -62,8 +62,8 @@ public class MaxKeyOpenApiConfig{
return authenticationRealm; return authenticationRealm;
} }
@Bean @Bean
public AbstractOtpAuthn timeBasedOtpAuthn() { AbstractOtpAuthn timeBasedOtpAuthn() {
AbstractOtpAuthn tfaOtpAuthn = new TimeBasedOtpAuthn(); AbstractOtpAuthn tfaOtpAuthn = new TimeBasedOtpAuthn();
logger.debug("TimeBasedOtpAuthn inited."); logger.debug("TimeBasedOtpAuthn inited.");
return tfaOtpAuthn; return tfaOtpAuthn;

View File

@ -45,23 +45,23 @@ import org.springframework.security.crypto.password.PasswordEncoder;
@AutoConfiguration @AutoConfiguration
public class Oauth20ClientAutoConfiguration { public class Oauth20ClientAutoConfiguration {
private static final Logger logger = LoggerFactory.getLogger(Oauth20ClientAutoConfiguration.class); private static final Logger logger = LoggerFactory.getLogger(Oauth20ClientAutoConfiguration.class);
@Bean @Bean
public JdbcClientDetailsService oauth20JdbcClientDetailsService( JdbcClientDetailsService oauth20JdbcClientDetailsService(
DataSource dataSource, @Qualifier("passwordReciprocal") PasswordEncoder passwordReciprocal) { DataSource dataSource, @Qualifier("passwordReciprocal") PasswordEncoder passwordReciprocal) {
JdbcClientDetailsService clientDetailsService = new JdbcClientDetailsService(dataSource); JdbcClientDetailsService clientDetailsService = new JdbcClientDetailsService(dataSource);
//clientDetailsService.setPasswordEncoder(passwordReciprocal); //clientDetailsService.setPasswordEncoder(passwordReciprocal);
logger.debug("JdbcClientDetailsService inited."); logger.debug("JdbcClientDetailsService inited.");
return clientDetailsService; return clientDetailsService;
} }
/** /**
* TokenStore. * TokenStore.
* @param persistence int * @param persistence int
* @return oauth20TokenStore * @return oauth20TokenStore
*/ */
@Bean @Bean
public TokenStore oauth20TokenStore( TokenStore oauth20TokenStore(
@Value("${maxkey.server.persistence}") int persistence, @Value("${maxkey.server.persistence}") int persistence,
JdbcTemplate jdbcTemplate, JdbcTemplate jdbcTemplate,
RedisConnectionFactory jedisConnectionFactory) { RedisConnectionFactory jedisConnectionFactory) {
@ -76,13 +76,13 @@ public class Oauth20ClientAutoConfiguration {
return tokenStore; return tokenStore;
} }
/** /**
* clientDetailsUserDetailsService. * clientDetailsUserDetailsService.
* @return oauth20TokenServices * @return oauth20TokenServices
*/ */
@Bean @Bean
public DefaultTokenServices oauth20TokenServices( DefaultTokenServices oauth20TokenServices(
JdbcClientDetailsService oauth20JdbcClientDetailsService, JdbcClientDetailsService oauth20JdbcClientDetailsService,
TokenStore oauth20TokenStore) { TokenStore oauth20TokenStore) {
DefaultTokenServices tokenServices = new DefaultTokenServices(); DefaultTokenServices tokenServices = new DefaultTokenServices();
@ -91,17 +91,17 @@ public class Oauth20ClientAutoConfiguration {
tokenServices.setSupportRefreshToken(true); tokenServices.setSupportRefreshToken(true);
return tokenServices; return tokenServices;
} }
/** /**
* ProviderManager. * ProviderManager.
* @return oauth20ClientAuthenticationManager * @return oauth20ClientAuthenticationManager
*/ */
@Bean @Bean
public ProviderManager oauth20ClientAuthenticationManager( ProviderManager oauth20ClientAuthenticationManager(
JdbcClientDetailsService oauth20JdbcClientDetailsService, JdbcClientDetailsService oauth20JdbcClientDetailsService,
@Qualifier("passwordReciprocal") @Qualifier("passwordReciprocal")
PasswordEncoder passwordReciprocal PasswordEncoder passwordReciprocal
) { ) {
ClientDetailsUserDetailsService cientDetailsUserDetailsService = ClientDetailsUserDetailsService cientDetailsUserDetailsService =
new ClientDetailsUserDetailsService(oauth20JdbcClientDetailsService); new ClientDetailsUserDetailsService(oauth20JdbcClientDetailsService);

View File

@ -1,7 +1,7 @@
echo off echo off
echo set env echo set env
set JAVA_HOME=C:\IDE\jdk-17.0.2.8 set JAVA_HOME=C:\ide\jdk-17.0.9+9
set GRADLE_HOME=C:\IDE\gradle-8.8 set GRADLE_HOME=C:\ide\gradle-8.8
call %JAVA_HOME%/bin/java -version call %JAVA_HOME%/bin/java -version
call %GRADLE_HOME%/bin/gradle -version call %GRADLE_HOME%/bin/gradle -version