-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81d9000
commit abdfa22
Showing
7 changed files
with
158 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...nt/deployment/src/main/java/io/quarkus/kafka/client/deployment/StrimziOAuthProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.quarkus.kafka.client.deployment; | ||
|
||
import io.quarkus.bootstrap.classloading.QuarkusClassLoader; | ||
import io.quarkus.deployment.annotations.BuildProducer; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; | ||
import io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem; | ||
|
||
public class StrimziOAuthProcessor { | ||
|
||
@BuildStep | ||
public void handleStrimziOAuth(CurateOutcomeBuildItem curateOutcomeBuildItem, | ||
BuildProducer<ReflectiveClassBuildItem> reflectiveClass) { | ||
if (!QuarkusClassLoader.isClassPresentAtRuntime("io.strimzi.kafka.oauth.client.JaasClientOauthLoginCallbackHandler")) { | ||
return; | ||
} | ||
|
||
reflectiveClass | ||
.produce(ReflectiveClassBuildItem.builder( | ||
"io.strimzi.kafka.oauth.client.JaasClientOauthLoginCallbackHandler") | ||
.methods().fields().build()); | ||
|
||
if (curateOutcomeBuildItem.getApplicationModel().getDependencies().stream().anyMatch( | ||
x -> x.getGroupId().equals("org.keycloak") && x.getArtifactId().equals("keycloak-core"))) { | ||
reflectiveClass.produce(ReflectiveClassBuildItem.builder("org.keycloak.jose.jws.JWSHeader", | ||
"org.keycloak.representations.AccessToken", | ||
"org.keycloak.representations.AccessToken$Access", | ||
"org.keycloak.representations.AccessTokenResponse", | ||
"org.keycloak.representations.IDToken", | ||
"org.keycloak.representations.JsonWebToken", | ||
"org.keycloak.jose.jwk.JSONWebKeySet", | ||
"org.keycloak.jose.jwk.JWK", | ||
"org.keycloak.json.StringOrArrayDeserializer", | ||
"org.keycloak.json.StringListMapDeserializer").methods().fields().build()); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...a-client/runtime/src/main/java/io/smallrye/reactive/kafka/graal/StrimziSubstitutions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package io.smallrye.reactive.kafka.graal; | ||
|
||
import java.util.function.BooleanSupplier; | ||
|
||
import com.jayway.jsonpath.Predicate; | ||
import com.jayway.jsonpath.spi.json.JacksonJsonNodeJsonProvider; | ||
import com.jayway.jsonpath.spi.json.JacksonJsonProvider; | ||
import com.jayway.jsonpath.spi.json.JsonProvider; | ||
import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider; | ||
import com.jayway.jsonpath.spi.mapper.MappingProvider; | ||
import com.oracle.svm.core.annotate.Alias; | ||
import com.oracle.svm.core.annotate.RecomputeFieldValue; | ||
import com.oracle.svm.core.annotate.Substitute; | ||
import com.oracle.svm.core.annotate.TargetClass; | ||
|
||
final class HasStrimzi implements BooleanSupplier { | ||
|
||
@Override | ||
public boolean getAsBoolean() { | ||
try { | ||
KafkaSubstitutions.class.getClassLoader() | ||
.loadClass("io.strimzi.kafka.oauth.client.JaasClientOauthLoginCallbackHandler"); | ||
return true; | ||
} catch (Exception e) { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
@TargetClass(className = "com.jayway.jsonpath.internal.filter.ValueNodes", innerClass = "JsonNode", onlyWith = HasStrimzi.class) | ||
final class Target_com_jayway_jsonpath_internal_filter_ValueNodes_JsonNode { | ||
@Alias | ||
private Object json; | ||
@Alias | ||
private boolean parsed; | ||
|
||
@Substitute | ||
public Object parse(Predicate.PredicateContext ctx) { | ||
try { | ||
return parsed ? json : new JacksonJsonProvider().parse(json.toString()); | ||
} catch (Throwable e) { | ||
throw new IllegalArgumentException(e); | ||
} | ||
} | ||
} | ||
|
||
@TargetClass(className = "com.jayway.jsonpath.internal.filter.ValueNode", onlyWith = HasStrimzi.class) | ||
final class Target_com_jayway_jsonpath_internal_filter_ValueNode { | ||
|
||
@Substitute | ||
private static boolean isJson(Object o) { | ||
if (o == null || !(o instanceof String)) { | ||
return false; | ||
} | ||
String str = o.toString().trim(); | ||
if (str.length() <= 1) { | ||
return false; | ||
} | ||
char c0 = str.charAt(0); | ||
char c1 = str.charAt(str.length() - 1); | ||
if ((c0 == '[' && c1 == ']') || (c0 == '{' && c1 == '}')) { | ||
try { | ||
new JacksonJsonProvider().parse(str); | ||
return true; | ||
} catch (Exception e) { | ||
return false; | ||
} | ||
} | ||
return false; | ||
} | ||
} | ||
|
||
@TargetClass(className = "com.jayway.jsonpath.internal.DefaultsImpl", onlyWith = HasStrimzi.class) | ||
final class Target_com_jayway_jsonpath_internal_DefaultsImpl { | ||
|
||
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias) | ||
@Alias | ||
public static Target_com_jayway_jsonpath_internal_DefaultsImpl INSTANCE = new Target_com_jayway_jsonpath_internal_DefaultsImpl(); | ||
|
||
@Substitute | ||
public JsonProvider jsonProvider() { | ||
return new JacksonJsonNodeJsonProvider(); | ||
} | ||
|
||
@Substitute | ||
public MappingProvider mappingProvider() { | ||
return new JacksonMappingProvider(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters