Skip to content

Commit ece604c

Browse files
Cleanup code
Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
1 parent 2041757 commit ece604c

File tree

9 files changed

+25
-24
lines changed

9 files changed

+25
-24
lines changed

core/src/main/java/org/springframework/security/aot/hint/AuthorizeReturnObjectHintsRegistrar.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -122,7 +122,7 @@ private void registerProxy(RuntimeHints hints, Class<?> clazz) {
122122
.registerType(clazz, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
123123
MemberCategory.INVOKE_DECLARED_METHODS)
124124
.registerType(proxied, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
125-
MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS);
125+
MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.ACCESS_DECLARED_FIELDS);
126126
}
127127
}
128128

core/src/main/java/org/springframework/security/aot/hint/CoreSecurityRuntimeHints.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -79,7 +79,7 @@ private void registerExpressionEvaluationHints(RuntimeHints hints) {
7979
.registerTypes(
8080
List.of(TypeReference.of(SecurityExpressionOperations.class),
8181
TypeReference.of(SecurityExpressionRoot.class)),
82-
(builder) -> builder.withMembers(MemberCategory.DECLARED_FIELDS,
82+
(builder) -> builder.withMembers(MemberCategory.ACCESS_DECLARED_FIELDS,
8383
MemberCategory.INVOKE_DECLARED_METHODS));
8484
}
8585

core/src/main/java/org/springframework/security/provisioning/JdbcUserDetailsManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@ public void setUserCache(UserCache userCache) {
605605
* set this to {@code true} to enable password updates.
606606
* @param enableUpdatePassword {@code true} to enable password updates, {@code false}
607607
* otherwise.
608+
* @since 7.0
608609
*/
609610
public void setEnableUpdatePassword(boolean enableUpdatePassword) {
610611
this.enableUpdatePassword = enableUpdatePassword;
@@ -626,6 +627,7 @@ private void validateAuthorities(Collection<? extends GrantedAuthority> authorit
626627
/**
627628
* Conditionally updates password based on the setting from
628629
* {@link #setEnableUpdatePassword(boolean)}. {@inheritDoc}
630+
* @since 7.0
629631
*/
630632
@Override
631633
public UserDetails updatePassword(UserDetails user, String newPassword) {

core/src/test/java/org/springframework/security/aot/hint/CoreSecurityRuntimeHintsTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -81,15 +81,15 @@ void springSecurityMessagesBundleHasHints() {
8181
void securityExpressionOperationsHasHints() {
8282
assertThat(RuntimeHintsPredicates.reflection()
8383
.onType(SecurityExpressionOperations.class)
84-
.withMemberCategories(MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS))
84+
.withMemberCategories(MemberCategory.ACCESS_DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS))
8585
.accepts(this.hints);
8686
}
8787

8888
@Test
8989
void securityExpressionRootHasHints() {
9090
assertThat(RuntimeHintsPredicates.reflection()
9191
.onType(SecurityExpressionRoot.class)
92-
.withMemberCategories(MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS))
92+
.withMemberCategories(MemberCategory.ACCESS_DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS))
9393
.accepts(this.hints);
9494
}
9595

core/src/test/java/org/springframework/security/provisioning/JdbcUserDetailsManagerTests.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,9 @@ public void findGroupMembersReturnsCorrectData() {
285285
}
286286

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

368367
// SEC-2166
369368
@Test
370-
public void createNewAuthenticationUsesNullPasswordToKeepPassordsSave() {
369+
public void createNewAuthenticationUsesNullPasswordToKeepPasswordSave() {
371370
insertJoe();
372371
UsernamePasswordAuthenticationToken currentAuth = UsernamePasswordAuthenticationToken.authenticated("joe", null,
373372
AuthorityUtils.createAuthorityList("ROLE_USER"));
@@ -443,9 +442,9 @@ private void insertJoe() {
443442
this.cache.putUserInCache(joe);
444443
}
445444

446-
private class MockUserCache implements UserCache {
445+
private static class MockUserCache implements UserCache {
447446

448-
private Map<String, UserDetails> cache = new HashMap<>();
447+
private final Map<String, UserDetails> cache = new HashMap<>();
449448

450449
@Override
451450
public UserDetails getUserFromCache(String username) {

test/src/main/java/org/springframework/security/test/aot/hint/WebTestUtilsRuntimeHints.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -58,12 +58,12 @@ private void registerFilterChainProxyHints(RuntimeHints hints) {
5858
}
5959

6060
private void registerCsrfTokenRepositoryHints(RuntimeHints hints) {
61-
hints.reflection().registerType(CsrfFilter.class, MemberCategory.DECLARED_FIELDS);
61+
hints.reflection().registerType(CsrfFilter.class, MemberCategory.ACCESS_DECLARED_FIELDS);
6262
}
6363

6464
private void registerSecurityContextRepositoryHints(RuntimeHints hints) {
65-
hints.reflection().registerType(SecurityContextPersistenceFilter.class, MemberCategory.DECLARED_FIELDS);
66-
hints.reflection().registerType(SecurityContextHolderFilter.class, MemberCategory.DECLARED_FIELDS);
65+
hints.reflection().registerType(SecurityContextPersistenceFilter.class, MemberCategory.ACCESS_DECLARED_FIELDS);
66+
hints.reflection().registerType(SecurityContextHolderFilter.class, MemberCategory.ACCESS_DECLARED_FIELDS);
6767
}
6868

6969
}

test/src/test/java/org/springframework/security/test/aot/hint/WebTestUtilsRuntimeHintsTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -72,21 +72,21 @@ void compositeFilterChainProxyHasHints() {
7272
void csrfFilterHasHints() {
7373
assertThat(RuntimeHintsPredicates.reflection()
7474
.onType(CsrfFilter.class)
75-
.withMemberCategories(MemberCategory.DECLARED_FIELDS)).accepts(this.hints);
75+
.withMemberCategories(MemberCategory.ACCESS_DECLARED_FIELDS)).accepts(this.hints);
7676
}
7777

7878
@Test
7979
void securityContextPersistenceFilterHasHints() {
8080
assertThat(RuntimeHintsPredicates.reflection()
8181
.onType(SecurityContextPersistenceFilter.class)
82-
.withMemberCategories(MemberCategory.DECLARED_FIELDS)).accepts(this.hints);
82+
.withMemberCategories(MemberCategory.ACCESS_DECLARED_FIELDS)).accepts(this.hints);
8383
}
8484

8585
@Test
8686
void securityContextHolderFilterHasHints() {
8787
assertThat(RuntimeHintsPredicates.reflection()
8888
.onType(SecurityContextHolderFilter.class)
89-
.withMemberCategories(MemberCategory.DECLARED_FIELDS)).accepts(this.hints);
89+
.withMemberCategories(MemberCategory.ACCESS_DECLARED_FIELDS)).accepts(this.hints);
9090
}
9191

9292
}

web/src/main/java/org/springframework/security/web/aot/hint/WebMvcSecurityRuntimeHints.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ class WebMvcSecurityRuntimeHints implements RuntimeHintsRegistrar {
3636
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
3737
hints.reflection()
3838
.registerType(WebSecurityExpressionRoot.class, (builder) -> builder
39-
.withMembers(MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS));
39+
.withMembers(MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.ACCESS_DECLARED_FIELDS));
4040
hints.reflection()
4141
.registerType(
4242
TypeReference

web/src/test/java/org/springframework/security/web/aot/hint/WebMvcSecurityRuntimeHintsTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -50,7 +50,7 @@ void setup() {
5050
void webSecurityExpressionRootHasHints() {
5151
assertThat(RuntimeHintsPredicates.reflection()
5252
.onType(WebSecurityExpressionRoot.class)
53-
.withMemberCategories(MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS))
53+
.withMemberCategories(MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.ACCESS_DECLARED_FIELDS))
5454
.accepts(this.hints);
5555
}
5656

0 commit comments

Comments
 (0)