Add SSLSocketFactory Hints

Closes gh-723
This commit is contained in:
Josh Cummings
2023-02-15 09:22:33 -07:00
parent af84dacb22
commit d5e1a15efc
2 changed files with 13 additions and 0 deletions

View File

@@ -16,6 +16,9 @@
package org.springframework.ldap.aot.hint;
import java.util.Collections;
import org.springframework.aot.hint.ExecutableMode;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
@@ -65,6 +68,9 @@ class LdapCoreRuntimeHints implements RuntimeHintsRegistrar {
hints.reflection().registerTypeIfPresent(classLoader, "com.sun.jndi.ldap.ctl.SortResponseControl",
(builder) -> builder.onReachableType(SortControlDirContextProcessor.class)
.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
hints.reflection().registerType(TypeReference.of("javax.net.ssl.SSLSocketFactory"), (builder) -> builder
.withMethod("getDefault", Collections.emptyList(), ExecutableMode.INVOKE)
.onReachableType(TypeReference.of("com.sun.jndi.ldap.Connection")));
}
}

View File

@@ -1,5 +1,7 @@
package org.springframework.ldap.aot.hint;
import javax.net.ssl.SSLSocketFactory;
import org.junit.Before;
import org.junit.Test;
@@ -46,4 +48,9 @@ public class LdapCoreRuntimeHintsTests {
.accepts(this.hints);
}
@Test
public void sslSocketFactoryHasHints() throws Exception {
assertThat(RuntimeHintsPredicates.reflection().onMethod(SSLSocketFactory.class.getDeclaredMethod("getDefault")))
.accepts(this.hints);
}
}