Skip to content

Commit

Permalink
Adds hints for Authentication manager, fixes spring-projects/spring-f…
Browse files Browse the repository at this point in the history
  • Loading branch information
nkonev committed Dec 11, 2022
1 parent 8ba7c0d commit 07f2f0b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@
import java.util.List;
import java.util.stream.Stream;

import org.springframework.aop.SpringProxy;
import org.springframework.aop.framework.Advised;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.aot.hint.TypeReference;
import org.springframework.core.DecoratingProxy;
import org.springframework.security.access.expression.SecurityExpressionOperations;
import org.springframework.security.access.expression.SecurityExpressionRoot;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.authentication.AccountExpiredException;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.CredentialsExpiredException;
Expand All @@ -49,6 +53,7 @@
* {@link RuntimeHintsRegistrar} for core classes
*
* @author Marcus Da Coregio
* @author Nikita Konev
* @since 6.0
*/
class CoreSecurityRuntimeHints implements RuntimeHintsRegistrar {
Expand All @@ -61,6 +66,7 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
hints.resources().registerResourceBundle("org.springframework.security.messages");
registerDefaultJdbcSchemaFileHint(hints);
registerSecurityContextHints(hints);
registerJdkProxyHints(hints);
}

private void registerMethodSecurityHints(RuntimeHints hints) {
Expand Down Expand Up @@ -104,4 +110,9 @@ private void registerSecurityContextHints(RuntimeHints hints) {
(builder) -> builder.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS));
}

private void registerJdkProxyHints(RuntimeHints hints) {
hints.proxies().registerJdkProxy(AuthenticationManager.class, SpringProxy.class, Advised.class,
DecoratingProxy.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,20 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import org.springframework.aop.SpringProxy;
import org.springframework.aop.framework.Advised;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.aot.hint.TypeReference;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.core.DecoratingProxy;
import org.springframework.core.io.support.SpringFactoriesLoader;
import org.springframework.security.access.expression.SecurityExpressionOperations;
import org.springframework.security.access.expression.SecurityExpressionRoot;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.authentication.AccountExpiredException;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.CredentialsExpiredException;
Expand All @@ -59,6 +63,7 @@
* Tests for {@link CoreSecurityRuntimeHints}
*
* @author Marcus Da Coregio
* @author Nikita Konev
*/
class CoreSecurityRuntimeHintsTests {

Expand Down Expand Up @@ -144,4 +149,10 @@ void securityContextHasHints() {
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_METHODS)).accepts(this.hints);
}

@Test
void authenticationManagerHasHints() {
assertThat(RuntimeHintsPredicates.proxies().forInterfaces(AuthenticationManager.class, SpringProxy.class,
Advised.class, DecoratingProxy.class)).accepts(this.hints);
}

}

0 comments on commit 07f2f0b

Please sign in to comment.