-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Native server fails to build due to Elytron Credential unsupported co…
…mbination #44 Co-authored-by: Galder Zamarreño <galder@redhat.com>
- Loading branch information
Showing
2 changed files
with
88 additions
and
1 deletion.
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
83 changes: 83 additions & 0 deletions
83
...e/src/main/java/org/infinispan/quarkus/server/runtime/graal/SubstituteElytronClasses.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,83 @@ | ||
package org.infinispan.quarkus.server.runtime.graal; | ||
|
||
import static java.security.AccessController.doPrivileged; | ||
|
||
import java.lang.reflect.Constructor; | ||
import java.lang.reflect.Method; | ||
import java.lang.reflect.UndeclaredThrowableException; | ||
import java.security.Key; | ||
import java.security.PrivilegedAction; | ||
import java.util.function.UnaryOperator; | ||
|
||
import com.oracle.svm.core.annotate.Substitute; | ||
import com.oracle.svm.core.annotate.TargetClass; | ||
|
||
public class SubstituteElytronClasses { | ||
} | ||
|
||
@TargetClass(className = "org.wildfly.security.key.KeyUtil$KeyClonerCreator") | ||
final class Target_org_wildfly_security_key_KeyUtil_KeyClonerCreator { | ||
@Substitute | ||
private UnaryOperator<Key> checkForCloneMethod(final Class<?> declType, final Class<?> returnType) { | ||
final Method method = doPrivileged(new PrivilegedAction<Method>() { | ||
@Override | ||
public Method run() { | ||
try { | ||
Method cloneMethod = declType.getDeclaredMethod("clone"); | ||
if (cloneMethod.getReturnType() == returnType) | ||
return cloneMethod; | ||
|
||
return null; | ||
} catch (NoSuchMethodException e) { | ||
return null; | ||
} | ||
} | ||
}); | ||
|
||
if (method == null) | ||
return null; | ||
|
||
return new UnaryOperator<Key>() { | ||
@Override | ||
public Key apply(Key key) { | ||
try { | ||
return (Key) method.invoke(key); | ||
} catch (RuntimeException | Error e) { | ||
throw e; | ||
} catch (Throwable throwable) { | ||
throw new UndeclaredThrowableException(throwable); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
@Substitute | ||
private UnaryOperator<Key> checkForCopyCtor(final Class<?> declType, final Class<?> paramType) { | ||
final Constructor<?> constructor = doPrivileged(new PrivilegedAction<Constructor<?>>() { | ||
@Override | ||
public Constructor<?> run() { | ||
try { | ||
return declType.getDeclaredConstructor(paramType); | ||
} catch (NoSuchMethodException e) { | ||
return null; | ||
} | ||
} | ||
}); | ||
|
||
if (constructor == null) | ||
return null; | ||
|
||
return new UnaryOperator<Key>() { | ||
@Override | ||
public Key apply(Key key) { | ||
try { | ||
return (Key) constructor.newInstance(key); | ||
} catch (RuntimeException | Error e) { | ||
throw e; | ||
} catch (Throwable throwable) { | ||
throw new UndeclaredThrowableException(throwable); | ||
} | ||
} | ||
}; | ||
} | ||
} |