Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lambdas from OidcRecorder #32558

Merged
merged 1 commit into from
Apr 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import io.smallrye.jwt.util.KeyUtils;
import io.smallrye.mutiny.Uni;
import io.vertx.core.Vertx;
import io.vertx.core.json.JsonObject;
import io.vertx.core.net.ProxyOptions;
import io.vertx.ext.web.client.WebClientOptions;
import io.vertx.mutiny.ext.web.client.WebClient;
Expand All @@ -45,7 +46,12 @@ public class OidcRecorder {
private static final Map<String, TenantConfigContext> dynamicTenantsConfig = new ConcurrentHashMap<>();

public Supplier<DefaultTokenIntrospectionUserInfoCache> setupTokenCache(OidcConfig config, Supplier<Vertx> vertx) {
return () -> new DefaultTokenIntrospectionUserInfoCache(config, vertx.get());
return new Supplier<DefaultTokenIntrospectionUserInfoCache>() {
@Override
public DefaultTokenIntrospectionUserInfoCache get() {
return new DefaultTokenIntrospectionUserInfoCache(config, vertx.get());
}
};
}

public Supplier<TenantConfigBean> setup(OidcConfig config, Supplier<Vertx> vertx, TlsConfig tlsConfig) {
Expand Down Expand Up @@ -86,7 +92,12 @@ private Uni<TenantConfigContext> createDynamicTenantContext(Vertx vertx,
}
if (!dynamicTenantsConfig.containsKey(tenantId)) {
Uni<TenantConfigContext> uniContext = createTenantContext(vertx, oidcConfig, tlsConfig, tenantId);
uniContext.onFailure().transform(t -> logTenantConfigContextFailure(t, tenantId));
uniContext.onFailure().transform(new Function<Throwable, Throwable>() {
@Override
public Throwable apply(Throwable t) {
return logTenantConfigContextFailure(t, tenantId);
}
});
return uniContext.onItem().transform(
new Function<TenantConfigContext, TenantConfigContext>() {
@Override
Expand Down Expand Up @@ -232,7 +243,12 @@ private Uni<TenantConfigContext> createTenantContext(Vertx vertx, OidcTenantConf
}

return createOidcProvider(oidcConfig, tlsConfig, vertx)
.onItem().transform(p -> new TenantConfigContext(p, oidcConfig));
.onItem().transform(new Function<OidcProvider, TenantConfigContext>() {
@Override
public TenantConfigContext apply(OidcProvider p) {
return new TenantConfigContext(p, oidcConfig);
}
});
}

private static TenantConfigContext createTenantContextFromPublicKey(OidcTenantConfig oidcConfig) {
Expand Down Expand Up @@ -324,7 +340,12 @@ protected static Uni<JsonWebKeySet> getJsonWebSetUni(OidcProviderClient client,
.withBackOff(OidcCommonUtils.CONNECTION_BACKOFF_DURATION, OidcCommonUtils.CONNECTION_BACKOFF_DURATION)
.expireIn(connectionDelayInMillisecs)
.onFailure()
.transform(t -> toOidcException(t, oidcConfig.authServerUrl.get()))
.transform(new Function<Throwable, Throwable>() {
@Override
public Throwable apply(Throwable t) {
return toOidcException(t, oidcConfig.authServerUrl.get());
}
})
.onFailure()
.invoke(client::close);
} else {
Expand All @@ -350,8 +371,12 @@ protected static Uni<OidcProviderClient> createOidcClientUni(OidcTenantConfig oi
final long connectionDelayInMillisecs = OidcCommonUtils.getConnectionDelayInMillis(oidcConfig);
metadataUni = OidcCommonUtils.discoverMetadata(client, authServerUriString, connectionDelayInMillisecs)
.onItem()
.transform(
json -> new OidcConfigurationMetadata(json, createLocalMetadata(oidcConfig, authServerUriString)));
.transform(new Function<JsonObject, OidcConfigurationMetadata>() {
@Override
public OidcConfigurationMetadata apply(JsonObject json) {
return new OidcConfigurationMetadata(json, createLocalMetadata(oidcConfig, authServerUriString));
}
});
}
return metadataUni.onItemOrFailure()
.transformToUni(new BiFunction<OidcConfigurationMetadata, Throwable, Uni<? extends OidcProviderClient>>() {
Expand Down