Skip to content

Cleanup code #17142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -122,7 +122,7 @@ private void registerProxy(RuntimeHints hints, Class<?> clazz) {
.registerType(clazz, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
MemberCategory.INVOKE_DECLARED_METHODS)
.registerType(proxied, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS);
MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.ACCESS_DECLARED_FIELDS);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -79,7 +79,7 @@ private void registerExpressionEvaluationHints(RuntimeHints hints) {
.registerTypes(
List.of(TypeReference.of(SecurityExpressionOperations.class),
TypeReference.of(SecurityExpressionRoot.class)),
(builder) -> builder.withMembers(MemberCategory.DECLARED_FIELDS,
(builder) -> builder.withMembers(MemberCategory.ACCESS_DECLARED_FIELDS,
MemberCategory.INVOKE_DECLARED_METHODS));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ public void setUserCache(UserCache userCache) {
* set this to {@code true} to enable password updates.
* @param enableUpdatePassword {@code true} to enable password updates, {@code false}
* otherwise.
* @since 7.0
*/
public void setEnableUpdatePassword(boolean enableUpdatePassword) {
this.enableUpdatePassword = enableUpdatePassword;
Expand All @@ -626,6 +627,7 @@ private void validateAuthorities(Collection<? extends GrantedAuthority> authorit
/**
* Conditionally updates password based on the setting from
* {@link #setEnableUpdatePassword(boolean)}. {@inheritDoc}
* @since 7.0
*/
@Override
public UserDetails updatePassword(UserDetails user, String newPassword) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -81,15 +81,15 @@ void springSecurityMessagesBundleHasHints() {
void securityExpressionOperationsHasHints() {
assertThat(RuntimeHintsPredicates.reflection()
.onType(SecurityExpressionOperations.class)
.withMemberCategories(MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS))
.withMemberCategories(MemberCategory.ACCESS_DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS))
.accepts(this.hints);
}

@Test
void securityExpressionRootHasHints() {
assertThat(RuntimeHintsPredicates.reflection()
.onType(SecurityExpressionRoot.class)
.withMemberCategories(MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS))
.withMemberCategories(MemberCategory.ACCESS_DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS))
.accepts(this.hints);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,9 @@ public void findGroupMembersReturnsCorrectData() {
}

@Test
@SuppressWarnings("unchecked")
public void createGroupInsertsCorrectData() {
this.manager.createGroup("TEST_GROUP", AuthorityUtils.createAuthorityList("ROLE_X", "ROLE_Y"));
List roles = this.template.queryForList("select ga.authority from groups g, group_authorities ga "
List<?> roles = this.template.queryForList("select ga.authority from groups g, group_authorities ga "
+ "where ga.group_id = g.id " + "and g.group_name = 'TEST_GROUP'");
assertThat(roles).hasSize(2);
}
Expand Down Expand Up @@ -367,7 +366,7 @@ public void updateUserDoesNotSaveAuthoritiesIfEnableAuthoritiesIsFalse() {

// SEC-2166
@Test
public void createNewAuthenticationUsesNullPasswordToKeepPassordsSave() {
public void createNewAuthenticationUsesNullPasswordToKeepPasswordSave() {
insertJoe();
UsernamePasswordAuthenticationToken currentAuth = UsernamePasswordAuthenticationToken.authenticated("joe", null,
AuthorityUtils.createAuthorityList("ROLE_USER"));
Expand Down Expand Up @@ -443,9 +442,9 @@ private void insertJoe() {
this.cache.putUserInCache(joe);
}

private class MockUserCache implements UserCache {
private static class MockUserCache implements UserCache {

private Map<String, UserDetails> cache = new HashMap<>();
private final Map<String, UserDetails> cache = new HashMap<>();

@Override
public UserDetails getUserFromCache(String username) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -58,12 +58,12 @@ private void registerFilterChainProxyHints(RuntimeHints hints) {
}

private void registerCsrfTokenRepositoryHints(RuntimeHints hints) {
hints.reflection().registerType(CsrfFilter.class, MemberCategory.DECLARED_FIELDS);
hints.reflection().registerType(CsrfFilter.class, MemberCategory.ACCESS_DECLARED_FIELDS);
}

private void registerSecurityContextRepositoryHints(RuntimeHints hints) {
hints.reflection().registerType(SecurityContextPersistenceFilter.class, MemberCategory.DECLARED_FIELDS);
hints.reflection().registerType(SecurityContextHolderFilter.class, MemberCategory.DECLARED_FIELDS);
hints.reflection().registerType(SecurityContextPersistenceFilter.class, MemberCategory.ACCESS_DECLARED_FIELDS);
hints.reflection().registerType(SecurityContextHolderFilter.class, MemberCategory.ACCESS_DECLARED_FIELDS);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -72,21 +72,21 @@ void compositeFilterChainProxyHasHints() {
void csrfFilterHasHints() {
assertThat(RuntimeHintsPredicates.reflection()
.onType(CsrfFilter.class)
.withMemberCategories(MemberCategory.DECLARED_FIELDS)).accepts(this.hints);
.withMemberCategories(MemberCategory.ACCESS_DECLARED_FIELDS)).accepts(this.hints);
}

@Test
void securityContextPersistenceFilterHasHints() {
assertThat(RuntimeHintsPredicates.reflection()
.onType(SecurityContextPersistenceFilter.class)
.withMemberCategories(MemberCategory.DECLARED_FIELDS)).accepts(this.hints);
.withMemberCategories(MemberCategory.ACCESS_DECLARED_FIELDS)).accepts(this.hints);
}

@Test
void securityContextHolderFilterHasHints() {
assertThat(RuntimeHintsPredicates.reflection()
.onType(SecurityContextHolderFilter.class)
.withMemberCategories(MemberCategory.DECLARED_FIELDS)).accepts(this.hints);
.withMemberCategories(MemberCategory.ACCESS_DECLARED_FIELDS)).accepts(this.hints);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,7 +36,7 @@ class WebMvcSecurityRuntimeHints implements RuntimeHintsRegistrar {
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
hints.reflection()
.registerType(WebSecurityExpressionRoot.class, (builder) -> builder
.withMembers(MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS));
.withMembers(MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.ACCESS_DECLARED_FIELDS));
hints.reflection()
.registerType(
TypeReference
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -50,7 +50,7 @@ void setup() {
void webSecurityExpressionRootHasHints() {
assertThat(RuntimeHintsPredicates.reflection()
.onType(WebSecurityExpressionRoot.class)
.withMemberCategories(MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS))
.withMemberCategories(MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.ACCESS_DECLARED_FIELDS))
.accepts(this.hints);
}

Expand Down