From f95fcaf0b4ef4cbf07c9e7dfc3e9d41d382ae431 Mon Sep 17 00:00:00 2001 From: Lukas Lohoff Date: Wed, 22 Mar 2023 15:15:28 +0100 Subject: [PATCH] feat: update spring-boot to 3.0.x BREAKING CHANGE: requires migration for spring / spring-security 6 and hibernate 6 updates Migration guide: - update java EE 8 dependencies to jakarta EE 9 (see https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#jakarta-ee) - update repositories - update `@QueryHints` annotations - e.g. `org.hibernate.annotations.QueryHints.CACHEABLE` -> `AvailableHints.HINT_CACHEABLE` - if you use custom data fetching methods, migration steps for hibernate 6 / 6.1 / 6.2 might be necessary - especially consider https://github.com/hibernate/hibernate-orm/blob/6.0/migration-guide.adoc#removals - for more information see the hibernate migration guides listed below - update your SecurityConfigs which extend `KeycloakWebSecurityConfig` or `SimpleWebSecurityConfig` - update your filter chain according to the the spring security migration guides below - replace `antMatchers` with `requestMatchers`, ignoringAntMatchers with ignoringRequestMatchers - update your rules for swagger (`/v3/api-docs`) if they're not already updated - update your `git-commit-id-plugin` configuration and check if the version set in shogun is overridden (for more information see https://github.com/terrestris/shogun/pull/730) --- pom.xml | 49 +++++++++++++++---- shogun-boot/pom.xml | 4 +- .../shogun/boot/config/JdbcConfiguration.java | 3 +- shogun-config/pom.xml | 2 +- .../config/DefaultWebSecurityConfig.java | 14 +++--- .../config/KeycloakWebSecurityConfig.java | 31 +++++++----- .../config/SimpleWebSecurityConfig.java | 12 ++--- .../shogun/config/WebSecurityConfig.java | 8 +-- .../src/main/resources/application-base.yml | 4 +- shogun-gs-interceptor/pom.xml | 5 +- .../config/InterceptorWebSecurityConfig.java | 32 ++++++------ .../GeoServerInterceptorController.java | 2 +- .../interceptor/message/OgcMessage.java | 4 +- .../interceptor/model/InterceptorRule.java | 2 +- .../repository/InterceptorRuleRepository.java | 8 +-- .../service/GeoServerInterceptorService.java | 2 +- .../servlet/CachedServletInputStream.java | 4 +- .../servlet/MutableHttpServletRequest.java | 6 +-- .../shogun/interceptor/util/OgcXmlUtil.java | 4 +- shogun-lib/pom.xml | 16 +++--- .../shogun/lib/config/AuditConfig.java | 2 +- .../shogun/lib/config/JacksonConfig.java | 2 +- .../shogun/lib/config/SwaggerConfig.java | 6 +-- .../lib/dto/PermissionCollectionTypeDto.java | 5 ++ .../shogun/lib/dto/RegisterUserDto.java | 8 +-- ...unEnversRevisionRepositoryFactoryBean.java | 4 +- .../shogun/lib/model/Application.java | 13 ++--- .../shogun/lib/model/BaseEntity.java | 8 +-- .../de/terrestris/shogun/lib/model/File.java | 4 +- .../de/terrestris/shogun/lib/model/Group.java | 2 +- .../shogun/lib/model/ImageFile.java | 8 +-- .../de/terrestris/shogun/lib/model/Layer.java | 11 +++-- .../de/terrestris/shogun/lib/model/User.java | 9 ++-- .../security/permission/BasePermission.java | 6 +-- .../security/permission/ClassPermission.java | 4 +- .../permission/GroupClassPermission.java | 8 +-- .../permission/GroupInstancePermission.java | 8 +-- .../permission/InstancePermission.java | 4 +- .../permission/PermissionCollection.java | 6 +-- .../permission/UserClassPermission.java | 8 +-- .../permission/UserInstancePermission.java | 8 +-- .../lib/repository/ApplicationRepository.java | 4 +- .../lib/repository/BaseCrudRepository.java | 4 +- .../lib/repository/BaseFileRepository.java | 5 +- .../lib/repository/GroupRepository.java | 4 +- .../shogun/lib/repository/UserRepository.java | 4 +- .../impl/ShogunRevisionRepositoryImpl.java | 2 +- .../GroupClassPermissionRepository.java | 7 ++- .../GroupInstancePermissionRepository.java | 9 ++-- .../PermissionCollectionRepository.java | 4 +- .../UserClassPermissionRepository.java | 6 +-- .../UserInstancePermissionRepository.java | 10 ++-- .../shogun/lib/service/CacheService.java | 6 +-- .../terrestris/shogun/lib/util/HttpUtil.java | 6 +-- .../shogun/lib/util/KeycloakUtil.java | 18 +------ .../config/HttpProxyWebSecurityConfig.java | 14 ++++-- .../controller/HttpProxyController.java | 2 +- .../shogun/service/HttpProxyService.java | 4 +- .../shogun/service/HttpProxyServiceTest.java | 5 +- 59 files changed, 253 insertions(+), 207 deletions(-) diff --git a/pom.xml b/pom.xml index 04d42b15c..c81ede83e 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.springframework.boot spring-boot-starter-parent - 2.7.4 + 3.0.4 de.terrestris @@ -97,6 +97,8 @@ UTF-8 17 + "" + 3.12.1 0.8.10 @@ -104,8 +106,11 @@ 3.3.2 - 2.7.6 - 2.7.6 + 3.0.4 + 3.0.4 + + + 6.1.7.Final 2.13.2.20220328 @@ -113,13 +118,13 @@ 19.0.3 - 2.21.0 + 2.21.1 21.0 - 1.7.0 + 2.0.4 1.0-2.7 @@ -369,7 +374,7 @@ org.springdoc - springdoc-openapi-ui + springdoc-openapi-starter-webmvc-ui ${springdoc-openapi.version} @@ -413,10 +418,35 @@ com.vladmihalcea - hibernate-types-52 + hibernate-types-60 ${hibernate-extra-types.version} + + + org.hibernate + hibernate-core + ${hibernate.version} + + + + org.hibernate + hibernate-spatial + ${hibernate.version} + + + + org.hibernate + hibernate-jcache + ${hibernate.version} + + + + org.ehcache + ehcache + 3.10.1 + + org.springframework.boot @@ -504,8 +534,9 @@ com.sun.mail - javax.mail - ${javax-mail.version} + jakarta.mail + + 2.0.1 diff --git a/shogun-boot/pom.xml b/shogun-boot/pom.xml index 4e55388f8..be9d6f530 100644 --- a/shogun-boot/pom.xml +++ b/shogun-boot/pom.xml @@ -98,7 +98,7 @@ com.vladmihalcea - hibernate-types-52 + hibernate-types-60 @@ -110,7 +110,7 @@ org.springdoc - springdoc-openapi-ui + springdoc-openapi-starter-webmvc-ui diff --git a/shogun-boot/src/test/java/de/terrestris/shogun/boot/config/JdbcConfiguration.java b/shogun-boot/src/test/java/de/terrestris/shogun/boot/config/JdbcConfiguration.java index a79f96305..a5d812588 100644 --- a/shogun-boot/src/test/java/de/terrestris/shogun/boot/config/JdbcConfiguration.java +++ b/shogun-boot/src/test/java/de/terrestris/shogun/boot/config/JdbcConfiguration.java @@ -21,7 +21,6 @@ import org.junit.AfterClass; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy; -import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; @@ -96,7 +95,7 @@ public LocalContainerEntityManagerFactoryBean entityManagerFactory() { jpaProperties.put("hibernate.default_schema", env.getProperty("hibernate.default_schema")); jpaProperties.put("hibernate.integration.envers.enabled", false); jpaProperties.put("hibernate.implicit_naming_strategy", SpringImplicitNamingStrategy.class.getName()); - jpaProperties.put("hibernate.physical_naming_strategy", SpringPhysicalNamingStrategy.class.getName()); +// jpaProperties.put("hibernate.physical_naming_strategy", CamelCaseToUnderscoresNamingStrategy.class.getName()); // todo: needs fix? result.setJpaPropertyMap(jpaProperties); diff --git a/shogun-config/pom.xml b/shogun-config/pom.xml index 51b1d0dbf..c587f268e 100644 --- a/shogun-config/pom.xml +++ b/shogun-config/pom.xml @@ -74,7 +74,7 @@ org.springdoc - springdoc-openapi-ui + springdoc-openapi-starter-webmvc-ui diff --git a/shogun-config/src/main/java/de/terrestris/shogun/config/DefaultWebSecurityConfig.java b/shogun-config/src/main/java/de/terrestris/shogun/config/DefaultWebSecurityConfig.java index 4a11b3059..362923f5f 100644 --- a/shogun-config/src/main/java/de/terrestris/shogun/config/DefaultWebSecurityConfig.java +++ b/shogun-config/src/main/java/de/terrestris/shogun/config/DefaultWebSecurityConfig.java @@ -27,8 +27,8 @@ default void customHttpConfiguration(HttpSecurity http) throws Exception { .sessionManagement(session -> session .sessionCreationPolicy(SessionCreationPolicy.STATELESS) ) - .authorizeRequests() - .antMatchers( + .authorizeHttpRequests() + .requestMatchers( "/", "/auth/**", "/info/**", @@ -45,7 +45,7 @@ default void customHttpConfiguration(HttpSecurity http) throws Exception { "/graphiql/**" ) .permitAll() - .antMatchers( + .requestMatchers( "/actuator/**", "/cache/**", "/webhooks/**", @@ -58,10 +58,10 @@ default void customHttpConfiguration(HttpSecurity http) throws Exception { .csrf() .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()) .ignoringRequestMatchers(csrfRequestMatcher) - .ignoringAntMatchers("/graphql") - .ignoringAntMatchers("/actuator/**") - .ignoringAntMatchers("/sso/**") - .ignoringAntMatchers("/ws/**"); + .ignoringRequestMatchers("/graphql") + .ignoringRequestMatchers("/actuator/**") + .ignoringRequestMatchers("/sso/**") + .ignoringRequestMatchers("/ws/**"); } } diff --git a/shogun-config/src/main/java/de/terrestris/shogun/config/KeycloakWebSecurityConfig.java b/shogun-config/src/main/java/de/terrestris/shogun/config/KeycloakWebSecurityConfig.java index d056da51d..9998d4942 100644 --- a/shogun-config/src/main/java/de/terrestris/shogun/config/KeycloakWebSecurityConfig.java +++ b/shogun-config/src/main/java/de/terrestris/shogun/config/KeycloakWebSecurityConfig.java @@ -21,18 +21,21 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; 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.configuration.WebSecurityConfigurerAdapter; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; +import org.springframework.security.web.SecurityFilterChain; +import org.springframework.security.web.access.expression.WebExpressionAuthorizationManager; + import javax.net.ssl.HttpsURLConnection; @ConditionalOnExpression("${keycloak.enabled:true}") @Configuration @EnableWebSecurity -public class KeycloakWebSecurityConfig extends WebSecurityConfigurerAdapter implements DefaultWebSecurityConfig { +public class KeycloakWebSecurityConfig implements DefaultWebSecurityConfig { @Autowired private KeycloakProperties keycloakProperties; @@ -48,14 +51,14 @@ public void init() { } } - @Override - public void configure(HttpSecurity http) throws Exception { - // allows access to `/webhooks/keycloak` for request from internal keycloak container + @Bean + public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http - .authorizeRequests() - .antMatchers("/webhooks/keycloak/**") - .access("authenticated or hasIpAddress('%s')" - .formatted(keycloakProperties.getInternalServerUrl())); + .authorizeHttpRequests() + .requestMatchers("/webhooks/keycloak/**") + .access(new WebExpressionAuthorizationManager( + "authenticated or hasIpAddress('%s')".formatted(keycloakProperties.getInternalServerUrl())) + ); customHttpConfiguration(http); @@ -66,11 +69,13 @@ public void configure(HttpSecurity http) throws Exception { http .csrf() - .ignoringAntMatchers("/webhooks/**") + .ignoringRequestMatchers("/webhooks/**") .and() .oauth2ResourceServer() - .jwt() - .jwtAuthenticationConverter(authConverter); + .jwt() + .jwtAuthenticationConverter(authConverter); + + return http.build(); } } diff --git a/shogun-config/src/main/java/de/terrestris/shogun/config/SimpleWebSecurityConfig.java b/shogun-config/src/main/java/de/terrestris/shogun/config/SimpleWebSecurityConfig.java index 94e1593a6..76c1d3fb5 100644 --- a/shogun-config/src/main/java/de/terrestris/shogun/config/SimpleWebSecurityConfig.java +++ b/shogun-config/src/main/java/de/terrestris/shogun/config/SimpleWebSecurityConfig.java @@ -18,17 +18,18 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 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.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.core.authority.mapping.SimpleAuthorityMapper; +import org.springframework.security.web.SecurityFilterChain; @ConditionalOnExpression("${keycloak.enabled:false}") @Configuration @EnableWebSecurity -public abstract class SimpleWebSecurityConfig extends WebSecurityConfigurerAdapter implements DefaultWebSecurityConfig { +public abstract class SimpleWebSecurityConfig implements DefaultWebSecurityConfig { @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) { @@ -40,11 +41,10 @@ public void configureGlobal(AuthenticationManagerBuilder auth) { // TODO make this extendable } - @Override - public void configure(HttpSecurity http) throws Exception { - super.configure(http); - + @Bean + public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { customHttpConfiguration(http); + return http.build(); } } diff --git a/shogun-config/src/main/java/de/terrestris/shogun/config/WebSecurityConfig.java b/shogun-config/src/main/java/de/terrestris/shogun/config/WebSecurityConfig.java index 9669a3c99..e09e21364 100644 --- a/shogun-config/src/main/java/de/terrestris/shogun/config/WebSecurityConfig.java +++ b/shogun-config/src/main/java/de/terrestris/shogun/config/WebSecurityConfig.java @@ -16,7 +16,9 @@ */ package de.terrestris.shogun.config; +import org.springframework.context.annotation.Bean; import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.util.matcher.RequestMatcher; public interface WebSecurityConfig { @@ -27,9 +29,9 @@ public interface WebSecurityConfig { return refererHeader != null && refererHeader.endsWith("swagger-ui/index.html"); }; - default void configure(HttpSecurity http) throws Exception { - customHttpConfiguration(http); - } +// default void configure(HttpSecurity http) throws Exception { +// customHttpConfiguration(http); +// } void customHttpConfiguration(HttpSecurity http) throws Exception; diff --git a/shogun-config/src/main/resources/application-base.yml b/shogun-config/src/main/resources/application-base.yml index df5fda082..c8fe74d18 100644 --- a/shogun-config/src/main/resources/application-base.yml +++ b/shogun-config/src/main/resources/application-base.yml @@ -38,7 +38,7 @@ spring: non_contextual_creation: true ddl-auto: none properties: - javax: + jakarta: persistence: sharedCache: # Only entities with @Cacheable annotation will use L2 cache @@ -51,7 +51,7 @@ spring: audit_table_suffix: _rev global_with_modified_flag: true hibernate: - javax: + jakarta: cache: provider: org.ehcache.jsr107.EhcacheCachingProvider uri: ehcache.xml diff --git a/shogun-gs-interceptor/pom.xml b/shogun-gs-interceptor/pom.xml index ee8ea14f4..9ee361b1f 100644 --- a/shogun-gs-interceptor/pom.xml +++ b/shogun-gs-interceptor/pom.xml @@ -78,7 +78,7 @@ com.vladmihalcea - hibernate-types-52 + hibernate-types-60 @@ -90,7 +90,8 @@ org.springdoc - springdoc-openapi-ui + springdoc-openapi-starter-webmvc-ui + diff --git a/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/config/InterceptorWebSecurityConfig.java b/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/config/InterceptorWebSecurityConfig.java index da6c177e6..835fa27d3 100644 --- a/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/config/InterceptorWebSecurityConfig.java +++ b/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/config/InterceptorWebSecurityConfig.java @@ -16,26 +16,28 @@ */ package de.terrestris.shogun.interceptor.config; -import de.terrestris.shogun.config.WebSecurityConfig; +import de.terrestris.shogun.config.DefaultWebSecurityConfig; import org.apache.commons.lang3.StringUtils; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.csrf.CookieCsrfTokenRepository; import org.springframework.security.web.util.matcher.RequestMatcher; @Configuration -public class InterceptorWebSecurityConfig implements WebSecurityConfig { +public class InterceptorWebSecurityConfig implements DefaultWebSecurityConfig { RequestMatcher csrfRequestMatcher = httpServletRequest -> { String refererHeader = httpServletRequest.getHeader("Referer"); return StringUtils.equalsIgnoreCase(refererHeader, "Shogun-Manager-Client"); }; - @Override - public void customHttpConfiguration(HttpSecurity http) throws Exception { + @Bean + public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http - .authorizeRequests() - .antMatchers( + .authorizeHttpRequests() + .requestMatchers( // Allow access to swagger interface "/swagger-ui/index.html", "/swagger-resources/**", @@ -43,16 +45,18 @@ public void customHttpConfiguration(HttpSecurity http) throws Exception { "/v2/**", "/csrf/**" ) - .permitAll() - .antMatchers("/interceptorrules/**") - .hasRole("INTERCEPTOR_ADMIN") + .permitAll() + .requestMatchers("/interceptorrules/**") + .hasRole("INTERCEPTOR_ADMIN") .anyRequest() - .authenticated() + .authenticated() .and() - .httpBasic() + .httpBasic() .and() - .csrf() - .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()) - .ignoringRequestMatchers(csrfRequestMatcher); + .csrf() + .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()) + .ignoringRequestMatchers(csrfRequestMatcher); + return http.build(); } + } diff --git a/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/controller/GeoServerInterceptorController.java b/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/controller/GeoServerInterceptorController.java index 96b830fdc..120a08dc1 100644 --- a/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/controller/GeoServerInterceptorController.java +++ b/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/controller/GeoServerInterceptorController.java @@ -31,7 +31,7 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.server.ResponseStatusException; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import java.io.IOException; import java.net.URISyntaxException; import java.util.Optional; diff --git a/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/message/OgcMessage.java b/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/message/OgcMessage.java index ca4bd6ab1..bc0b5444e 100644 --- a/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/message/OgcMessage.java +++ b/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/message/OgcMessage.java @@ -22,8 +22,8 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; public class OgcMessage { diff --git a/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/model/InterceptorRule.java b/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/model/InterceptorRule.java index 0cf89b775..f5b1851b1 100644 --- a/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/model/InterceptorRule.java +++ b/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/model/InterceptorRule.java @@ -25,7 +25,7 @@ import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; -import javax.persistence.*; +import jakarta.persistence.*; import java.util.Objects; @Entity diff --git a/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/repository/InterceptorRuleRepository.java b/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/repository/InterceptorRuleRepository.java index 1413ee46e..7ce069432 100644 --- a/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/repository/InterceptorRuleRepository.java +++ b/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/repository/InterceptorRuleRepository.java @@ -25,7 +25,7 @@ import org.springframework.data.jpa.repository.QueryHints; import org.springframework.stereotype.Repository; -import javax.persistence.QueryHint; +import jakarta.persistence.QueryHint; import java.util.List; import java.util.Optional; @@ -33,19 +33,19 @@ public interface InterceptorRuleRepository extends BaseCrudRepository, JpaSpecificationExecutor { @QueryHints(value = { - @QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"), + @QueryHint(name = AvailableHints.HINT_CACHEABLE, value = "true"), @QueryHint(name = org.hibernate.annotations.QueryHints.CACHE_REGION, value = "interceptorrule_query") }) List findAllByServiceAndEvent(OgcEnum.ServiceType service, HttpEnum.EventType event); @QueryHints(value = { - @QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"), + @QueryHint(name = AvailableHints.HINT_CACHEABLE, value = "true"), @QueryHint(name = org.hibernate.annotations.QueryHints.CACHE_REGION, value = "interceptorrule_query") }) List findByEndPoint(String endpoint); @QueryHints(value = { - @QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"), + @QueryHint(name = AvailableHints.HINT_CACHEABLE, value = "true"), @QueryHint(name = org.hibernate.annotations.QueryHints.CACHE_REGION, value = "interceptorrule_query") }) Optional findByEventAndRuleAndServiceAndOperationAndEndPoint(HttpEnum.EventType event, InterceptorEnum.RuleType rule, OgcEnum.ServiceType service, OgcEnum.OperationType operation, String endPoint); diff --git a/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/service/GeoServerInterceptorService.java b/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/service/GeoServerInterceptorService.java index fda206048..bff9324c3 100644 --- a/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/service/GeoServerInterceptorService.java +++ b/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/service/GeoServerInterceptorService.java @@ -41,7 +41,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.stereotype.Service; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URI; diff --git a/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/servlet/CachedServletInputStream.java b/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/servlet/CachedServletInputStream.java index c25e0c01a..9a1ec2241 100644 --- a/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/servlet/CachedServletInputStream.java +++ b/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/servlet/CachedServletInputStream.java @@ -16,8 +16,8 @@ */ package de.terrestris.shogun.interceptor.servlet; -import javax.servlet.ReadListener; -import javax.servlet.ServletInputStream; +import jakarta.servlet.ReadListener; +import jakarta.servlet.ServletInputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; diff --git a/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/servlet/MutableHttpServletRequest.java b/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/servlet/MutableHttpServletRequest.java index da904057d..efc366daf 100644 --- a/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/servlet/MutableHttpServletRequest.java +++ b/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/servlet/MutableHttpServletRequest.java @@ -24,9 +24,9 @@ import org.apache.commons.lang3.StringUtils; import org.w3c.dom.Document; -import javax.servlet.ServletInputStream; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; +import jakarta.servlet.ServletInputStream; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequestWrapper; import java.io.*; import java.net.URI; import java.util.Arrays; diff --git a/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/util/OgcXmlUtil.java b/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/util/OgcXmlUtil.java index ac442f35e..b74c327c7 100644 --- a/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/util/OgcXmlUtil.java +++ b/shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/util/OgcXmlUtil.java @@ -27,8 +27,8 @@ import org.xml.sax.InputSource; import org.xml.sax.SAXException; -import javax.servlet.ServletInputStream; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.ServletInputStream; +import jakarta.servlet.http.HttpServletRequest; import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; diff --git a/shogun-lib/pom.xml b/shogun-lib/pom.xml index e8664f0a7..a4c688bd1 100644 --- a/shogun-lib/pom.xml +++ b/shogun-lib/pom.xml @@ -49,8 +49,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api provided @@ -152,7 +152,7 @@ com.vladmihalcea - hibernate-types-52 + hibernate-types-60 org.hibernate @@ -196,13 +196,13 @@ - javax.validation - validation-api + jakarta.validation + jakarta.validation-api com.sun.mail - javax.mail + jakarta.mail @@ -265,8 +265,8 @@ - javax.xml.bind - jaxb-api + jakarta.xml.bind + jakarta.xml.bind-api test diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/config/AuditConfig.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/config/AuditConfig.java index 38c6d3c03..f0f47dae5 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/config/AuditConfig.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/config/AuditConfig.java @@ -21,7 +21,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import javax.persistence.EntityManagerFactory; +import jakarta.persistence.EntityManagerFactory; @Configuration public class AuditConfig { diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/config/JacksonConfig.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/config/JacksonConfig.java index 0eaa846dc..447941229 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/config/JacksonConfig.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/config/JacksonConfig.java @@ -35,7 +35,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import java.util.HashMap; import java.util.Map; diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/config/SwaggerConfig.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/config/SwaggerConfig.java index 2dc8991df..fd0852b0a 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/config/SwaggerConfig.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/config/SwaggerConfig.java @@ -29,8 +29,8 @@ import org.reflections.scanners.Scanners; import org.reflections.util.ClasspathHelper; import org.reflections.util.ConfigurationBuilder; -import org.springdoc.core.SpringDocUtils; -import org.springdoc.core.customizers.OpenApiCustomiser; +import org.springdoc.core.customizers.OpenApiCustomizer; +import org.springdoc.core.utils.SpringDocUtils; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -193,7 +193,7 @@ protected void replaceJsonSuperTypes() { * } */ @Bean - public OpenApiCustomiser enableArbitraryObjects() { + public OpenApiCustomizer enableArbitraryObjects() { return openApi -> openApi.getComponents().getSchemas().values().forEach( s -> enableArbitraryObjects(s)); } diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/dto/PermissionCollectionTypeDto.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/dto/PermissionCollectionTypeDto.java index 8692e2879..101c0716a 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/dto/PermissionCollectionTypeDto.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/dto/PermissionCollectionTypeDto.java @@ -22,6 +22,11 @@ import lombok.NoArgsConstructor; import lombok.ToString; +import jakarta.validation.constraints.AssertTrue; +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + @Data @AllArgsConstructor @NoArgsConstructor diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/dto/RegisterUserDto.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/dto/RegisterUserDto.java index 5943e2d71..b1a0af218 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/dto/RegisterUserDto.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/dto/RegisterUserDto.java @@ -21,10 +21,10 @@ import lombok.NoArgsConstructor; import lombok.ToString; -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.Email; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.AssertTrue; +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; @Data @AllArgsConstructor diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/envers/ShogunEnversRevisionRepositoryFactoryBean.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/envers/ShogunEnversRevisionRepositoryFactoryBean.java index 3958d9a35..424848b28 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/envers/ShogunEnversRevisionRepositoryFactoryBean.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/envers/ShogunEnversRevisionRepositoryFactoryBean.java @@ -27,7 +27,7 @@ import org.springframework.data.repository.history.RevisionRepository; import org.springframework.data.repository.history.support.RevisionEntityInformation; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import java.util.Optional; public class ShogunEnversRevisionRepositoryFactoryBean, S, ID, N extends Number & Comparable> @@ -55,7 +55,7 @@ public void setRevisionEntityClass(Class revisionEntityClass) { /* * (non-Javadoc) - * @see org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean#createRepositoryFactory(javax.persistence.EntityManager) + * @see org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean#createRepositoryFactory(jakarta.persistence.EntityManager) */ @Override protected RepositoryFactorySupport createRepositoryFactory(EntityManager entityManager) { diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/Application.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/Application.java index 3cdfbdf98..947b073a5 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/Application.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/Application.java @@ -21,16 +21,17 @@ import de.terrestris.shogun.lib.model.jsonb.LayerConfig; import de.terrestris.shogun.lib.model.jsonb.LayerTree; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.persistence.*; import lombok.*; import org.hibernate.Hibernate; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.annotations.DynamicUpdate; -import org.hibernate.annotations.Type; +import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.envers.AuditTable; import org.hibernate.envers.Audited; +import org.hibernate.type.SqlTypes; -import javax.persistence.*; import java.util.List; import java.util.Objects; @@ -64,7 +65,7 @@ public class Application extends BaseEntity { ) private Boolean stateOnly; - @Type(type = "jsonb") + @JdbcTypeCode(SqlTypes.JSON) @Column(columnDefinition = "jsonb") @Basic(fetch = FetchType.LAZY) @ToString.Exclude @@ -74,7 +75,7 @@ public class Application extends BaseEntity { ) private ApplicationClientConfig clientConfig; - @Type(type = "jsonb") + @JdbcTypeCode(SqlTypes.JSON) @Column(columnDefinition = "jsonb") @Basic(fetch = FetchType.LAZY) @ToString.Exclude @@ -83,7 +84,7 @@ public class Application extends BaseEntity { ) private LayerTree layerTree; - @Type(type = "jsonb") + @JdbcTypeCode(SqlTypes.JSON) @Column(columnDefinition = "jsonb") @Basic(fetch = FetchType.LAZY) @ToString.Exclude @@ -93,7 +94,7 @@ public class Application extends BaseEntity { ) private List layerConfig; - @Type(type = "jsonb") + @JdbcTypeCode(SqlTypes.JSON) @Column(columnDefinition = "jsonb") @Basic(fetch = FetchType.LAZY) @ToString.Exclude diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/BaseEntity.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/BaseEntity.java index a38c83b84..7d315aae5 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/BaseEntity.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/BaseEntity.java @@ -18,26 +18,20 @@ import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.ObjectIdGenerators; -import com.vladmihalcea.hibernate.type.json.JsonBinaryType; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.persistence.*; import lombok.*; import org.hibernate.Hibernate; import org.hibernate.annotations.CreationTimestamp; -import org.hibernate.annotations.TypeDef; -import org.hibernate.annotations.TypeDefs; import org.hibernate.annotations.UpdateTimestamp; import org.hibernate.envers.Audited; -import javax.persistence.*; import java.io.Serializable; import java.time.OffsetDateTime; import java.util.Objects; @MappedSuperclass @Audited -@TypeDefs({ - @TypeDef(name = "jsonb", typeClass = JsonBinaryType.class) -}) @NoArgsConstructor @AllArgsConstructor @ToString diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/File.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/File.java index d05f5b48d..0fbd44da0 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/File.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/File.java @@ -18,14 +18,13 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.persistence.*; import lombok.*; import org.hibernate.Hibernate; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.annotations.DynamicUpdate; -import org.hibernate.annotations.Type; -import javax.persistence.*; import java.util.Objects; import java.util.UUID; @@ -41,7 +40,6 @@ public class File extends BaseEntity { @Column(columnDefinition = "uuid", updatable = false, nullable = false) - @Type(type="pg-uuid") @Getter @Schema( description = "The (auto assigned) UUID of the file.", diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/Group.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/Group.java index eac01fa85..9fb067ba2 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/Group.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/Group.java @@ -17,6 +17,7 @@ package de.terrestris.shogun.lib.model; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.persistence.*; import lombok.*; import org.hibernate.Hibernate; import org.hibernate.annotations.Cache; @@ -25,7 +26,6 @@ import org.hibernate.envers.AuditTable; import org.hibernate.envers.Audited; -import javax.persistence.*; import java.util.Objects; @Entity(name = "groups") diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/ImageFile.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/ImageFile.java index 7f51f0cd6..379b39cab 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/ImageFile.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/ImageFile.java @@ -18,14 +18,14 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.persistence.Cacheable; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; import lombok.*; import org.hibernate.Hibernate; import org.hibernate.annotations.DynamicUpdate; -import javax.persistence.Cacheable; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; import java.util.Objects; @Entity(name = "imagefiles") diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/Layer.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/Layer.java index caf9f4e80..0fe19e589 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/Layer.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/Layer.java @@ -20,17 +20,18 @@ import de.terrestris.shogun.lib.model.jsonb.LayerClientConfig; import de.terrestris.shogun.lib.model.jsonb.LayerSourceConfig; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.persistence.*; import lombok.*; import org.geojson.GeoJsonObject; import org.hibernate.Hibernate; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.annotations.DynamicUpdate; -import org.hibernate.annotations.Type; +import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.envers.AuditTable; import org.hibernate.envers.Audited; +import org.hibernate.type.SqlTypes; -import javax.persistence.*; import java.util.Objects; @Entity(name = "layers") @@ -54,7 +55,7 @@ public class Layer extends BaseEntity { ) private String name; - @Type(type = "jsonb") + @JdbcTypeCode(SqlTypes.JSON) @Column(columnDefinition = "jsonb") @Basic(fetch = FetchType.LAZY) @ToString.Exclude @@ -64,7 +65,7 @@ public class Layer extends BaseEntity { ) private LayerClientConfig clientConfig; - @Type(type = "jsonb") + @JdbcTypeCode(SqlTypes.JSON) @Column(columnDefinition = "jsonb") @Basic(fetch = FetchType.LAZY) @ToString.Exclude @@ -75,7 +76,7 @@ public class Layer extends BaseEntity { ) private LayerSourceConfig sourceConfig; - @Type(type = "jsonb") + @JdbcTypeCode(SqlTypes.JSON) @Column(columnDefinition = "jsonb") @Basic(fetch = FetchType.LAZY) @ToString.Exclude diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/User.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/User.java index 62bd6cc61..288ee0d33 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/User.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/User.java @@ -19,16 +19,17 @@ import de.terrestris.shogun.lib.model.jsonb.UserClientConfig; import de.terrestris.shogun.lib.model.jsonb.UserDetails; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.persistence.*; import lombok.*; import org.hibernate.Hibernate; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.annotations.DynamicUpdate; -import org.hibernate.annotations.Type; +import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.envers.AuditTable; import org.hibernate.envers.Audited; +import org.hibernate.type.SqlTypes; -import javax.persistence.*; import java.util.Objects; @Entity(name = "users") @@ -59,7 +60,7 @@ public class User extends BaseEntity { ) private T providerDetails; - @Type(type = "jsonb") + @JdbcTypeCode(SqlTypes.JSON) @Column(columnDefinition = "jsonb") @Basic(fetch = FetchType.LAZY) @ToString.Exclude @@ -68,7 +69,7 @@ public class User extends BaseEntity { ) private UserDetails details; - @Type(type = "jsonb") + @JdbcTypeCode(SqlTypes.JSON) @Column(columnDefinition = "jsonb") @Basic(fetch = FetchType.LAZY) @ToString.Exclude diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/BasePermission.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/BasePermission.java index c5a859be5..6e305becf 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/BasePermission.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/BasePermission.java @@ -18,15 +18,15 @@ package de.terrestris.shogun.lib.model.security.permission; import de.terrestris.shogun.lib.model.BaseEntity; +import jakarta.persistence.FetchType; +import jakarta.persistence.MappedSuperclass; +import jakarta.persistence.OneToOne; import lombok.*; import org.hibernate.Hibernate; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; import org.hibernate.envers.Audited; -import javax.persistence.FetchType; -import javax.persistence.MappedSuperclass; -import javax.persistence.OneToOne; import java.util.Objects; import static org.hibernate.envers.RelationTargetAuditMode.NOT_AUDITED; diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/ClassPermission.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/ClassPermission.java index 3946d85ec..9ffebc3da 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/ClassPermission.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/ClassPermission.java @@ -16,12 +16,12 @@ */ package de.terrestris.shogun.lib.model.security.permission; +import jakarta.persistence.Column; +import jakarta.persistence.MappedSuperclass; import lombok.*; import org.hibernate.Hibernate; import org.hibernate.envers.Audited; -import javax.persistence.Column; -import javax.persistence.MappedSuperclass; import java.util.Objects; @MappedSuperclass diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/GroupClassPermission.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/GroupClassPermission.java index ee5c61d5e..cad947399 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/GroupClassPermission.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/GroupClassPermission.java @@ -17,6 +17,10 @@ package de.terrestris.shogun.lib.model.security.permission; import de.terrestris.shogun.lib.model.Group; +import jakarta.persistence.Cacheable; +import jakarta.persistence.Entity; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import lombok.*; import org.hibernate.Hibernate; import org.hibernate.annotations.Cache; @@ -25,10 +29,6 @@ import org.hibernate.envers.AuditTable; import org.hibernate.envers.Audited; -import javax.persistence.Cacheable; -import javax.persistence.Entity; -import javax.persistence.ManyToOne; -import javax.persistence.Table; import java.util.Objects; @Entity(name = "groupclasspermissions") diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/GroupInstancePermission.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/GroupInstancePermission.java index 3f5a1738f..58a463b51 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/GroupInstancePermission.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/GroupInstancePermission.java @@ -17,6 +17,10 @@ package de.terrestris.shogun.lib.model.security.permission; import de.terrestris.shogun.lib.model.Group; +import jakarta.persistence.Cacheable; +import jakarta.persistence.Entity; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import lombok.*; import org.hibernate.Hibernate; import org.hibernate.annotations.Cache; @@ -25,10 +29,6 @@ import org.hibernate.envers.AuditTable; import org.hibernate.envers.Audited; -import javax.persistence.Cacheable; -import javax.persistence.Entity; -import javax.persistence.ManyToOne; -import javax.persistence.Table; import java.util.Objects; @Entity(name = "groupinstancepermissions") diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/InstancePermission.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/InstancePermission.java index 226ad4694..c02e057d8 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/InstancePermission.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/InstancePermission.java @@ -16,12 +16,12 @@ */ package de.terrestris.shogun.lib.model.security.permission; +import jakarta.persistence.Column; +import jakarta.persistence.MappedSuperclass; import lombok.*; import org.hibernate.Hibernate; import org.hibernate.envers.Audited; -import javax.persistence.Column; -import javax.persistence.MappedSuperclass; import java.util.Objects; @MappedSuperclass diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/PermissionCollection.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/PermissionCollection.java index 058d56a0d..5cfbc43f5 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/PermissionCollection.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/PermissionCollection.java @@ -26,9 +26,9 @@ import org.hibernate.annotations.Cache; import org.hibernate.annotations.*; -import javax.persistence.Entity; -import javax.persistence.Table; -import javax.persistence.*; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; +import jakarta.persistence.*; import java.util.HashSet; import java.util.Objects; import java.util.Set; diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/UserClassPermission.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/UserClassPermission.java index 294b1b2f9..ad1d70cbc 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/UserClassPermission.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/UserClassPermission.java @@ -17,6 +17,10 @@ package de.terrestris.shogun.lib.model.security.permission; import de.terrestris.shogun.lib.model.User; +import jakarta.persistence.Cacheable; +import jakarta.persistence.Entity; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import lombok.*; import org.hibernate.Hibernate; import org.hibernate.annotations.Cache; @@ -25,10 +29,6 @@ import org.hibernate.envers.AuditTable; import org.hibernate.envers.Audited; -import javax.persistence.Cacheable; -import javax.persistence.Entity; -import javax.persistence.ManyToOne; -import javax.persistence.Table; import java.util.Objects; @Entity(name = "userclasspermissions") diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/UserInstancePermission.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/UserInstancePermission.java index afc5cc772..63f76f62d 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/UserInstancePermission.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/security/permission/UserInstancePermission.java @@ -17,6 +17,10 @@ package de.terrestris.shogun.lib.model.security.permission; import de.terrestris.shogun.lib.model.User; +import jakarta.persistence.Cacheable; +import jakarta.persistence.Entity; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import lombok.*; import org.hibernate.Hibernate; import org.hibernate.annotations.Cache; @@ -25,10 +29,6 @@ import org.hibernate.envers.AuditTable; import org.hibernate.envers.Audited; -import javax.persistence.Cacheable; -import javax.persistence.Entity; -import javax.persistence.ManyToOne; -import javax.persistence.Table; import java.util.Objects; @Entity(name = "userinstancepermissions") diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/ApplicationRepository.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/ApplicationRepository.java index 38fd5b329..66ee0a15a 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/ApplicationRepository.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/ApplicationRepository.java @@ -17,6 +17,8 @@ package de.terrestris.shogun.lib.repository; import de.terrestris.shogun.lib.model.Application; +import java.util.Optional; +import jakarta.persistence.QueryHint; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.QueryHints; import org.springframework.stereotype.Repository; @@ -27,7 +29,7 @@ @Repository public interface ApplicationRepository extends BaseCrudRepository, JpaSpecificationExecutor { - @QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true")) + @QueryHints(@QueryHint(name = AvailableHints.HINT_CACHEABLE, value = "true")) Optional findByName(String name); } diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/BaseCrudRepository.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/BaseCrudRepository.java index ee9eed334..3a50f9e70 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/BaseCrudRepository.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/BaseCrudRepository.java @@ -25,7 +25,7 @@ import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.history.RevisionRepository; -import javax.persistence.QueryHint; +import jakarta.persistence.QueryHint; import java.util.List; @NoRepositoryBean @@ -34,7 +34,7 @@ public interface BaseCrudRepository extends ShogunRevisionRepository, PagingAndSortingRepository { - @QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true")) + @QueryHints(@QueryHint(name = AvailableHints.HINT_CACHEABLE, value = "true")) List findAll(); /** diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/BaseFileRepository.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/BaseFileRepository.java index d19f0706a..c18ad3ea6 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/BaseFileRepository.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/BaseFileRepository.java @@ -16,6 +16,9 @@ */ package de.terrestris.shogun.lib.repository; +import java.util.Optional; +import java.util.UUID; +import jakarta.persistence.QueryHint; import org.springframework.data.jpa.repository.QueryHints; import org.springframework.data.repository.NoRepositoryBean; @@ -26,7 +29,7 @@ @NoRepositoryBean public interface BaseFileRepository extends BaseCrudRepository { - @QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true")) + @QueryHints(@QueryHint(name = AvailableHints.HINT_CACHEABLE, value = "true")) Optional findByFileUuid(UUID uuid); } diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/GroupRepository.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/GroupRepository.java index 70e860a36..f4b7a0849 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/GroupRepository.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/GroupRepository.java @@ -21,13 +21,13 @@ import org.springframework.data.jpa.repository.QueryHints; import org.springframework.stereotype.Repository; -import javax.persistence.QueryHint; +import jakarta.persistence.QueryHint; import java.util.Optional; @Repository public interface GroupRepository extends BaseCrudRepository, JpaSpecificationExecutor { - @QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true")) + @QueryHints(@QueryHint(name = AvailableHints.HINT_CACHEABLE, value = "true")) Optional findByAuthProviderId(String authProviderId); } diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/UserRepository.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/UserRepository.java index d0c1016d3..9750260d7 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/UserRepository.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/UserRepository.java @@ -21,13 +21,13 @@ import org.springframework.data.jpa.repository.QueryHints; import org.springframework.stereotype.Repository; -import javax.persistence.QueryHint; +import jakarta.persistence.QueryHint; import java.util.Optional; @Repository public interface UserRepository extends BaseCrudRepository, JpaSpecificationExecutor { - @QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true")) + @QueryHints(@QueryHint(name = AvailableHints.HINT_CACHEABLE, value = "true")) Optional findByAuthProviderId(String authProviderId); } diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/impl/ShogunRevisionRepositoryImpl.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/impl/ShogunRevisionRepositoryImpl.java index 2b479e92a..a0bd175ff 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/impl/ShogunRevisionRepositoryImpl.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/impl/ShogunRevisionRepositoryImpl.java @@ -30,7 +30,7 @@ import org.springframework.data.repository.history.support.RevisionEntityInformation; import org.springframework.util.Assert; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import java.util.ArrayList; import java.util.List; import java.util.Set; diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/security/permission/GroupClassPermissionRepository.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/security/permission/GroupClassPermissionRepository.java index 3fe738ad9..4469cc05b 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/security/permission/GroupClassPermissionRepository.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/security/permission/GroupClassPermissionRepository.java @@ -18,6 +18,9 @@ import de.terrestris.shogun.lib.model.Group; import de.terrestris.shogun.lib.model.security.permission.GroupClassPermission; +import java.util.List; +import java.util.Optional; +import jakarta.persistence.QueryHint; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.QueryHints; @@ -32,10 +35,10 @@ public interface GroupClassPermissionRepository extends BasePermissionRepository JpaSpecificationExecutor { @Query("Select gcp from groupclasspermissions gcp where gcp.group.id = ?1 and gcp.className = ?2") - @QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true")) + @QueryHints(@QueryHint(name = AvailableHints.HINT_CACHEABLE, value = "true")) Optional findByGroupIdAndClassName(Long groupId, String className); - @QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true")) + @QueryHints(@QueryHint(name = AvailableHints.HINT_CACHEABLE, value = "true")) List findAllByGroup(Group group); List findByClassName(String className); diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/security/permission/GroupInstancePermissionRepository.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/security/permission/GroupInstancePermissionRepository.java index 5a589abe3..295a788e9 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/security/permission/GroupInstancePermissionRepository.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/security/permission/GroupInstancePermissionRepository.java @@ -18,6 +18,9 @@ import de.terrestris.shogun.lib.model.Group; import de.terrestris.shogun.lib.model.security.permission.GroupInstancePermission; +import java.util.List; +import java.util.Optional; +import jakarta.persistence.QueryHint; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.QueryHints; @@ -32,13 +35,13 @@ public interface GroupInstancePermissionRepository extends BasePermissionReposit JpaSpecificationExecutor { @Query("Select gip from groupinstancepermissions gip where gip.group.id = ?1 and gip.entityId = ?2") - @QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true")) + @QueryHints(@QueryHint(name = AvailableHints.HINT_CACHEABLE, value = "true")) Optional findByGroupIdAndEntityId(Long groupId, Long entityId); - @QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true")) + @QueryHints(@QueryHint(name = AvailableHints.HINT_CACHEABLE, value = "true")) List findByEntityId(Long entityId); - @QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true")) + @QueryHints(@QueryHint(name = AvailableHints.HINT_CACHEABLE, value = "true")) List findAllByGroup(Group group); } diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/security/permission/PermissionCollectionRepository.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/security/permission/PermissionCollectionRepository.java index 1aa693a3c..53c4fcc8c 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/security/permission/PermissionCollectionRepository.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/security/permission/PermissionCollectionRepository.java @@ -18,6 +18,8 @@ import de.terrestris.shogun.lib.enumeration.PermissionCollectionType; import de.terrestris.shogun.lib.model.security.permission.PermissionCollection; +import java.util.Optional; +import jakarta.persistence.QueryHint; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.QueryHints; import org.springframework.stereotype.Repository; @@ -29,7 +31,7 @@ public interface PermissionCollectionRepository extends BasePermissionRepository, JpaSpecificationExecutor { - @QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true")) + @QueryHints(@QueryHint(name = AvailableHints.HINT_CACHEABLE, value = "true")) Optional findByName(PermissionCollectionType name); } diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/security/permission/UserClassPermissionRepository.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/security/permission/UserClassPermissionRepository.java index ed3311e2f..5b434ef6d 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/security/permission/UserClassPermissionRepository.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/security/permission/UserClassPermissionRepository.java @@ -25,7 +25,7 @@ import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; -import javax.persistence.QueryHint; +import jakarta.persistence.QueryHint; import java.util.List; import java.util.Optional; @@ -34,10 +34,10 @@ public interface UserClassPermissionRepository extends BasePermissionRepository< JpaSpecificationExecutor { @Query("Select ucp from userclasspermissions ucp where ucp.user.id = ?1 and ucp.className = ?2") - @QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true")) + @QueryHints(@QueryHint(name = AvailableHints.HINT_CACHEABLE, value = "true")) Optional findByUserIdAndClassName(Long userId, String className); - @QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true")) + @QueryHints(@QueryHint(name = AvailableHints.HINT_CACHEABLE, value = "true")) List findAllByUser(User user); @Modifying diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/security/permission/UserInstancePermissionRepository.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/security/permission/UserInstancePermissionRepository.java index 86e95ba17..3865158b3 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/security/permission/UserInstancePermissionRepository.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/security/permission/UserInstancePermissionRepository.java @@ -26,7 +26,7 @@ import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; -import javax.persistence.QueryHint; +import jakarta.persistence.QueryHint; import java.util.List; import java.util.Optional; @@ -35,20 +35,20 @@ public interface UserInstancePermissionRepository extends BasePermissionReposito JpaSpecificationExecutor { @Query("Select uip from userinstancepermissions uip where uip.user.id = ?1 and uip.entityId = ?2") - @QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true")) + @QueryHints(@QueryHint(name = AvailableHints.HINT_CACHEABLE, value = "true")) Optional findByUserIdAndEntityId(Long userId, Long entityId); - @QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true")) + @QueryHints(@QueryHint(name = AvailableHints.HINT_CACHEABLE, value = "true")) List findByEntityId(Long entityId); @Query("SELECT u FROM userinstancepermissions u LEFT JOIN u.permission p WHERE u.entityId = :entityId AND p.name = :permissionCollectionType") - @QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true")) + @QueryHints(@QueryHint(name = AvailableHints.HINT_CACHEABLE, value = "true")) List findByEntityAndPermissionCollectionType( @Param("entityId") Long entityId, @Param("permissionCollectionType") PermissionCollectionType permissionCollectionType ); - @QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true")) + @QueryHints(@QueryHint(name = AvailableHints.HINT_CACHEABLE, value = "true")) List findAllByUser(User user); @Modifying diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/service/CacheService.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/service/CacheService.java index 7af86ec78..c8f66ffd2 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/service/CacheService.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/service/CacheService.java @@ -22,9 +22,9 @@ import org.hibernate.SessionFactory; import org.springframework.stereotype.Service; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.PersistenceContext; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.PersistenceContext; @Service @Log4j2 diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/util/HttpUtil.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/util/HttpUtil.java index c16b8174a..4572701fb 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/util/HttpUtil.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/util/HttpUtil.java @@ -48,9 +48,9 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.Part; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.Part; import java.io.BufferedReader; import java.io.File; import java.io.IOException; diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/util/KeycloakUtil.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/util/KeycloakUtil.java index 1c31f070a..9fb3a1587 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/util/KeycloakUtil.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/util/KeycloakUtil.java @@ -18,9 +18,6 @@ import de.terrestris.shogun.lib.model.Group; import de.terrestris.shogun.lib.model.User; -import de.terrestris.shogun.lib.repository.GroupRepository; -import de.terrestris.shogun.lib.repository.UserRepository; -import de.terrestris.shogun.lib.security.SecurityContextUtil; import lombok.extern.log4j.Log4j2; import org.apache.commons.lang3.StringUtils; import org.keycloak.admin.client.CreatedResponseUtil; @@ -50,15 +47,6 @@ public class KeycloakUtil { @Autowired protected RealmResource keycloakRealm; - @Autowired - protected UserRepository userRepository; - - @Autowired - protected GroupRepository groupRepository; - - @Autowired - private SecurityContextUtil securityContextUtil; - public UserResource getUserResource(User user) { UsersResource kcUsers = this.keycloakRealm.users(); return kcUsers.get(user.getAuthProviderId()); @@ -173,7 +161,7 @@ public boolean isUserInGroup(User user, Group