Skip to content

Commit

Permalink
Merge pull request #29076 from michalvavrik/feature/fix-kc-admin-jack…
Browse files Browse the repository at this point in the history
…son-serializers

Keycloak admin client classic - use default Quarkus Jackson serializers
  • Loading branch information
sberyozkin authored Nov 5, 2022
2 parents 622dd40 + 6851757 commit 76c6e6e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Produce;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.AdditionalApplicationArchiveMarkerBuildItem;
import io.quarkus.deployment.builditem.ServiceStartBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyIgnoreWarningBuildItem;
import io.quarkus.keycloak.admin.client.common.AutoCloseableDestroyer;
Expand Down Expand Up @@ -45,6 +47,13 @@ ReflectiveClassBuildItem reflect() {
.build();
}

@Record(ExecutionTime.STATIC_INIT)
@Produce(ServiceStartBuildItem.class)
@BuildStep
public void integrate(ResteasyKeycloakAdminClientRecorder recorder) {
recorder.setClientProvider();
}

@Record(ExecutionTime.RUNTIME_INIT)
@BuildStep(onlyIf = KeycloakAdminClientInjectionEnabled.class)
public void registerKeycloakAdminClientBeans(ResteasyKeycloakAdminClientRecorder recorder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@

import java.util.function.Supplier;

import javax.net.ssl.SSLContext;
import javax.ws.rs.client.Client;

import org.keycloak.admin.client.ClientBuilderWrapper;
import org.keycloak.admin.client.Keycloak;
import org.keycloak.admin.client.KeycloakBuilder;
import org.keycloak.admin.client.spi.ResteasyClientClassicProvider;

import io.quarkus.keycloak.admin.client.common.KeycloakAdminClientConfig;
import io.quarkus.runtime.RuntimeValue;
Expand Down Expand Up @@ -50,4 +55,15 @@ public Keycloak get() {
}
};
}

public void setClientProvider() {
Keycloak.setClientProvider(new ResteasyClientClassicProvider() {
@Override
public Client newRestEasyClient(Object customJacksonProvider, SSLContext sslContext, boolean disableTrustManager) {
// point here is to use default Quarkus providers rather than org.keycloak.admin.client.JacksonProvider
// as it doesn't work properly in native mode
return ClientBuilderWrapper.create(sslContext, disableTrustManager).build();
}
});
}
}

0 comments on commit 76c6e6e

Please sign in to comment.