diff --git a/build.gradle b/build.gradle index ee809ee27..0d4180c01 100644 --- a/build.gradle +++ b/build.gradle @@ -65,7 +65,6 @@ dependencies { implementation "io.micronaut:micronaut-inject" implementation "io.micronaut:micronaut-validation" implementation "io.micronaut:micronaut-runtime" - implementation "io.micronaut:micronaut-http-client" implementation "io.micronaut:micronaut-http-server-netty" implementation "io.swagger.core.v3:swagger-annotations" runtimeOnly 'ch.qos.logback:logback-classic:1.3.0-alpha5' @@ -77,6 +76,9 @@ dependencies { implementation 'io.micronaut.micrometer:micronaut-micrometer-registry-prometheus' implementation "io.micronaut.cache:micronaut-cache-core" + implementation "io.micronaut.rxjava2:micronaut-rxjava2" + implementation "io.micronaut.rxjava2:micronaut-rxjava2-http-server-netty" + // kafka implementation group: "org.apache.kafka", name: "kafka_" + kafkaScalaVersion, version: kafkaVersion implementation group: "org.apache.kafka", name: "kafka-clients", version: kafkaVersion @@ -147,6 +149,8 @@ dependencies { testImplementation "io.micronaut.test:micronaut-test-junit5" testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine" testImplementation "org.junit.jupiter:junit-jupiter-params" + testImplementation "io.micronaut:micronaut-http-client" + testImplementation "io.micronaut.rxjava2:micronaut-rxjava2-http-client" // test testImplementation "org.apache.kafka:kafka-clients:" + kafkaVersion + ":test" diff --git a/gradle.properties b/gradle.properties index da3739a04..66fb57cb9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -micronautVersion=2.5.5 +micronautVersion=3.2.0 confluentVersion=6.1.1 kafkaVersion=2.8.0 kafkaScalaVersion=2.13 diff --git a/src/main/java/io/micronaut/web/router/resource/ReactStaticResourceResolver.java b/src/main/java/io/micronaut/web/router/resource/ReactStaticResourceResolver.java index 8400287d7..2a8ae346c 100644 --- a/src/main/java/io/micronaut/web/router/resource/ReactStaticResourceResolver.java +++ b/src/main/java/io/micronaut/web/router/resource/ReactStaticResourceResolver.java @@ -7,7 +7,7 @@ import java.net.URL; import java.util.List; import java.util.Optional; -import javax.inject.Singleton; +import jakarta.inject.Singleton; @Singleton @Replaces(StaticResourceResolver.class) diff --git a/src/main/java/org/akhq/configs/JwtSecurityWarning.java b/src/main/java/org/akhq/configs/JwtSecurityWarning.java index 0a184ac6b..269ff86b3 100644 --- a/src/main/java/org/akhq/configs/JwtSecurityWarning.java +++ b/src/main/java/org/akhq/configs/JwtSecurityWarning.java @@ -5,7 +5,7 @@ import lombok.extern.slf4j.Slf4j; import javax.annotation.PostConstruct; -import javax.inject.Singleton; +import jakarta.inject.Singleton; @Singleton @Slf4j diff --git a/src/main/java/org/akhq/controllers/AbstractController.java b/src/main/java/org/akhq/controllers/AbstractController.java index 177d4e0a4..4bd08d231 100644 --- a/src/main/java/org/akhq/controllers/AbstractController.java +++ b/src/main/java/org/akhq/controllers/AbstractController.java @@ -5,7 +5,7 @@ import io.micronaut.security.utils.SecurityService; import org.akhq.utils.DefaultGroupUtils; -import javax.inject.Inject; +import jakarta.inject.Inject; import java.net.URI; import java.net.URISyntaxException; import java.util.*; @@ -56,7 +56,6 @@ protected boolean isAllowed(String role) { .anyMatch(s -> s.equals(role)); } - @SuppressWarnings("unchecked") protected List getRights() { if (!applicationContext.containsBean(SecurityService.class)) { return expandRoles(this.defaultGroupUtils.getDefaultRoles()); @@ -67,7 +66,7 @@ protected List getRights() { return expandRoles( securityService .getAuthentication() - .map(authentication -> (List) authentication.getAttributes().get("roles")) + .map(authentication -> (List) new ArrayList<>(authentication.getRoles())) .orElseGet(() -> this.defaultGroupUtils.getDefaultRoles()) ); } diff --git a/src/main/java/org/akhq/controllers/AclsController.java b/src/main/java/org/akhq/controllers/AclsController.java index 1b0641919..353828a6b 100644 --- a/src/main/java/org/akhq/controllers/AclsController.java +++ b/src/main/java/org/akhq/controllers/AclsController.java @@ -13,7 +13,7 @@ import java.util.List; import java.util.Optional; import java.util.concurrent.ExecutionException; -import javax.inject.Inject; +import jakarta.inject.Inject; @Secured(Role.ROLE_ACLS_READ) @Controller("/api/{cluster}/acls") diff --git a/src/main/java/org/akhq/controllers/AkhqController.java b/src/main/java/org/akhq/controllers/AkhqController.java index b6e380c1a..97b8fbdf4 100644 --- a/src/main/java/org/akhq/controllers/AkhqController.java +++ b/src/main/java/org/akhq/controllers/AkhqController.java @@ -1,6 +1,5 @@ package org.akhq.controllers; -import io.micronaut.configuration.security.ldap.configuration.LdapConfiguration; import io.micronaut.context.ApplicationContext; import io.micronaut.core.annotation.Introspected; import io.micronaut.core.annotation.Nullable; @@ -9,6 +8,7 @@ import io.micronaut.http.annotation.Controller; import io.micronaut.http.annotation.Get; import io.micronaut.security.annotation.Secured; +import io.micronaut.security.ldap.configuration.LdapConfiguration; import io.micronaut.security.rules.SecurityRule; import io.micronaut.security.utils.SecurityService; import io.swagger.v3.oas.annotations.Hidden; @@ -20,7 +20,7 @@ import org.akhq.modules.HasAnyPermission; import org.akhq.utils.VersionProvider; -import javax.inject.Inject; +import jakarta.inject.Inject; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; diff --git a/src/main/java/org/akhq/controllers/ConnectController.java b/src/main/java/org/akhq/controllers/ConnectController.java index cb3359ffb..6ea8ddb0e 100644 --- a/src/main/java/org/akhq/controllers/ConnectController.java +++ b/src/main/java/org/akhq/controllers/ConnectController.java @@ -23,7 +23,7 @@ import java.util.Map; import java.util.Optional; import java.util.concurrent.ExecutionException; -import javax.inject.Inject; +import jakarta.inject.Inject; @Secured(Role.ROLE_CONNECT_READ) @Controller("/api/{cluster}/connect/{connectId}") diff --git a/src/main/java/org/akhq/controllers/GroupController.java b/src/main/java/org/akhq/controllers/GroupController.java index 88e91a641..23880dfaa 100644 --- a/src/main/java/org/akhq/controllers/GroupController.java +++ b/src/main/java/org/akhq/controllers/GroupController.java @@ -32,7 +32,7 @@ import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; -import javax.inject.Inject; +import jakarta.inject.Inject; @Secured(Role.ROLE_GROUP_READ) @Controller("/api/{cluster}/group") diff --git a/src/main/java/org/akhq/controllers/NodeController.java b/src/main/java/org/akhq/controllers/NodeController.java index bffac864f..9d2e1091a 100644 --- a/src/main/java/org/akhq/controllers/NodeController.java +++ b/src/main/java/org/akhq/controllers/NodeController.java @@ -19,7 +19,7 @@ import java.util.Map; import java.util.NoSuchElementException; import java.util.concurrent.ExecutionException; -import javax.inject.Inject; +import jakarta.inject.Inject; @Secured(Role.ROLE_NODE_READ) @Controller diff --git a/src/main/java/org/akhq/controllers/SchemaController.java b/src/main/java/org/akhq/controllers/SchemaController.java index b2b791746..312d97537 100644 --- a/src/main/java/org/akhq/controllers/SchemaController.java +++ b/src/main/java/org/akhq/controllers/SchemaController.java @@ -21,7 +21,7 @@ import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; -import javax.inject.Inject; +import jakarta.inject.Inject; @Secured(Role.ROLE_REGISTRY_READ) @Controller diff --git a/src/main/java/org/akhq/controllers/TailController.java b/src/main/java/org/akhq/controllers/TailController.java index fb25a28e5..c746b34cc 100644 --- a/src/main/java/org/akhq/controllers/TailController.java +++ b/src/main/java/org/akhq/controllers/TailController.java @@ -22,7 +22,7 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; -import javax.inject.Inject; +import jakarta.inject.Inject; @Secured(Role.ROLE_TOPIC_READ) @Controller diff --git a/src/main/java/org/akhq/controllers/TopicController.java b/src/main/java/org/akhq/controllers/TopicController.java index d8fa5f202..f0267a5c2 100644 --- a/src/main/java/org/akhq/controllers/TopicController.java +++ b/src/main/java/org/akhq/controllers/TopicController.java @@ -33,7 +33,7 @@ import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; -import javax.inject.Inject; +import jakarta.inject.Inject; @Secured(Role.ROLE_TOPIC_READ) @Controller diff --git a/src/main/java/org/akhq/middlewares/HttpServerAccessLogFilter.java b/src/main/java/org/akhq/middlewares/HttpServerAccessLogFilter.java index 1bb98c7af..3b8a66969 100644 --- a/src/main/java/org/akhq/middlewares/HttpServerAccessLogFilter.java +++ b/src/main/java/org/akhq/middlewares/HttpServerAccessLogFilter.java @@ -25,7 +25,7 @@ import java.time.format.DateTimeFormatter; import java.util.List; import java.util.concurrent.TimeUnit; -import javax.inject.Singleton; +import jakarta.inject.Singleton; @Singleton @Requires(property = "akhq.server.access-log.enabled", value = StringUtils.TRUE, defaultValue = StringUtils.FALSE) diff --git a/src/main/java/org/akhq/middlewares/KafkaWrapperFilter.java b/src/main/java/org/akhq/middlewares/KafkaWrapperFilter.java index e22850ac4..a00154157 100644 --- a/src/main/java/org/akhq/middlewares/KafkaWrapperFilter.java +++ b/src/main/java/org/akhq/middlewares/KafkaWrapperFilter.java @@ -8,7 +8,7 @@ import org.akhq.modules.KafkaModule; import org.reactivestreams.Publisher; -import javax.inject.Inject; +import jakarta.inject.Inject; @Filter("/**") public class KafkaWrapperFilter implements HttpServerFilter { diff --git a/src/main/java/org/akhq/modules/AbstractKafkaWrapper.java b/src/main/java/org/akhq/modules/AbstractKafkaWrapper.java index 46c2b1e64..a58bb1e88 100644 --- a/src/main/java/org/akhq/modules/AbstractKafkaWrapper.java +++ b/src/main/java/org/akhq/modules/AbstractKafkaWrapper.java @@ -20,7 +20,7 @@ import java.util.*; import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; -import javax.inject.Inject; +import jakarta.inject.Inject; import static java.util.stream.Collectors.*; diff --git a/src/main/java/org/akhq/modules/BasicAuthAuthenticationProvider.java b/src/main/java/org/akhq/modules/BasicAuthAuthenticationProvider.java index af977b1c2..e02c5ed10 100644 --- a/src/main/java/org/akhq/modules/BasicAuthAuthenticationProvider.java +++ b/src/main/java/org/akhq/modules/BasicAuthAuthenticationProvider.java @@ -4,13 +4,13 @@ import io.micronaut.http.HttpRequest; import io.micronaut.security.authentication.*; import io.reactivex.Flowable; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import org.akhq.configs.BasicAuth; import org.akhq.configs.SecurityProperties; import org.akhq.utils.ClaimProvider; import org.reactivestreams.Publisher; -import javax.inject.Inject; -import javax.inject.Singleton; import java.util.Optional; @Singleton @@ -39,16 +39,16 @@ public Publisher authenticate(@Nullable HttpRequest h return Flowable.just(new AuthenticationFailed(AuthenticationFailureReason.CREDENTIALS_DO_NOT_MATCH)); } - ClaimProvider.AKHQClaimRequest request = - ClaimProvider.AKHQClaimRequest.builder() - .providerType(ClaimProvider.ProviderType.BASIC_AUTH) - .providerName(null) - .username(auth.getUsername()) - .groups(auth.getGroups()) - .build(); + ClaimProvider.AKHQClaimRequest request = ClaimProvider.AKHQClaimRequest.builder() + .providerType(ClaimProvider.ProviderType.BASIC_AUTH) + .providerName(null) + .username(auth.getUsername()) + .groups(auth.getGroups()) + .build(); + try { ClaimProvider.AKHQClaimResponse claim = claimProvider.generateClaim(request); - return Flowable.just(new UserDetails(auth.getUsername(), claim.getRoles(), claim.getAttributes())); + return Flowable.just(AuthenticationResponse.success(auth.getUsername(), claim.getRoles(), claim.getAttributes())); } catch (Exception e) { String claimProviderClass = claimProvider.getClass().getName(); return Flowable.just(new AuthenticationFailed("Exception from ClaimProvider " + claimProviderClass + ": " + e.getMessage())); diff --git a/src/main/java/org/akhq/modules/HeaderAuthenticationFetcher.java b/src/main/java/org/akhq/modules/HeaderAuthenticationFetcher.java index 4dee5ca0a..8123c7724 100644 --- a/src/main/java/org/akhq/modules/HeaderAuthenticationFetcher.java +++ b/src/main/java/org/akhq/modules/HeaderAuthenticationFetcher.java @@ -4,9 +4,8 @@ import io.micronaut.core.async.publisher.Publishers; import io.micronaut.http.HttpRequest; import io.micronaut.security.authentication.Authentication; -import io.micronaut.security.authentication.AuthenticationUserDetailsAdapter; import io.micronaut.security.authentication.Authenticator; -import io.micronaut.security.authentication.UserDetails; +import io.micronaut.security.authentication.ServerAuthentication; import io.micronaut.security.config.SecurityConfigurationProperties; import io.micronaut.security.filters.AuthenticationFetcher; import io.micronaut.security.token.config.TokenConfiguration; @@ -23,8 +22,8 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; import javax.annotation.PostConstruct; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; @Requires(property = "akhq.security.header-auth.user-header") @Singleton @@ -109,16 +108,10 @@ public Publisher fetchAuthentication(HttpRequest request) { }) .switchMap(t -> { if (t.isPresent()) { - UserDetails userDetails = new UserDetails( + return Flowable.just(new ServerAuthentication( userHeaders.get(), t.get().getRoles(), t.get().getAttributes() - ); - - return Flowable.just(new AuthenticationUserDetailsAdapter( - userDetails, - configuration.getRolesName(), - configuration.getNameKey() )); } else { if (log.isDebugEnabled()) { diff --git a/src/main/java/org/akhq/modules/KafkaModule.java b/src/main/java/org/akhq/modules/KafkaModule.java index 199b25808..542cab810 100644 --- a/src/main/java/org/akhq/modules/KafkaModule.java +++ b/src/main/java/org/akhq/modules/KafkaModule.java @@ -24,8 +24,8 @@ import org.sourcelab.kafka.connect.apiclient.Configuration; import org.sourcelab.kafka.connect.apiclient.KafkaConnectClient; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.io.File; import java.util.*; import java.util.stream.Collectors; @@ -91,7 +91,7 @@ private Properties getAdminProperties(String clusterId) { return props; } - private Map adminClient = new HashMap<>(); + private final Map adminClient = new HashMap<>(); public AdminClient getAdminClient(String clusterId) { if (!this.adminClient.containsKey(clusterId)) { @@ -120,7 +120,7 @@ public KafkaConsumer getConsumer(String clusterId, Properties pr ); } - private Map> producers = new HashMap<>(); + private final Map> producers = new HashMap<>(); public KafkaProducer getProducer(String clusterId) { if (!this.producers.containsKey(clusterId)) { @@ -175,9 +175,9 @@ public RestService getRegistryRestClient(String clusterId) { && !connection.getSchemaRegistry().getProperties().isEmpty()) { Map sslConfigs = - (Map) connection.getSchemaRegistry().getProperties().entrySet().stream() - .filter(e -> e.getKey().startsWith("schema.registry.")) - .collect(Collectors.toMap(e -> e.getKey().substring("schema.registry.".length()), Map.Entry::getValue)); + connection.getSchemaRegistry().getProperties().entrySet().stream() + .filter(e -> e.getKey().startsWith("schema.registry.")) + .collect(Collectors.toMap(e -> e.getKey().substring("schema.registry.".length()), Map.Entry::getValue)); SslFactory sslFactory = new SslFactory(sslConfigs); if (sslFactory != null && sslFactory.sslContext() != null) { @@ -208,7 +208,7 @@ public RestService getRegistryRestClient(String clusterId) { return null; } - private Map registryClient = new HashMap<>(); + private final Map registryClient = new HashMap<>(); public SchemaRegistryClient getRegistryClient(String clusterId) { if (!this.registryClient.containsKey(clusterId)) { @@ -233,7 +233,7 @@ public SchemaRegistryClient getRegistryClient(String clusterId) { return this.registryClient.get(clusterId); } - private Map> connectRestClient = new HashMap<>(); + private final Map> connectRestClient = new HashMap<>(); public Map getConnectRestClient(String clusterId) { if (!this.connectRestClient.containsKey(clusterId)) { diff --git a/src/main/java/org/akhq/modules/LdapContextAuthenticationMapper.java b/src/main/java/org/akhq/modules/LdapContextAuthenticationMapper.java index f7a9df962..78df1e473 100644 --- a/src/main/java/org/akhq/modules/LdapContextAuthenticationMapper.java +++ b/src/main/java/org/akhq/modules/LdapContextAuthenticationMapper.java @@ -1,23 +1,21 @@ package org.akhq.modules; -import io.micronaut.configuration.security.ldap.ContextAuthenticationMapper; -import io.micronaut.configuration.security.ldap.DefaultContextAuthenticationMapper; import io.micronaut.context.annotation.Replaces; import io.micronaut.core.convert.value.ConvertibleValues; import io.micronaut.security.authentication.AuthenticationFailed; import io.micronaut.security.authentication.AuthenticationResponse; -import io.micronaut.security.authentication.UserDetails; +import io.micronaut.security.ldap.ContextAuthenticationMapper; +import io.micronaut.security.ldap.DefaultContextAuthenticationMapper; import org.akhq.utils.ClaimProvider; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.List; import java.util.Set; @Singleton @Replaces(DefaultContextAuthenticationMapper.class) public class LdapContextAuthenticationMapper implements ContextAuthenticationMapper { - @Inject private ClaimProvider claimProvider; @@ -31,12 +29,10 @@ public AuthenticationResponse map(ConvertibleValues attributes, String u .build(); try { ClaimProvider.AKHQClaimResponse claim = claimProvider.generateClaim(request); - return new UserDetails(username, claim.getRoles(), claim.getAttributes()); + return AuthenticationResponse.success(username, claim.getRoles(), claim.getAttributes()); } catch (Exception e) { String claimProviderClass = claimProvider.getClass().getName(); return new AuthenticationFailed("Exception from ClaimProvider " + claimProviderClass + ": " + e.getMessage()); } } - - } diff --git a/src/main/java/org/akhq/modules/OidcUserDetailsMapper.java b/src/main/java/org/akhq/modules/OidcUserDetailsMapper.java index 530bdab7a..d4098fd1a 100644 --- a/src/main/java/org/akhq/modules/OidcUserDetailsMapper.java +++ b/src/main/java/org/akhq/modules/OidcUserDetailsMapper.java @@ -7,18 +7,17 @@ import io.micronaut.core.util.StringUtils; import io.micronaut.security.authentication.AuthenticationFailed; import io.micronaut.security.authentication.AuthenticationResponse; -import io.micronaut.security.authentication.UserDetails; import io.micronaut.security.config.AuthenticationModeConfiguration; import io.micronaut.security.oauth2.configuration.OpenIdAdditionalClaimsConfiguration; import io.micronaut.security.oauth2.endpoint.authorization.state.State; -import io.micronaut.security.oauth2.endpoint.token.response.DefaultOpenIdUserDetailsMapper; +import io.micronaut.security.oauth2.endpoint.token.response.DefaultOpenIdAuthenticationMapper; import io.micronaut.security.oauth2.endpoint.token.response.OpenIdClaims; import io.micronaut.security.oauth2.endpoint.token.response.OpenIdTokenResponse; import org.akhq.configs.Oidc; import org.akhq.utils.ClaimProvider; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.*; import java.util.stream.Collectors; @@ -28,9 +27,9 @@ * It will read a username and roles from the OpenID claims and translate them to akhq roles. */ @Singleton -@Replaces(DefaultOpenIdUserDetailsMapper.class) +@Replaces(DefaultOpenIdAuthenticationMapper.class) @Requires(property = "akhq.security.oidc.enabled", value = StringUtils.TRUE) -public class OidcUserDetailsMapper extends DefaultOpenIdUserDetailsMapper { +public class OidcUserDetailsMapper extends DefaultOpenIdAuthenticationMapper { @Inject private Oidc oidc; @Inject @@ -66,7 +65,7 @@ public AuthenticationResponse createAuthenticationResponse(String providerName, try { ClaimProvider.AKHQClaimResponse claim = claimProvider.generateClaim(request); - return new UserDetails(oidcUsername, claim.getRoles(), claim.getAttributes()); + return AuthenticationResponse.success(oidcUsername, claim.getRoles(), claim.getAttributes()); } catch (Exception e) { String claimProviderClass = claimProvider.getClass().getName(); return new AuthenticationFailed("Exception from ClaimProvider " + claimProviderClass + ": " + e.getMessage()); @@ -83,7 +82,7 @@ private AuthenticationResponse createDirectClaimAuthenticationResponse(String oi // keep only topicsFilterRegexp, connectsFilterRegexp, consumerGroupsFilterRegexp and potential future filters .filter(kv -> kv.getKey().matches(".*FilterRegexp$")) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - return new UserDetails(oidcUsername, roles, attributes); + return AuthenticationResponse.success(oidcUsername, roles, attributes); } return new AuthenticationFailed("Exception during Authentication: use-oidc-claim config requires attribute " + @@ -95,7 +94,7 @@ private AuthenticationResponse createDirectClaimAuthenticationResponse(String oi * * @param provider The OpenID provider * @param openIdClaims The OpenID claims - * @return The username to set in the {@link UserDetails} + * @return The username to set in the {@link io.micronaut.security.authentication.Authentication} */ protected String getUsername(Oidc.Provider provider, OpenIdClaims openIdClaims) { return Objects.toString(openIdClaims.get(provider.getUsernameField())); diff --git a/src/main/java/org/akhq/modules/SecuredAnnotationRuleWithDefault.java b/src/main/java/org/akhq/modules/SecuredAnnotationRuleWithDefault.java index f93e68464..92f28ee30 100644 --- a/src/main/java/org/akhq/modules/SecuredAnnotationRuleWithDefault.java +++ b/src/main/java/org/akhq/modules/SecuredAnnotationRuleWithDefault.java @@ -3,18 +3,20 @@ import io.micronaut.context.annotation.Replaces; import io.micronaut.core.annotation.Nullable; import io.micronaut.http.HttpRequest; +import io.micronaut.security.authentication.Authentication; import io.micronaut.security.rules.SecuredAnnotationRule; import io.micronaut.security.rules.SecurityRule; import io.micronaut.security.rules.SecurityRuleResult; import io.micronaut.security.token.RolesFinder; import io.micronaut.web.router.MethodBasedRouteMatch; import io.micronaut.web.router.RouteMatch; +import io.reactivex.Flowable; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import org.akhq.utils.DefaultGroupUtils; +import org.reactivestreams.Publisher; -import javax.inject.Inject; -import javax.inject.Singleton; import java.util.List; -import java.util.Map; @Singleton @Replaces(SecuredAnnotationRule.class) @@ -28,8 +30,8 @@ public class SecuredAnnotationRuleWithDefault extends SecuredAnnotationRule { private DefaultGroupUtils defaultGroupUtils; @Override - protected List getRoles(Map claims) { - List roles = super.getRoles(claims); + protected List getRoles(Authentication authentication) { + List roles = super.getRoles(authentication); roles.addAll(this.defaultGroupUtils.getDefaultRoles()); @@ -37,19 +39,23 @@ protected List getRoles(Map claims) { } @Override - public SecurityRuleResult check(HttpRequest request, @Nullable RouteMatch routeMatch, @Nullable Map claims) { + public Publisher check(HttpRequest request, @Nullable RouteMatch routeMatch, Authentication authentication) { if (!(routeMatch instanceof MethodBasedRouteMatch)) { - return SecurityRuleResult.UNKNOWN; + return Flowable.just(SecurityRuleResult.UNKNOWN); } + MethodBasedRouteMatch methodRoute = ((MethodBasedRouteMatch) routeMatch); if (methodRoute.hasAnnotation(HasAnyPermission.class)) { - if(getRoles(claims).stream() - .anyMatch(s -> !s.equals(SecurityRule.IS_ANONYMOUS))) { - return SecurityRuleResult.ALLOWED; + if (getRoles(authentication) + .stream() + .anyMatch(s -> !s.equals(SecurityRule.IS_ANONYMOUS)) + ) { + return Flowable.just(SecurityRuleResult.ALLOWED); } else { - return SecurityRuleResult.REJECTED; + return Flowable.just(SecurityRuleResult.REJECTED); } } - return super.check(request, routeMatch, claims); + + return super.check(request, routeMatch, authentication); } } diff --git a/src/main/java/org/akhq/modules/schemaregistry/AvroSerializer.java b/src/main/java/org/akhq/modules/schemaregistry/AvroSerializer.java index c2f0ed66b..aa8a422e5 100644 --- a/src/main/java/org/akhq/modules/schemaregistry/AvroSerializer.java +++ b/src/main/java/org/akhq/modules/schemaregistry/AvroSerializer.java @@ -18,7 +18,7 @@ import org.apache.avro.generic.GenericDatumWriter; import org.apache.avro.io.*; -import javax.inject.Singleton; +import jakarta.inject.Singleton; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.ByteBuffer; diff --git a/src/main/java/org/akhq/modules/schemaregistry/RecordWithSchemaSerializerFactory.java b/src/main/java/org/akhq/modules/schemaregistry/RecordWithSchemaSerializerFactory.java index f49e82091..d6e4b8a42 100644 --- a/src/main/java/org/akhq/modules/schemaregistry/RecordWithSchemaSerializerFactory.java +++ b/src/main/java/org/akhq/modules/schemaregistry/RecordWithSchemaSerializerFactory.java @@ -9,7 +9,7 @@ import org.akhq.configs.SchemaRegistryType; import org.akhq.modules.KafkaModule; -import javax.inject.Singleton; +import jakarta.inject.Singleton; import java.io.IOException; @Singleton diff --git a/src/main/java/org/akhq/repositories/AccessControlListRepository.java b/src/main/java/org/akhq/repositories/AccessControlListRepository.java index d9cde8e99..28d1e4455 100644 --- a/src/main/java/org/akhq/repositories/AccessControlListRepository.java +++ b/src/main/java/org/akhq/repositories/AccessControlListRepository.java @@ -12,8 +12,8 @@ import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; @Singleton public class AccessControlListRepository extends AbstractRepository { diff --git a/src/main/java/org/akhq/repositories/AvroWireFormatConverter.java b/src/main/java/org/akhq/repositories/AvroWireFormatConverter.java index 4d804ed24..1a48a1fa4 100644 --- a/src/main/java/org/akhq/repositories/AvroWireFormatConverter.java +++ b/src/main/java/org/akhq/repositories/AvroWireFormatConverter.java @@ -13,7 +13,7 @@ import java.util.Iterator; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.inject.Singleton; +import jakarta.inject.Singleton; /** * Converts an avro payload to the kafka avro wire format (https://docs.confluent.io/current/schema-registry/serializer-formatter.html#wire-format) diff --git a/src/main/java/org/akhq/repositories/ClusterRepository.java b/src/main/java/org/akhq/repositories/ClusterRepository.java index 77ff1705c..666c2aa3c 100644 --- a/src/main/java/org/akhq/repositories/ClusterRepository.java +++ b/src/main/java/org/akhq/repositories/ClusterRepository.java @@ -3,8 +3,8 @@ import org.akhq.models.Cluster; import org.akhq.modules.AbstractKafkaWrapper; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.concurrent.ExecutionException; @Singleton diff --git a/src/main/java/org/akhq/repositories/ConfigRepository.java b/src/main/java/org/akhq/repositories/ConfigRepository.java index d192f4006..674e36623 100644 --- a/src/main/java/org/akhq/repositories/ConfigRepository.java +++ b/src/main/java/org/akhq/repositories/ConfigRepository.java @@ -10,8 +10,8 @@ import java.util.concurrent.ExecutionException; import java.util.function.Function; import java.util.stream.Collectors; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; @Singleton public class ConfigRepository extends AbstractRepository { diff --git a/src/main/java/org/akhq/repositories/ConnectRepository.java b/src/main/java/org/akhq/repositories/ConnectRepository.java index 41cff1b68..00254da7b 100644 --- a/src/main/java/org/akhq/repositories/ConnectRepository.java +++ b/src/main/java/org/akhq/repositories/ConnectRepository.java @@ -21,8 +21,8 @@ import org.sourcelab.kafka.connect.apiclient.rest.exceptions.InvalidRequestException; import org.sourcelab.kafka.connect.apiclient.rest.exceptions.ResourceNotFoundException; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.io.IOException; import java.util.*; import java.util.concurrent.ExecutionException; diff --git a/src/main/java/org/akhq/repositories/ConsumerGroupRepository.java b/src/main/java/org/akhq/repositories/ConsumerGroupRepository.java index 683235898..2ecb5fa9a 100644 --- a/src/main/java/org/akhq/repositories/ConsumerGroupRepository.java +++ b/src/main/java/org/akhq/repositories/ConsumerGroupRepository.java @@ -17,8 +17,8 @@ import org.apache.kafka.clients.consumer.OffsetAndMetadata; import org.apache.kafka.common.TopicPartition; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.*; import java.util.concurrent.ExecutionException; import java.util.function.Function; diff --git a/src/main/java/org/akhq/repositories/CustomDeserializerRepository.java b/src/main/java/org/akhq/repositories/CustomDeserializerRepository.java index 9169cc8aa..fb38c5cce 100644 --- a/src/main/java/org/akhq/repositories/CustomDeserializerRepository.java +++ b/src/main/java/org/akhq/repositories/CustomDeserializerRepository.java @@ -5,8 +5,8 @@ import org.akhq.utils.AvroToJsonSerializer; import org.akhq.utils.ProtobufToJsonDeserializer; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/org/akhq/repositories/LogDirRepository.java b/src/main/java/org/akhq/repositories/LogDirRepository.java index 0facc144e..bcff6100b 100644 --- a/src/main/java/org/akhq/repositories/LogDirRepository.java +++ b/src/main/java/org/akhq/repositories/LogDirRepository.java @@ -6,8 +6,8 @@ import org.akhq.models.LogDir; import org.akhq.modules.AbstractKafkaWrapper; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.ArrayList; import java.util.List; import java.util.Map; diff --git a/src/main/java/org/akhq/repositories/RecordRepository.java b/src/main/java/org/akhq/repositories/RecordRepository.java index 36cc3be32..9b3a90185 100644 --- a/src/main/java/org/akhq/repositories/RecordRepository.java +++ b/src/main/java/org/akhq/repositories/RecordRepository.java @@ -40,8 +40,8 @@ import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; @Singleton @Slf4j diff --git a/src/main/java/org/akhq/repositories/SchemaRegistryRepository.java b/src/main/java/org/akhq/repositories/SchemaRegistryRepository.java index 790f9ba76..00e0d13d3 100644 --- a/src/main/java/org/akhq/repositories/SchemaRegistryRepository.java +++ b/src/main/java/org/akhq/repositories/SchemaRegistryRepository.java @@ -20,8 +20,8 @@ import org.akhq.utils.Pagination; import org.apache.kafka.common.serialization.Deserializer; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.*; diff --git a/src/main/java/org/akhq/repositories/TopicRepository.java b/src/main/java/org/akhq/repositories/TopicRepository.java index 1cf2a6746..8fc3f53c7 100644 --- a/src/main/java/org/akhq/repositories/TopicRepository.java +++ b/src/main/java/org/akhq/repositories/TopicRepository.java @@ -14,8 +14,8 @@ import org.akhq.utils.Pagination; import org.akhq.utils.DefaultGroupUtils; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.*; import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; diff --git a/src/main/java/org/akhq/utils/AvroToJsonSerializer.java b/src/main/java/org/akhq/utils/AvroToJsonSerializer.java index 4a104701c..118607236 100644 --- a/src/main/java/org/akhq/utils/AvroToJsonSerializer.java +++ b/src/main/java/org/akhq/utils/AvroToJsonSerializer.java @@ -5,7 +5,7 @@ import java.util.List; import java.util.Map; import java.util.TimeZone; -import javax.inject.Singleton; +import jakarta.inject.Singleton; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/src/main/java/org/akhq/utils/ConverterRegistrar.java b/src/main/java/org/akhq/utils/ConverterRegistrar.java index 1faec52f5..1a020f8e6 100644 --- a/src/main/java/org/akhq/utils/ConverterRegistrar.java +++ b/src/main/java/org/akhq/utils/ConverterRegistrar.java @@ -6,7 +6,7 @@ import java.time.Instant; import java.time.format.DateTimeParseException; import java.util.Optional; -import javax.inject.Singleton; +import jakarta.inject.Singleton; @Singleton public class ConverterRegistrar implements TypeConverterRegistrar { diff --git a/src/main/java/org/akhq/utils/DefaultGroupUtils.java b/src/main/java/org/akhq/utils/DefaultGroupUtils.java index f76e46f47..0615325b9 100644 --- a/src/main/java/org/akhq/utils/DefaultGroupUtils.java +++ b/src/main/java/org/akhq/utils/DefaultGroupUtils.java @@ -3,8 +3,8 @@ import io.micronaut.core.util.StringUtils; import org.akhq.configs.SecurityProperties; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.*; import java.util.stream.Collectors; diff --git a/src/main/java/org/akhq/utils/GroovyClaimProvider.java b/src/main/java/org/akhq/utils/GroovyClaimProvider.java index 924ccf294..f09da4751 100644 --- a/src/main/java/org/akhq/utils/GroovyClaimProvider.java +++ b/src/main/java/org/akhq/utils/GroovyClaimProvider.java @@ -8,7 +8,7 @@ import lombok.extern.slf4j.Slf4j; import javax.annotation.PostConstruct; -import javax.inject.Singleton; +import jakarta.inject.Singleton; import java.lang.reflect.InvocationTargetException; @Slf4j @@ -27,7 +27,7 @@ private void init() { try { // the file must be an implementation of ClaimProvider Interface final Class clazz = loader.parseClass(groovyFile); - groovyImpl = ClaimProvider.class.cast(clazz.getDeclaredConstructors()[0].newInstance()); + groovyImpl = (ClaimProvider) clazz.getDeclaredConstructors()[0].newInstance(); } catch (IllegalAccessException | InstantiationException | InvocationTargetException e) { log.error("Error", e); diff --git a/src/main/java/org/akhq/utils/LocalSecurityClaimProvider.java b/src/main/java/org/akhq/utils/LocalSecurityClaimProvider.java index 3d3e9f752..9ca6e87dd 100644 --- a/src/main/java/org/akhq/utils/LocalSecurityClaimProvider.java +++ b/src/main/java/org/akhq/utils/LocalSecurityClaimProvider.java @@ -4,8 +4,8 @@ import io.micronaut.core.util.StringUtils; import org.akhq.configs.*; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.ArrayList; import java.util.List; import java.util.Map; diff --git a/src/main/java/org/akhq/utils/Logger.java b/src/main/java/org/akhq/utils/Logger.java index 1888c23f5..ba05e9509 100644 --- a/src/main/java/org/akhq/utils/Logger.java +++ b/src/main/java/org/akhq/utils/Logger.java @@ -7,7 +7,7 @@ import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; -import javax.inject.Singleton; +import jakarta.inject.Singleton; @Singleton @Slf4j diff --git a/src/main/java/org/akhq/utils/LoginFailedEventListener.java b/src/main/java/org/akhq/utils/LoginFailedEventListener.java index 0ec4ef051..26e73ddac 100644 --- a/src/main/java/org/akhq/utils/LoginFailedEventListener.java +++ b/src/main/java/org/akhq/utils/LoginFailedEventListener.java @@ -1,12 +1,12 @@ package org.akhq.utils; import io.micronaut.context.event.ApplicationEventListener; +import io.micronaut.security.authentication.Authentication; import io.micronaut.security.authentication.AuthenticationFailed; -import io.micronaut.security.authentication.UserDetails; import io.micronaut.security.event.LoginFailedEvent; import lombok.extern.slf4j.Slf4j; -import javax.inject.Singleton; +import jakarta.inject.Singleton; @Singleton @Slf4j @@ -17,7 +17,7 @@ public void onApplicationEvent(LoginFailedEvent event) { AuthenticationFailed authenticationFailed = (AuthenticationFailed) event.getSource(); log.warn("Login failed reason {}, username {}, message {}", authenticationFailed.getReason(), - authenticationFailed.getUserDetails().map(UserDetails::getUsername).orElse("unknown"), + authenticationFailed.getAuthentication().map(Authentication::getName).orElse("unknown"), authenticationFailed.getMessage().orElse("none") ); } diff --git a/src/main/java/org/akhq/utils/VersionProvider.java b/src/main/java/org/akhq/utils/VersionProvider.java index a1a038e4c..37b4c35e9 100644 --- a/src/main/java/org/akhq/utils/VersionProvider.java +++ b/src/main/java/org/akhq/utils/VersionProvider.java @@ -6,8 +6,8 @@ import lombok.Getter; import javax.annotation.PostConstruct; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.Objects; import java.util.Optional; import java.util.stream.Stream; diff --git a/src/test/java/org/akhq/AbstractTest.java b/src/test/java/org/akhq/AbstractTest.java index 1a1084c62..5911ef7e3 100644 --- a/src/test/java/org/akhq/AbstractTest.java +++ b/src/test/java/org/akhq/AbstractTest.java @@ -4,7 +4,7 @@ import io.micronaut.core.annotation.NonNull; import io.micronaut.core.type.Argument; import io.micronaut.http.MutableHttpRequest; -import io.micronaut.http.client.RxHttpClient; +import io.micronaut.rxjava2.http.client.RxHttpClient; import io.micronaut.http.client.annotation.Client; import io.micronaut.test.extensions.junit5.annotation.MicronautTest; import io.micronaut.test.support.TestPropertyProvider; @@ -16,7 +16,7 @@ import java.io.IOException; import java.util.List; import java.util.Map; -import javax.inject.Inject; +import jakarta.inject.Inject; // https://github.com/micronaut-projects/micronaut-test/commit/0f32d13876decfc33f3f94238e280552422bf170#diff-985f52f80183621fbb0bc4f031044158R16 // https://github.com/micronaut-projects/micronaut-test/issues/32 diff --git a/src/test/java/org/akhq/KafkaWrapperTest.java b/src/test/java/org/akhq/KafkaWrapperTest.java index ed0b522a9..e0c7869d5 100644 --- a/src/test/java/org/akhq/KafkaWrapperTest.java +++ b/src/test/java/org/akhq/KafkaWrapperTest.java @@ -3,7 +3,7 @@ import io.micronaut.context.annotation.Replaces; import org.akhq.modules.AbstractKafkaWrapper; -import javax.inject.Singleton; +import jakarta.inject.Singleton; @Singleton @Replaces(AbstractKafkaWrapper.class) diff --git a/src/test/java/org/akhq/applications/ServerTest.java b/src/test/java/org/akhq/applications/ServerTest.java index 4a2174158..046e967b5 100644 --- a/src/test/java/org/akhq/applications/ServerTest.java +++ b/src/test/java/org/akhq/applications/ServerTest.java @@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test; import org.akhq.AbstractTest; -import javax.inject.Inject; +import jakarta.inject.Inject; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/src/test/java/org/akhq/controllers/GroupControllerTest.java b/src/test/java/org/akhq/controllers/GroupControllerTest.java index 0d0babbe2..f085d91d6 100644 --- a/src/test/java/org/akhq/controllers/GroupControllerTest.java +++ b/src/test/java/org/akhq/controllers/GroupControllerTest.java @@ -19,7 +19,7 @@ import java.util.List; import java.util.Properties; import java.util.UUID; -import javax.inject.Inject; +import jakarta.inject.Inject; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/test/java/org/akhq/controllers/HeaderAuthControllerTest.java b/src/test/java/org/akhq/controllers/HeaderAuthControllerTest.java index 7357777ce..aa1623c1e 100644 --- a/src/test/java/org/akhq/controllers/HeaderAuthControllerTest.java +++ b/src/test/java/org/akhq/controllers/HeaderAuthControllerTest.java @@ -1,13 +1,13 @@ package org.akhq.controllers; import io.micronaut.http.HttpRequest; -import io.micronaut.http.client.RxHttpClient; +import io.micronaut.rxjava2.http.client.RxHttpClient; import io.micronaut.http.client.annotation.Client; import io.micronaut.test.extensions.junit5.annotation.MicronautTest; import org.akhq.AbstractTest; import org.junit.jupiter.api.Test; -import javax.inject.Inject; +import jakarta.inject.Inject; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; diff --git a/src/test/java/org/akhq/controllers/SseControllerTest.java b/src/test/java/org/akhq/controllers/SseControllerTest.java index ab2035e5d..f7b37630e 100644 --- a/src/test/java/org/akhq/controllers/SseControllerTest.java +++ b/src/test/java/org/akhq/controllers/SseControllerTest.java @@ -1,7 +1,7 @@ package org.akhq.controllers; import io.micronaut.context.annotation.Property; -import io.micronaut.http.client.sse.RxSseClient; +import io.micronaut.rxjava2.http.client.sse.RxSseClient; import io.micronaut.runtime.server.EmbeddedServer; import org.akhq.AbstractTest; import org.akhq.KafkaTestCluster; @@ -11,7 +11,7 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.inject.Inject; +import jakarta.inject.Inject; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; diff --git a/src/test/java/org/akhq/modules/BasicAuthAuthenticationProviderTest.java b/src/test/java/org/akhq/modules/BasicAuthAuthenticationProviderTest.java index 419779e00..af181ba84 100644 --- a/src/test/java/org/akhq/modules/BasicAuthAuthenticationProviderTest.java +++ b/src/test/java/org/akhq/modules/BasicAuthAuthenticationProviderTest.java @@ -7,7 +7,7 @@ import java.util.Collection; import java.util.List; -import javax.inject.Inject; +import jakarta.inject.Inject; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; @@ -26,20 +26,17 @@ void success() { "pass" ))).blockingFirst(); - assertThat(response, instanceOf(UserDetails.class)); + assertTrue(response.isAuthenticated()); + assertTrue(response.getAuthentication().isPresent()); + assertEquals("user", response.getAuthentication().get().getName()); - UserDetails userDetail = (UserDetails) response; - - assertTrue(userDetail.isAuthenticated()); - assertEquals("user", userDetail.getUsername()); - - Collection roles = userDetail.getRoles(); + Collection roles = response.getAuthentication().get().getRoles(); assertThat(roles, hasSize(4)); assertThat(roles, hasItem("topic/read")); assertThat(roles, hasItem("registry/version/delete")); - assertEquals("test.*", ((List) userDetail.getAttributes("roles", "username").get("topicsFilterRegexp")).get(0)); + assertEquals("test.*", ((List) response.getAuthentication().get().getAttributes().get("topicsFilterRegexp")).get(0)); } @Test @@ -50,20 +47,18 @@ void successCase() { "pass" ))).blockingFirst(); - assertThat(response, instanceOf(UserDetails.class)); - - UserDetails userDetail = (UserDetails) response; - assertTrue(userDetail.isAuthenticated()); - assertEquals("MyUser3!@yàhöù.com", userDetail.getUsername()); + assertTrue(response.isAuthenticated()); + assertTrue(response.getAuthentication().isPresent()); + assertEquals("MyUser3!@yàhöù.com", response.getAuthentication().get().getName()); - Collection roles = userDetail.getRoles(); + Collection roles = response.getAuthentication().get().getRoles(); assertThat(roles, hasSize(4)); assertThat(roles, hasItem("topic/read")); assertThat(roles, hasItem("registry/version/delete")); - assertEquals("test.*", ((List) userDetail.getAttributes("roles", "username").get("topicsFilterRegexp")).get(0)); + assertEquals("test.*", ((List) response.getAuthentication().get().getAttributes().get("topicsFilterRegexp")).get(0)); } @Test diff --git a/src/test/java/org/akhq/modules/GroovyClaimProviderTest.java b/src/test/java/org/akhq/modules/GroovyClaimProviderTest.java index 663eb8957..12962248c 100644 --- a/src/test/java/org/akhq/modules/GroovyClaimProviderTest.java +++ b/src/test/java/org/akhq/modules/GroovyClaimProviderTest.java @@ -1,13 +1,12 @@ package org.akhq.modules; import io.micronaut.security.authentication.AuthenticationResponse; -import io.micronaut.security.authentication.UserDetails; import io.micronaut.security.authentication.UsernamePasswordCredentials; import io.micronaut.test.extensions.junit5.annotation.MicronautTest; import io.reactivex.Flowable; import org.junit.jupiter.api.Test; -import javax.inject.Inject; +import jakarta.inject.Inject; import java.util.Collection; import java.util.List; @@ -30,18 +29,16 @@ void successUser() { "pass" ))).blockingFirst(); - assertThat(response, instanceOf(UserDetails.class)); - UserDetails userDetail = (UserDetails) response; + assertTrue(response.isAuthenticated()); + assertTrue(response.getAuthentication().isPresent()); + assertEquals("user", response.getAuthentication().get().getName()); - assertTrue(userDetail.isAuthenticated()); - assertEquals("user", userDetail.getUsername()); - - Collection roles = userDetail.getRoles(); + Collection roles = response.getAuthentication().get().getRoles(); assertThat(roles, hasSize(1)); assertThat(roles, hasItem("topic/read")); - assertEquals("single-topic", ((List) userDetail.getAttributes("roles", "username").get("topicsFilterRegexp")).get(0)); + assertEquals("single-topic", ((List) response.getAuthentication().get().getAttributes().get("topicsFilterRegexp")).get(0)); } } diff --git a/src/test/java/org/akhq/modules/LdapAuthenticationProviderTest.java b/src/test/java/org/akhq/modules/LdapAuthenticationProviderTest.java index ecf17bb87..e62a45c33 100644 --- a/src/test/java/org/akhq/modules/LdapAuthenticationProviderTest.java +++ b/src/test/java/org/akhq/modules/LdapAuthenticationProviderTest.java @@ -1,10 +1,11 @@ package org.akhq.modules; -import io.micronaut.configuration.security.ldap.LdapAuthenticationProvider; -import io.micronaut.configuration.security.ldap.context.*; -import io.micronaut.configuration.security.ldap.group.DefaultLdapGroupProcessor; -import io.micronaut.configuration.security.ldap.group.LdapGroupProcessor; + import io.micronaut.security.authentication.*; +import io.micronaut.security.ldap.LdapAuthenticationProvider; +import io.micronaut.security.ldap.context.*; +import io.micronaut.security.ldap.group.DefaultLdapGroupProcessor; +import io.micronaut.security.ldap.group.LdapGroupProcessor; import io.micronaut.test.annotation.MockBean; import io.micronaut.test.extensions.junit5.annotation.MicronautTest; import io.reactivex.Flowable; @@ -12,8 +13,8 @@ import org.junit.jupiter.api.TestInstance; import java.util.*; -import javax.inject.Inject; -import javax.inject.Named; +import jakarta.inject.Inject; +import jakarta.inject.Named; import javax.naming.NamingException; import javax.naming.directory.BasicAttributes; import javax.naming.directory.DirContext; @@ -61,7 +62,6 @@ LdapGroupProcessor ldapGroupProcessor() { @Test void success() throws NamingException { - Optional optionalResult = Optional.of(new LdapSearchResult(new BasicAttributes(), "dn")); List listResults = Collections.singletonList(new LdapSearchResult(new BasicAttributes(), "dn")); @@ -78,22 +78,21 @@ void success() throws NamingException { "pass" ))).blockingFirst(); - assertThat(response, instanceOf(UserDetails.class)); - - UserDetails userDetail = (UserDetails) response; - assertTrue(userDetail.isAuthenticated()); - assertEquals("user", userDetail.getUsername()); + assertTrue(response.isAuthenticated()); + assertTrue(response.getAuthentication().isPresent()); + assertEquals("user", response.getAuthentication().get().getName()); - Collection roles = userDetail.getRoles(); + Collection roles = response.getAuthentication().get().getRoles(); assertThat(roles, hasSize(4)); assertThat(roles, hasItem("topic/read")); assertThat(roles, hasItem("registry/version/delete")); - assertEquals("test.*", ((List) userDetail.getAttributes("roles", "username").get("topicsFilterRegexp")).get(0)); + assertEquals("test.*", ((List) response.getAuthentication().get().getAttributes().get("topicsFilterRegexp")).get(0)); } + @SuppressWarnings("unchecked") @Test void successWithMultipleLdapGroups() throws NamingException { @@ -113,29 +112,26 @@ void successWithMultipleLdapGroups() throws NamingException { "pass" ))).blockingFirst(); - assertThat(response, instanceOf(UserDetails.class)); + assertTrue(response.isAuthenticated()); + assertTrue(response.getAuthentication().isPresent()); + assertEquals("user", response.getAuthentication().get().getName()); - UserDetails userDetail = (UserDetails) response; - - assertTrue(userDetail.isAuthenticated()); - assertEquals("user", userDetail.getUsername()); - - Collection roles = userDetail.getRoles(); + Collection roles = response.getAuthentication().get().getRoles(); assertThat(roles, hasSize(7)); assertThat(roles, hasItem("topic/read")); assertThat(roles, hasItem("registry/version/delete")); assertThat(roles, hasItem("topic/data/read")); - List topicsFilterList = (List) (userDetail.getAttributes("roles", "username").get("topicsFilterRegexp")); + List topicsFilterList = (List) (response.getAuthentication().get().getAttributes().get("topicsFilterRegexp")); assertThat(topicsFilterList, hasSize(2)); assertThat(topicsFilterList, hasItem("test.*")); assertThat(topicsFilterList, hasItem("test-operator.*")); } + @SuppressWarnings("unchecked") @Test void successWithLdapGroupAndUserRole() throws NamingException { - Optional optionalResult = Optional.of(new LdapSearchResult(new BasicAttributes(), "dn")); List listResults = Collections.singletonList(new LdapSearchResult(new BasicAttributes(), "dn")); @@ -144,7 +140,7 @@ void successWithLdapGroupAndUserRole() throws NamingException { when(ldapSearchService.searchFirst(any(DirContext.class), any(SearchSettings.class))).thenReturn(optionalResult); when(ldapSearchService.search(any(DirContext.class), any(SearchSettings.class))).thenReturn(listResults); - when(ldapGroupProcessor.process(anyString(), any(LdapSearchResult.class), any(SearchProvider.class))).thenReturn(new HashSet<>(Arrays.asList("ldap-admin"))); + when(ldapGroupProcessor.process(anyString(), any(LdapSearchResult.class), any(SearchProvider.class))).thenReturn(new HashSet<>(List.of("ldap-admin"))); AuthenticationResponse response = Flowable .fromPublisher(ldapAuthenticationProvider.authenticate(null, new UsernamePasswordCredentials( @@ -152,21 +148,18 @@ void successWithLdapGroupAndUserRole() throws NamingException { "pass" ))).blockingFirst(); - assertThat(response, instanceOf(UserDetails.class)); + assertTrue(response.isAuthenticated()); + assertTrue(response.getAuthentication().isPresent()); + assertEquals("user2", response.getAuthentication().get().getName()); - UserDetails userDetail = (UserDetails) response; - - assertTrue(userDetail.isAuthenticated()); - assertEquals("user2", userDetail.getUsername()); - - Collection roles = userDetail.getRoles(); + Collection roles = response.getAuthentication().get().getRoles(); assertThat(roles, hasSize(7)); assertThat(roles, hasItem("topic/read")); assertThat(roles, hasItem("registry/version/delete")); assertThat(roles, hasItem("topic/data/read")); - List topicsFilterList = (List) (userDetail.getAttributes("roles", "username").get("topicsFilterRegexp")); + List topicsFilterList = (List) (response.getAuthentication().get().getAttributes().get("topicsFilterRegexp")); assertThat(topicsFilterList, hasSize(2)); assertThat(topicsFilterList, hasItem("test.*")); assertThat(topicsFilterList, hasItem("test-operator.*")); @@ -174,7 +167,6 @@ void successWithLdapGroupAndUserRole() throws NamingException { @Test void successWithoutRoles() throws NamingException { - Optional optionalResult = Optional.of(new LdapSearchResult(new BasicAttributes(), "dn")); List listResults = Collections.singletonList(new LdapSearchResult(new BasicAttributes(), "dn")); @@ -191,20 +183,16 @@ void successWithoutRoles() throws NamingException { "pass" ))).blockingFirst(); - assertThat(response, instanceOf(UserDetails.class)); + assertTrue(response.isAuthenticated()); + assertTrue(response.getAuthentication().isPresent()); + assertEquals("user", response.getAuthentication().get().getName()); - UserDetails userDetail = (UserDetails) response; - - assertTrue(userDetail.isAuthenticated()); - assertEquals("user", userDetail.getUsername()); - - Collection roles = userDetail.getRoles(); + Collection roles = response.getAuthentication().get().getRoles(); assertThat(roles, hasSize(0)); } @Test void failure() throws NamingException { - Optional optionalResult = Optional.empty(); when(contextBuilder.build(any(ContextSettings.class))).thenReturn(new InitialLdapContext()); @@ -220,6 +208,7 @@ void failure() throws NamingException { }); assertThat(authenticationException.getResponse(), instanceOf(AuthenticationFailed.class)); + assertNotNull(authenticationException.getResponse()); assertFalse(authenticationException.getResponse().isAuthenticated()); } } diff --git a/src/test/java/org/akhq/modules/OidcAuthenticationProviderTest.java b/src/test/java/org/akhq/modules/OidcAuthenticationProviderTest.java index 6e821c72f..3ddbe3fc4 100644 --- a/src/test/java/org/akhq/modules/OidcAuthenticationProviderTest.java +++ b/src/test/java/org/akhq/modules/OidcAuthenticationProviderTest.java @@ -18,8 +18,8 @@ import org.mockito.ArgumentMatchers; import org.mockito.Mockito; -import javax.inject.Inject; -import javax.inject.Named; +import jakarta.inject.Inject; +import jakarta.inject.Named; import java.util.Collection; import java.util.List; import java.util.Optional; @@ -42,9 +42,6 @@ class OidcAuthenticationProviderTest { @Inject OpenIdTokenResponseValidator openIdTokenResponseValidator; - @Inject - DefaultOpenIdProviderMetadata defaultOpenIdProviderMetadata; - @Inject AkhqController akhqController; @@ -85,26 +82,22 @@ void successSingleOidcGroup() { "pass" ))).blockingFirst(); - assertThat(response, instanceOf(UserDetails.class)); - - UserDetails userDetail = (UserDetails) response; + assertTrue(response.isAuthenticated()); + assertTrue(response.getAuthentication().isPresent()); + assertEquals("user", response.getAuthentication().get().getName()); - assertTrue(userDetail.isAuthenticated()); - assertEquals("user", userDetail.getUsername()); - - Collection roles = userDetail.getRoles(); + Collection roles = response.getAuthentication().get().getRoles(); assertThat(roles, hasSize(4)); assertThat(roles, hasItem("topic/read")); assertThat(roles, hasItem("registry/version/delete")); - assertEquals("test.*", ((List) userDetail.getAttributes("roles", "username").get("topicsFilterRegexp")).get(0)); - + assertEquals("test.*", ((List) response.getAuthentication().get().getAttributes().get("topicsFilterRegexp")).get(0)); } + @SuppressWarnings("unchecked") @Test void successWithMultipleOidcGroups() { - JWTClaimsSet claimsSet = new JWTClaimsSet.Builder() .claim(OpenIdClaims.CLAIMS_PREFERRED_USERNAME, "user") .claim("roles", List.of("oidc-limited-group", "oidc-operator-group")) @@ -122,29 +115,26 @@ void successWithMultipleOidcGroups() { "pass" ))).blockingFirst(); - assertThat(response, instanceOf(UserDetails.class)); - - UserDetails userDetail = (UserDetails) response; + assertTrue(response.isAuthenticated()); + assertTrue(response.getAuthentication().isPresent()); + assertEquals("user", response.getAuthentication().get().getName()); - assertTrue(userDetail.isAuthenticated()); - assertEquals("user", userDetail.getUsername()); - - Collection roles = userDetail.getRoles(); + Collection roles = response.getAuthentication().get().getRoles(); assertThat(roles, hasSize(7)); assertThat(roles, hasItem("topic/read")); assertThat(roles, hasItem("registry/version/delete")); assertThat(roles, hasItem("topic/data/read")); - List topicsFilterList = (List) (userDetail.getAttributes("roles", "username").get("topicsFilterRegexp")); + List topicsFilterList = (List) (response.getAuthentication().get().getAttributes().get("topicsFilterRegexp")); assertThat(topicsFilterList, hasSize(2)); assertThat(topicsFilterList, hasItem("test.*")); assertThat(topicsFilterList, hasItem("test-operator.*")); } + @SuppressWarnings("unchecked") @Test void successWithOidcGroupAndUserRole() { - JWTClaimsSet claimsSet = new JWTClaimsSet.Builder() .claim(OpenIdClaims.CLAIMS_PREFERRED_USERNAME, "user2") .claim("roles", List.of("oidc-limited-group")) @@ -162,21 +152,18 @@ void successWithOidcGroupAndUserRole() { "pass" ))).blockingFirst(); - assertThat(response, instanceOf(UserDetails.class)); + assertTrue(response.isAuthenticated()); + assertTrue(response.getAuthentication().isPresent()); + assertEquals("user2", response.getAuthentication().get().getName()); - UserDetails userDetail = (UserDetails) response; - - assertTrue(userDetail.isAuthenticated()); - assertEquals("user2", userDetail.getUsername()); - - Collection roles = userDetail.getRoles(); + Collection roles = response.getAuthentication().get().getRoles(); assertThat(roles, hasSize(7)); assertThat(roles, hasItem("topic/read")); assertThat(roles, hasItem("registry/version/delete")); assertThat(roles, hasItem("topic/data/read")); - List topicsFilterList = (List) (userDetail.getAttributes("roles", "username").get("topicsFilterRegexp")); + List topicsFilterList = (List) (response.getAuthentication().get().getAttributes().get("topicsFilterRegexp")); assertThat(topicsFilterList, hasSize(2)); assertThat(topicsFilterList, hasItem("test.*")); assertThat(topicsFilterList, hasItem("test-operator.*")); @@ -184,7 +171,6 @@ void successWithOidcGroupAndUserRole() { @Test void successWithoutRoles() { - JWTClaimsSet claimsSet = new JWTClaimsSet.Builder() .claim(OpenIdClaims.CLAIMS_PREFERRED_USERNAME, "user") .claim("roles", List.of("oidc-other-group")) @@ -202,14 +188,10 @@ void successWithoutRoles() { "pass" ))).blockingFirst(); - assertThat(response, instanceOf(UserDetails.class)); - - UserDetails userDetail = (UserDetails) response; + assertTrue(response.isAuthenticated()); + assertEquals("user", response.getAuthentication().get().getName()); - assertTrue(userDetail.isAuthenticated()); - assertEquals("user", userDetail.getUsername()); - - Collection roles = userDetail.getRoles(); + Collection roles = response.getAuthentication().get().getRoles(); assertThat(roles, hasSize(0)); } @@ -221,15 +203,14 @@ void failure() { Mockito.when(openIdTokenResponseValidator.validate(ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any())) .thenReturn(Optional.empty()); - AuthenticationException authenticationException = assertThrows(AuthenticationException.class, () -> { - Flowable - .fromPublisher(oidcProvider.authenticate(null, new UsernamePasswordCredentials( - "user", - "pass" - ))).blockingFirst(); - }); + AuthenticationException authenticationException = assertThrows(AuthenticationException.class, () -> Flowable + .fromPublisher(oidcProvider.authenticate(null, new UsernamePasswordCredentials( + "user", + "pass" + ))).blockingFirst()); assertThat(authenticationException.getResponse(), instanceOf(AuthenticationFailed.class)); + assertNotNull(authenticationException.getResponse()); assertFalse(authenticationException.getResponse().isAuthenticated()); } diff --git a/src/test/java/org/akhq/modules/OidcDirectClaimAuthenticationProviderTest.java b/src/test/java/org/akhq/modules/OidcDirectClaimAuthenticationProviderTest.java index 565daa691..99ff1d11e 100644 --- a/src/test/java/org/akhq/modules/OidcDirectClaimAuthenticationProviderTest.java +++ b/src/test/java/org/akhq/modules/OidcDirectClaimAuthenticationProviderTest.java @@ -13,13 +13,12 @@ import io.micronaut.test.annotation.MockBean; import io.micronaut.test.extensions.junit5.annotation.MicronautTest; import io.reactivex.Flowable; -import org.akhq.controllers.AkhqController; import org.junit.jupiter.api.Test; import org.mockito.ArgumentMatchers; import org.mockito.Mockito; -import javax.inject.Inject; -import javax.inject.Named; +import jakarta.inject.Inject; +import jakarta.inject.Named; import java.util.Collection; import java.util.List; import java.util.Map; @@ -43,12 +42,6 @@ class OidcDirectClaimAuthenticationProviderTest { @Inject OpenIdTokenResponseValidator openIdTokenResponseValidator; - @Inject - DefaultOpenIdProviderMetadata defaultOpenIdProviderMetadata; - - @Inject - AkhqController akhqController; - @Named("oidc") @MockBean(TokenEndpointClient.class) TokenEndpointClient tokenEndpointClient() { @@ -89,25 +82,21 @@ void successSingleOidcGroup() { "pass" ))).blockingFirst(); - assertThat(response, instanceOf(UserDetails.class)); - - UserDetails userDetail = (UserDetails) response; + assertTrue(response.isAuthenticated()); + assertTrue(response.getAuthentication().isPresent()); + assertEquals("user", response.getAuthentication().get().getName()); - assertTrue(userDetail.isAuthenticated()); - assertEquals("user", userDetail.getUsername()); - - Collection roles = userDetail.getRoles(); + Collection roles = response.getAuthentication().get().getRoles(); assertThat(roles, hasSize(1)); assertThat(roles, hasItem("topic/read")); - Map attributes = userDetail.getAttributes("roles", "username"); + Map attributes = response.getAuthentication().get().getAttributes(); assertThat(attributes.keySet(), hasItem("topicsFilterRegexp")); assertThat(attributes.keySet(), hasItem("connectsFilterRegexp")); assertThat(attributes.keySet(), hasItem("consumerGroupsFilterRegexp")); - assertEquals("^topic1$", ((List) attributes.get("topicsFilterRegexp")).get(0)); - + assertEquals("^topic1$", ((List) attributes.get("topicsFilterRegexp")).get(0)); } @Test @@ -137,23 +126,18 @@ void successSingleOidcGroup_KeepsAllFilterRegexp() { "pass" ))).blockingFirst(); - assertThat(response, instanceOf(UserDetails.class)); - - UserDetails userDetail = (UserDetails) response; - - assertTrue(userDetail.isAuthenticated()); - assertEquals("user", userDetail.getUsername()); + assertTrue(response.isAuthenticated()); + assertTrue(response.getAuthentication().isPresent()); + assertEquals("user", response.getAuthentication().get().getName()); - Collection roles = userDetail.getRoles(); + Collection roles = response.getAuthentication().get().getRoles(); assertThat(roles, hasSize(1)); assertThat(roles, hasItem("topic/read")); - Map attributes = userDetail.getAttributes("roles", "username"); + Map attributes = response.getAuthentication().get().getAttributes(); - assertEquals(6, attributes.size()); - assertThat(attributes.keySet(), hasItem("username")); - assertThat(attributes.keySet(), hasItem("roles")); + assertEquals(4, attributes.size()); assertThat(attributes.keySet(), hasItem("topicsFilterRegexp")); assertThat(attributes.keySet(), hasItem("connectsFilterRegexp")); assertThat(attributes.keySet(), hasItem("consumerGroupsFilterRegexp")); diff --git a/src/test/java/org/akhq/repositories/AccessControlRepositoryTest.java b/src/test/java/org/akhq/repositories/AccessControlRepositoryTest.java index e3bdccfa8..ad119b11c 100644 --- a/src/test/java/org/akhq/repositories/AccessControlRepositoryTest.java +++ b/src/test/java/org/akhq/repositories/AccessControlRepositoryTest.java @@ -10,7 +10,7 @@ import java.util.List; import java.util.Optional; import java.util.concurrent.ExecutionException; -import javax.inject.Inject; +import jakarta.inject.Inject; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/test/java/org/akhq/repositories/ConfigRepositoryTest.java b/src/test/java/org/akhq/repositories/ConfigRepositoryTest.java index 71bb381c1..2588d23a5 100644 --- a/src/test/java/org/akhq/repositories/ConfigRepositoryTest.java +++ b/src/test/java/org/akhq/repositories/ConfigRepositoryTest.java @@ -5,7 +5,7 @@ import org.akhq.KafkaTestCluster; import org.akhq.models.Config; -import javax.inject.Inject; +import jakarta.inject.Inject; import java.util.Arrays; import java.util.Collections; import java.util.concurrent.ExecutionException; diff --git a/src/test/java/org/akhq/repositories/ConnectRepositoryTest.java b/src/test/java/org/akhq/repositories/ConnectRepositoryTest.java index 60901ce59..b43e84fdc 100644 --- a/src/test/java/org/akhq/repositories/ConnectRepositoryTest.java +++ b/src/test/java/org/akhq/repositories/ConnectRepositoryTest.java @@ -2,7 +2,7 @@ import io.micronaut.context.ApplicationContext; import io.micronaut.security.authentication.Authentication; -import io.micronaut.security.authentication.DefaultAuthentication; +import io.micronaut.security.authentication.ServerAuthentication; import io.micronaut.security.utils.DefaultSecurityService; import io.micronaut.security.utils.SecurityService; import com.google.common.collect.ImmutableMap; @@ -18,7 +18,7 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import javax.inject.Inject; +import jakarta.inject.Inject; import java.util.*; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -155,7 +155,7 @@ void create() { } private void mockApplicationContext() { - Authentication auth = new DefaultAuthentication("test", Collections.singletonMap("connectsFilterRegexp", new ArrayList<>(Arrays.asList("^prefixed.*$")))); + Authentication auth = new ServerAuthentication("test", List.of(), Collections.singletonMap("connectsFilterRegexp", new ArrayList<>(Arrays.asList("^prefixed.*$")))); DefaultSecurityService securityService = Mockito.mock(DefaultSecurityService.class); when(securityService.getAuthentication()).thenReturn(Optional.of(auth)); when(applicationContext.containsBean(SecurityService.class)).thenReturn(true); diff --git a/src/test/java/org/akhq/repositories/ConsumerGroupRepositoryTest.java b/src/test/java/org/akhq/repositories/ConsumerGroupRepositoryTest.java index ff780a4d3..4860eaa3c 100644 --- a/src/test/java/org/akhq/repositories/ConsumerGroupRepositoryTest.java +++ b/src/test/java/org/akhq/repositories/ConsumerGroupRepositoryTest.java @@ -2,7 +2,7 @@ import io.micronaut.context.ApplicationContext; import io.micronaut.security.authentication.Authentication; -import io.micronaut.security.authentication.DefaultAuthentication; +import io.micronaut.security.authentication.ServerAuthentication; import io.micronaut.security.utils.DefaultSecurityService; import io.micronaut.security.utils.SecurityService; import org.akhq.AbstractTest; @@ -16,7 +16,7 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import javax.inject.Inject; +import jakarta.inject.Inject; import java.util.*; import java.util.concurrent.ExecutionException; @@ -87,7 +87,7 @@ void findByNameWithTopicRegex() throws ExecutionException, InterruptedException } private void mockApplicationContext() { - Authentication auth = new DefaultAuthentication("test", Collections.singletonMap("consumerGroupsFilterRegexp", new ArrayList<>(Arrays.asList("consumer-.*")))); + Authentication auth = new ServerAuthentication("test", List.of(), Collections.singletonMap("consumerGroupsFilterRegexp", new ArrayList<>(Arrays.asList("consumer-.*")))); DefaultSecurityService securityService = Mockito.mock(DefaultSecurityService.class); when(securityService.getAuthentication()).thenReturn(Optional.of(auth)); when(applicationContext.containsBean(SecurityService.class)).thenReturn(true); diff --git a/src/test/java/org/akhq/repositories/RecordRepositoryTest.java b/src/test/java/org/akhq/repositories/RecordRepositoryTest.java index 8919c5ee5..d8451559d 100644 --- a/src/test/java/org/akhq/repositories/RecordRepositoryTest.java +++ b/src/test/java/org/akhq/repositories/RecordRepositoryTest.java @@ -17,7 +17,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import javax.inject.Inject; +import jakarta.inject.Inject; import java.io.IOException; import java.util.*; import java.util.concurrent.ExecutionException; diff --git a/src/test/java/org/akhq/repositories/SchemaRegistryRepositoryTest.java b/src/test/java/org/akhq/repositories/SchemaRegistryRepositoryTest.java index a0f0ec4b5..600477dc3 100644 --- a/src/test/java/org/akhq/repositories/SchemaRegistryRepositoryTest.java +++ b/src/test/java/org/akhq/repositories/SchemaRegistryRepositoryTest.java @@ -12,7 +12,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import javax.inject.Inject; +import jakarta.inject.Inject; import java.io.IOException; import java.util.Collections; import java.util.List; diff --git a/src/test/java/org/akhq/repositories/TopicRepositoryTest.java b/src/test/java/org/akhq/repositories/TopicRepositoryTest.java index 3af1eb8e5..533617163 100644 --- a/src/test/java/org/akhq/repositories/TopicRepositoryTest.java +++ b/src/test/java/org/akhq/repositories/TopicRepositoryTest.java @@ -2,7 +2,7 @@ import io.micronaut.context.ApplicationContext; import io.micronaut.security.authentication.Authentication; -import io.micronaut.security.authentication.DefaultAuthentication; +import io.micronaut.security.authentication.ServerAuthentication; import io.micronaut.security.utils.DefaultSecurityService; import io.micronaut.security.utils.SecurityService; import org.apache.kafka.common.config.TopicConfig; @@ -21,7 +21,7 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import javax.inject.Inject; +import jakarta.inject.Inject; import java.util.*; import java.util.concurrent.ExecutionException; @@ -166,7 +166,7 @@ void partition() throws ExecutionException, InterruptedException { } private void mockApplicationContext() { - Authentication auth = new DefaultAuthentication("test", Collections.singletonMap("topicsFilterRegexp", new ArrayList<>(Arrays.asList("rando.*")))); + Authentication auth = new ServerAuthentication("test", List.of(), Collections.singletonMap("topicsFilterRegexp", new ArrayList<>(Arrays.asList("rando.*")))); DefaultSecurityService securityService = Mockito.mock(DefaultSecurityService.class); when(securityService.getAuthentication()).thenReturn(Optional.of(auth)); when(applicationContext.containsBean(SecurityService.class)).thenReturn(true);