Add native hint for the users JDBC schema

Closes gh-11907
This commit is contained in:
Marcus Da Coregio 2022-09-29 09:42:37 -03:00
parent 88e4b8b556
commit ef879aadd6
2 changed files with 12 additions and 0 deletions

View File

@ -42,6 +42,7 @@ import org.springframework.security.authentication.event.AuthenticationFailurePr
import org.springframework.security.authentication.event.AuthenticationFailureProxyUntrustedEvent;
import org.springframework.security.authentication.event.AuthenticationFailureServiceExceptionEvent;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl;
/**
* {@link RuntimeHintsRegistrar} for core classes
@ -57,6 +58,7 @@ class CoreSecurityRuntimeHints implements RuntimeHintsRegistrar {
registerExpressionEvaluationHints(hints);
registerMethodSecurityHints(hints);
hints.resources().registerResourceBundle("org.springframework.security.messages");
registerDefaultJdbcSchemaFileHint(hints);
}
private void registerMethodSecurityHints(RuntimeHints hints) {
@ -91,4 +93,8 @@ class CoreSecurityRuntimeHints implements RuntimeHintsRegistrar {
ProviderNotFoundException.class).map(TypeReference::of).toList();
}
private void registerDefaultJdbcSchemaFileHint(RuntimeHints hints) {
hints.resources().registerPattern(JdbcDaoImpl.DEFAULT_USER_SCHEMA_DDL_LOCATION);
}
}

View File

@ -131,4 +131,10 @@ class CoreSecurityRuntimeHintsTests {
LockedException.class, UsernameNotFoundException.class, ProviderNotFoundException.class);
}
@Test
void defaultJdbcSchemaFileHasHints() {
assertThat(RuntimeHintsPredicates.resource()
.forResource("org/springframework/security/core/userdetails/jdbc/users.ddl")).accepts(this.hints);
}
}