diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcAuthenticationMechanism.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcAuthenticationMechanism.java index 7ba3da804c859..26a97a7a8b64d 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcAuthenticationMechanism.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcAuthenticationMechanism.java @@ -4,9 +4,7 @@ import java.util.Set; import java.util.function.Function; -import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; import io.quarkus.oidc.OIDCException; import io.quarkus.oidc.OidcTenantConfig; @@ -24,23 +22,22 @@ @ApplicationScoped public class OidcAuthenticationMechanism implements HttpAuthenticationMechanism { - @Inject - DefaultTenantConfigResolver resolver; + private final BearerAuthenticationMechanism bearerAuth = new BearerAuthenticationMechanism(); + private final CodeAuthenticationMechanism codeAuth = new CodeAuthenticationMechanism(); - private BearerAuthenticationMechanism bearerAuth = new BearerAuthenticationMechanism(); - private CodeAuthenticationMechanism codeAuth = new CodeAuthenticationMechanism(); + private final DefaultTenantConfigResolver resolver; - @PostConstruct - public void init() { - bearerAuth.setResolver(resolver); - codeAuth.setResolver(resolver); + public OidcAuthenticationMechanism(DefaultTenantConfigResolver resolver) { + this.resolver = resolver; + this.bearerAuth.setResolver(resolver); + this.codeAuth.setResolver(resolver); } @Override public Uni authenticate(RoutingContext context, IdentityProviderManager identityProviderManager) { setTenantIdAttribute(context); - return resolve(context).chain(new Function>() { + return resolve(context).chain(new Function<>() { @Override public Uni apply(OidcTenantConfig oidcConfig) { if (!oidcConfig.tenantEnabled) { @@ -55,7 +52,7 @@ public Uni apply(OidcTenantConfig oidcConfig) { @Override public Uni getChallenge(RoutingContext context) { setTenantIdAttribute(context); - return resolve(context).chain(new Function>() { + return resolve(context).chain(new Function<>() { @Override public Uni apply(OidcTenantConfig oidcTenantConfig) { if (!oidcTenantConfig.tenantEnabled) { @@ -68,7 +65,7 @@ public Uni apply(OidcTenantConfig oidcTenantConfig) { } private Uni resolve(RoutingContext context) { - return resolver.resolveConfig(context).map(new Function() { + return resolver.resolveConfig(context).map(new Function<>() { @Override public OidcTenantConfig apply(OidcTenantConfig oidcTenantConfig) { if (oidcTenantConfig == null) {