Skip to content

Commit

Permalink
Apply minor polish to OidcAuthenticationMechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Jan 10, 2022
1 parent cd7ad27 commit d6c19c9
Showing 1 changed file with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<SecurityIdentity> authenticate(RoutingContext context,
IdentityProviderManager identityProviderManager) {
setTenantIdAttribute(context);
return resolve(context).chain(new Function<OidcTenantConfig, Uni<? extends SecurityIdentity>>() {
return resolve(context).chain(new Function<>() {
@Override
public Uni<? extends SecurityIdentity> apply(OidcTenantConfig oidcConfig) {
if (!oidcConfig.tenantEnabled) {
Expand All @@ -55,7 +52,7 @@ public Uni<? extends SecurityIdentity> apply(OidcTenantConfig oidcConfig) {
@Override
public Uni<ChallengeData> getChallenge(RoutingContext context) {
setTenantIdAttribute(context);
return resolve(context).chain(new Function<OidcTenantConfig, Uni<? extends ChallengeData>>() {
return resolve(context).chain(new Function<>() {
@Override
public Uni<? extends ChallengeData> apply(OidcTenantConfig oidcTenantConfig) {
if (!oidcTenantConfig.tenantEnabled) {
Expand All @@ -68,7 +65,7 @@ public Uni<? extends ChallengeData> apply(OidcTenantConfig oidcTenantConfig) {
}

private Uni<OidcTenantConfig> resolve(RoutingContext context) {
return resolver.resolveConfig(context).map(new Function<OidcTenantConfig, OidcTenantConfig>() {
return resolver.resolveConfig(context).map(new Function<>() {
@Override
public OidcTenantConfig apply(OidcTenantConfig oidcTenantConfig) {
if (oidcTenantConfig == null) {
Expand Down

0 comments on commit d6c19c9

Please sign in to comment.