From d6c19c9d9e09bb25a2687242c463db971e2131c4 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Mon, 10 Jan 2022 11:58:55 +0200 Subject: [PATCH] Apply minor polish to OidcAuthenticationMechanism --- .../runtime/OidcAuthenticationMechanism.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) 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) {