diff --git a/pig-auth/src/main/java/com/pig4cloud/pig/auth/config/AuthorizationServerConfiguration.java b/pig-auth/src/main/java/com/pig4cloud/pig/auth/config/AuthorizationServerConfiguration.java index 6eef4356..78ccbfbe 100755 --- a/pig-auth/src/main/java/com/pig4cloud/pig/auth/config/AuthorizationServerConfiguration.java +++ b/pig-auth/src/main/java/com/pig4cloud/pig/auth/config/AuthorizationServerConfiguration.java @@ -33,6 +33,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.config.Customizer; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService; import org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2AuthorizationServerConfigurer; @@ -65,14 +66,14 @@ public class AuthorizationServerConfiguration { public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http) throws Exception { OAuth2AuthorizationServerConfigurer authorizationServerConfigurer = new OAuth2AuthorizationServerConfigurer(); - http.apply(authorizationServerConfigurer.tokenEndpoint((tokenEndpoint) -> {// 个性化认证授权端点 + http.with(authorizationServerConfigurer.tokenEndpoint((tokenEndpoint) -> {// 个性化认证授权端点 tokenEndpoint.accessTokenRequestConverter(accessTokenRequestConverter()) // 注入自定义的授权认证Converter .accessTokenResponseHandler(new PigAuthenticationSuccessEventHandler()) // 登录成功处理器 .errorResponseHandler(new PigAuthenticationFailureEventHandler());// 登录失败处理器 }).clientAuthentication(oAuth2ClientAuthenticationConfigurer -> // 个性化客户端认证 oAuth2ClientAuthenticationConfigurer.errorResponseHandler(new PigAuthenticationFailureEventHandler()))// 处理客户端认证异常 .authorizationEndpoint(authorizationEndpoint -> authorizationEndpoint// 授权码端点个性化confirm页面 - .consentPage(SecurityConstants.CUSTOM_CONSENT_PAGE_URI))); + .consentPage(SecurityConstants.CUSTOM_CONSENT_PAGE_URI)), Customizer.withDefaults()); AntPathRequestMatcher[] requestMatchers = new AntPathRequestMatcher[] { AntPathRequestMatcher.antMatcher("/token/**"), AntPathRequestMatcher.antMatcher("/actuator/**"), @@ -83,10 +84,11 @@ public class AuthorizationServerConfiguration { authorizeRequests.requestMatchers(requestMatchers).permitAll(); authorizeRequests.anyRequest().authenticated(); }) - .apply(authorizationServerConfigurer.authorizationService(authorizationService)// redis存储token的实现 + .with(authorizationServerConfigurer.authorizationService(authorizationService)// redis存储token的实现 .authorizationServerSettings( - AuthorizationServerSettings.builder().issuer(SecurityConstants.PROJECT_LICENSE).build())); - http.apply(new FormIdentityLoginConfigurer()); + AuthorizationServerSettings.builder().issuer(SecurityConstants.PROJECT_LICENSE).build()), + Customizer.withDefaults()); + http.with(new FormIdentityLoginConfigurer(), Customizer.withDefaults()); DefaultSecurityFilterChain securityFilterChain = http.build(); // 注入自定义授权模式实现 diff --git a/pig-auth/src/main/java/com/pig4cloud/pig/auth/config/WebSecurityConfiguration.java b/pig-auth/src/main/java/com/pig4cloud/pig/auth/config/WebSecurityConfiguration.java index f85acef7..7a2d35f3 100755 --- a/pig-auth/src/main/java/com/pig4cloud/pig/auth/config/WebSecurityConfiguration.java +++ b/pig-auth/src/main/java/com/pig4cloud/pig/auth/config/WebSecurityConfiguration.java @@ -20,6 +20,7 @@ import com.pig4cloud.pig.auth.support.core.FormIdentityLoginConfigurer; import com.pig4cloud.pig.auth.support.core.PigDaoAuthenticationProvider; import org.springframework.context.annotation.Bean; import org.springframework.core.annotation.Order; +import org.springframework.security.config.Customizer; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; @@ -48,7 +49,7 @@ public class WebSecurityConfiguration { .permitAll()// 开放自定义的部分端点 .anyRequest() .authenticated()).headers(header -> header.frameOptions(HeadersConfigurer.FrameOptionsConfig::sameOrigin)// 避免iframe同源无法登录许iframe - ).apply(new FormIdentityLoginConfigurer()); // 表单登录个性化 + ).with(new FormIdentityLoginConfigurer(), Customizer.withDefaults()); // 表单登录个性化 // 处理 UsernamePasswordAuthenticationToken http.authenticationProvider(new PigDaoAuthenticationProvider()); return http.build(); diff --git a/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/CustomeOAuth2AccessTokenGenerator.java b/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/CustomeOAuth2AccessTokenGenerator.java index 33bcf48d..af438da7 100644 --- a/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/CustomeOAuth2AccessTokenGenerator.java +++ b/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/CustomeOAuth2AccessTokenGenerator.java @@ -24,9 +24,9 @@ import java.util.*; public class CustomeOAuth2AccessTokenGenerator implements OAuth2TokenGenerator { private OAuth2TokenCustomizer accessTokenCustomizer; - private final StringKeyGenerator accessTokenGenerator = - new Base64StringKeyGenerator(Base64.getUrlEncoder().withoutPadding(), 96); + private final StringKeyGenerator accessTokenGenerator = new Base64StringKeyGenerator( + Base64.getUrlEncoder().withoutPadding(), 96); @Nullable @Override @@ -85,8 +85,8 @@ public class CustomeOAuth2AccessTokenGenerator implements OAuth2TokenGenerator service.support(finalClientId, grantType)) .max(Comparator.comparingInt(Ordered::getOrder)); - if (!optional.isPresent()) { + if (optional.isEmpty()) { throw new InternalAuthenticationServiceException("UserDetailsService error , not register"); } diff --git a/pig-common/pig-common-feign/src/main/java/com/pig4cloud/pig/common/feign/sentinel/ext/PigSentinelFeign.java b/pig-common/pig-common-feign/src/main/java/com/pig4cloud/pig/common/feign/sentinel/ext/PigSentinelFeign.java index 84716ec6..c7c169b5 100644 --- a/pig-common/pig-common-feign/src/main/java/com/pig4cloud/pig/common/feign/sentinel/ext/PigSentinelFeign.java +++ b/pig-common/pig-common-feign/src/main/java/com/pig4cloud/pig/common/feign/sentinel/ext/PigSentinelFeign.java @@ -107,7 +107,7 @@ public final class PigSentinelFeign { Object fallbackInstance = feignClientFactory.getInstance(name, fallbackType); if (fallbackInstance == null) { throw new IllegalStateException(String - .format("No %s instance of type %s found for feign client %s", type, fallbackType, name)); + .format("No %s instance of type %s found for feign client %s", type, fallbackType, name)); } if (!targetType.isAssignableFrom(fallbackType)) { diff --git a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/PigInitQuartzJob.java b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/PigInitQuartzJob.java index dc960ede..3b18e025 100644 --- a/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/PigInitQuartzJob.java +++ b/pig-visual/pig-quartz/src/main/java/com/pig4cloud/pig/daemon/quartz/config/PigInitQuartzJob.java @@ -37,24 +37,28 @@ import org.springframework.context.annotation.Configuration; @AllArgsConstructor public class PigInitQuartzJob implements InitializingBean { - private final SysJobService sysJobService; + private final SysJobService sysJobService; - private final TaskUtil taskUtil; + private final TaskUtil taskUtil; - private final Scheduler scheduler; + private final Scheduler scheduler; + + @Override + public void afterPropertiesSet() throws Exception { + sysJobService.list().forEach(sysjob -> { + if (PigQuartzEnum.JOB_STATUS_RELEASE.getType().equals(sysjob.getJobStatus())) { + taskUtil.removeJob(sysjob, scheduler); + } + else if (PigQuartzEnum.JOB_STATUS_RUNNING.getType().equals(sysjob.getJobStatus())) { + taskUtil.resumeJob(sysjob, scheduler); + } + else if (PigQuartzEnum.JOB_STATUS_NOT_RUNNING.getType().equals(sysjob.getJobStatus())) { + taskUtil.pauseJob(sysjob, scheduler); + } + else { + taskUtil.removeJob(sysjob, scheduler); + } + }); + } - @Override - public void afterPropertiesSet() throws Exception { - sysJobService.list().forEach(sysjob -> { - if (PigQuartzEnum.JOB_STATUS_RELEASE.getType().equals(sysjob.getJobStatus())) { - taskUtil.removeJob(sysjob, scheduler); - } else if (PigQuartzEnum.JOB_STATUS_RUNNING.getType().equals(sysjob.getJobStatus())) { - taskUtil.resumeJob(sysjob, scheduler); - } else if (PigQuartzEnum.JOB_STATUS_NOT_RUNNING.getType().equals(sysjob.getJobStatus())) { - taskUtil.pauseJob(sysjob, scheduler); - } else { - taskUtil.removeJob(sysjob, scheduler); - } - }); - } }