forked from infinispan/infinispan-quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
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 infinispan#44
- Loading branch information
1 parent
6bd1be7
commit 3c5ce8b
Showing
2 changed files
with
115 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
113 changes: 113 additions & 0 deletions
113
...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,113 @@ | ||
package org.infinispan.quarkus.server.runtime.graal; | ||
|
||
import com.oracle.svm.core.annotate.Substitute; | ||
import com.oracle.svm.core.annotate.TargetClass; | ||
|
||
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 static java.security.AccessController.doPrivileged; | ||
|
||
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) | ||
{ | ||
System.out.printf("Call checkForCloneMethod(%s,%s)%n", declType, 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) | ||
{ | ||
System.out.printf("Call checkForCopyCtor(%s,%s)%n", declType, paramType); | ||
final Constructor<?> constructor = doPrivileged(new PrivilegedAction<Constructor<?>>() | ||
{ | ||
@Override | ||
public Constructor<?> run() | ||
{ | ||
try | ||
{ | ||
return declType.getDeclaredConstructor(paramType); | ||
} | ||
catch (NoSuchMethodException e) | ||
{ | ||
System.out.printf("Copy ctor in %s for parameter %s not found%n", declType, paramType); | ||
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); | ||
} | ||
} | ||
}; | ||
} | ||
} |