File tree Expand file tree Collapse file tree 11 files changed +34
-34
lines changed
config/src/test/java/org/springframework/security/config/annotation/web
main/java/org/springframework/security/authentication
test/java/org/springframework/security/authentication
main/java/org/springframework/security/web/authentication/password
test/java/org/springframework/security/web/authentication/password Expand file tree Collapse file tree 11 files changed +34
-34
lines changed Original file line number Diff line number Diff line change 47
47
import org .springframework .security .authentication .event .AbstractAuthenticationEvent ;
48
48
import org .springframework .security .authentication .event .AbstractAuthenticationFailureEvent ;
49
49
import org .springframework .security .authentication .event .AuthenticationSuccessEvent ;
50
- import org .springframework .security .authentication .password .CompromisedPasswordCheckResult ;
51
50
import org .springframework .security .authentication .password .CompromisedPasswordChecker ;
51
+ import org .springframework .security .authentication .password .CompromisedPasswordDecision ;
52
52
import org .springframework .security .authentication .password .CompromisedPasswordException ;
53
53
import org .springframework .security .config .Customizer ;
54
54
import org .springframework .security .config .annotation .SecurityContextChangedListenerConfig ;
@@ -809,11 +809,11 @@ SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
809
809
private static class TestCompromisedPasswordChecker implements CompromisedPasswordChecker {
810
810
811
811
@ Override
812
- public CompromisedPasswordCheckResult check (String password ) {
812
+ public CompromisedPasswordDecision check (String password ) {
813
813
if ("password" .equals (password )) {
814
- return new CompromisedPasswordCheckResult (true );
814
+ return new CompromisedPasswordDecision (true );
815
815
}
816
- return new CompromisedPasswordCheckResult (false );
816
+ return new CompromisedPasswordDecision (false );
817
817
}
818
818
819
819
}
Original file line number Diff line number Diff line change 26
26
import org .springframework .context .ApplicationContext ;
27
27
import org .springframework .context .annotation .Bean ;
28
28
import org .springframework .context .annotation .Configuration ;
29
- import org .springframework .security .authentication .password .CompromisedPasswordCheckResult ;
29
+ import org .springframework .security .authentication .password .CompromisedPasswordDecision ;
30
30
import org .springframework .security .authentication .password .CompromisedPasswordException ;
31
31
import org .springframework .security .authentication .password .ReactiveCompromisedPasswordChecker ;
32
32
import org .springframework .security .config .Customizer ;
@@ -228,11 +228,11 @@ TestReactivePasswordChecker compromisedPasswordChecker() {
228
228
static class TestReactivePasswordChecker implements ReactiveCompromisedPasswordChecker {
229
229
230
230
@ Override
231
- public Mono <CompromisedPasswordCheckResult > check (String password ) {
231
+ public Mono <CompromisedPasswordDecision > check (String password ) {
232
232
if ("password" .equals (password )) {
233
- return Mono .just (new CompromisedPasswordCheckResult (true ));
233
+ return Mono .just (new CompromisedPasswordDecision (true ));
234
234
}
235
- return Mono .just (new CompromisedPasswordCheckResult (false ));
235
+ return Mono .just (new CompromisedPasswordDecision (false ));
236
236
}
237
237
238
238
}
Original file line number Diff line number Diff line change 25
25
import org .springframework .context .MessageSource ;
26
26
import org .springframework .context .MessageSourceAware ;
27
27
import org .springframework .context .support .MessageSourceAccessor ;
28
- import org .springframework .security .authentication .password .CompromisedPasswordCheckResult ;
29
28
import org .springframework .security .authentication .password .CompromisedPasswordChecker ;
29
+ import org .springframework .security .authentication .password .CompromisedPasswordDecision ;
30
30
import org .springframework .security .authentication .password .CompromisedPasswordException ;
31
31
import org .springframework .security .authentication .password .ReactiveCompromisedPasswordChecker ;
32
32
import org .springframework .security .core .Authentication ;
@@ -118,7 +118,7 @@ private Mono<Void> checkCompromisedPassword(String password) {
118
118
return Mono .empty ();
119
119
}
120
120
return this .compromisedPasswordChecker .check (password )
121
- .filter (CompromisedPasswordCheckResult ::isCompromised )
121
+ .filter (CompromisedPasswordDecision ::isCompromised )
122
122
.flatMap ((compromised ) -> Mono .error (new CompromisedPasswordException (
123
123
"The provided password is compromised, please change your password" )));
124
124
}
Original file line number Diff line number Diff line change @@ -29,9 +29,9 @@ public interface CompromisedPasswordChecker {
29
29
/**
30
30
* Check whether the password is compromised
31
31
* @param password the password to check
32
- * @return a non-null {@link CompromisedPasswordCheckResult }
32
+ * @return a non-null {@link CompromisedPasswordDecision }
33
33
*/
34
34
@ NonNull
35
- CompromisedPasswordCheckResult check (String password );
35
+ CompromisedPasswordDecision check (String password );
36
36
37
37
}
Original file line number Diff line number Diff line change 16
16
17
17
package org .springframework .security .authentication .password ;
18
18
19
- public class CompromisedPasswordCheckResult {
19
+ public class CompromisedPasswordDecision {
20
20
21
21
private final boolean compromised ;
22
22
23
- public CompromisedPasswordCheckResult (boolean compromised ) {
23
+ public CompromisedPasswordDecision (boolean compromised ) {
24
24
this .compromised = compromised ;
25
25
}
26
26
Original file line number Diff line number Diff line change @@ -29,8 +29,8 @@ public interface ReactiveCompromisedPasswordChecker {
29
29
/**
30
30
* Check whether the password is compromised
31
31
* @param password the password to check
32
- * @return a {@link Mono} containing the {@link CompromisedPasswordCheckResult }
32
+ * @return a {@link Mono} containing the {@link CompromisedPasswordDecision }
33
33
*/
34
- Mono <CompromisedPasswordCheckResult > check (String password );
34
+ Mono <CompromisedPasswordDecision > check (String password );
35
35
36
36
}
Original file line number Diff line number Diff line change 27
27
import reactor .test .StepVerifier ;
28
28
29
29
import org .springframework .context .MessageSource ;
30
- import org .springframework .security .authentication .password .CompromisedPasswordCheckResult ;
30
+ import org .springframework .security .authentication .password .CompromisedPasswordDecision ;
31
31
import org .springframework .security .authentication .password .CompromisedPasswordException ;
32
32
import org .springframework .security .authentication .password .ReactiveCompromisedPasswordChecker ;
33
33
import org .springframework .security .core .Authentication ;
@@ -276,11 +276,11 @@ public void setMessageSourceWhenNotNullThenCanGet() {
276
276
static class TestReactivePasswordChecker implements ReactiveCompromisedPasswordChecker {
277
277
278
278
@ Override
279
- public Mono <CompromisedPasswordCheckResult > check (String password ) {
279
+ public Mono <CompromisedPasswordDecision > check (String password ) {
280
280
if ("password" .equals (password )) {
281
- return Mono .just (new CompromisedPasswordCheckResult (true ));
281
+ return Mono .just (new CompromisedPasswordDecision (true ));
282
282
}
283
- return Mono .just (new CompromisedPasswordCheckResult (false ));
283
+ return Mono .just (new CompromisedPasswordDecision (false ));
284
284
}
285
285
286
286
}
Original file line number Diff line number Diff line change 33
33
import org .springframework .security .authentication .LockedException ;
34
34
import org .springframework .security .authentication .TestingAuthenticationToken ;
35
35
import org .springframework .security .authentication .UsernamePasswordAuthenticationToken ;
36
- import org .springframework .security .authentication .password .CompromisedPasswordCheckResult ;
37
36
import org .springframework .security .authentication .password .CompromisedPasswordChecker ;
37
+ import org .springframework .security .authentication .password .CompromisedPasswordDecision ;
38
38
import org .springframework .security .authentication .password .CompromisedPasswordException ;
39
39
import org .springframework .security .core .Authentication ;
40
40
import org .springframework .security .core .GrantedAuthority ;
@@ -637,11 +637,11 @@ public UserDetails loadUserByUsername(String username) {
637
637
private static class TestCompromisedPasswordChecker implements CompromisedPasswordChecker {
638
638
639
639
@ Override
640
- public CompromisedPasswordCheckResult check (String password ) {
640
+ public CompromisedPasswordDecision check (String password ) {
641
641
if ("password" .equals (password )) {
642
- return new CompromisedPasswordCheckResult (true );
642
+ return new CompromisedPasswordDecision (true );
643
643
}
644
- return new CompromisedPasswordCheckResult (false );
644
+ return new CompromisedPasswordDecision (false );
645
645
}
646
646
647
647
}
Original file line number Diff line number Diff line change 26
26
import org .apache .commons .logging .LogFactory ;
27
27
28
28
import org .springframework .lang .NonNull ;
29
- import org .springframework .security .authentication .password .CompromisedPasswordCheckResult ;
30
29
import org .springframework .security .authentication .password .CompromisedPasswordChecker ;
30
+ import org .springframework .security .authentication .password .CompromisedPasswordDecision ;
31
31
import org .springframework .security .crypto .codec .Hex ;
32
32
import org .springframework .util .Assert ;
33
33
import org .springframework .util .StringUtils ;
@@ -61,15 +61,15 @@ public HaveIBeenPwnedRestApiPasswordChecker() {
61
61
62
62
@ Override
63
63
@ NonNull
64
- public CompromisedPasswordCheckResult check (String password ) {
64
+ public CompromisedPasswordDecision check (String password ) {
65
65
byte [] hash = this .sha1Digest .digest (password .getBytes (StandardCharsets .UTF_8 ));
66
66
String encoded = new String (Hex .encode (hash )).toUpperCase ();
67
67
String prefix = encoded .substring (0 , PREFIX_LENGTH );
68
68
String suffix = encoded .substring (PREFIX_LENGTH );
69
69
70
70
List <String > passwords = getLeakedPasswordsForPrefix (prefix );
71
71
boolean isLeaked = findLeakedPassword (passwords , suffix );
72
- return new CompromisedPasswordCheckResult (isLeaked );
72
+ return new CompromisedPasswordDecision (isLeaked );
73
73
}
74
74
75
75
/**
Original file line number Diff line number Diff line change 26
26
import reactor .core .publisher .Mono ;
27
27
import reactor .core .scheduler .Schedulers ;
28
28
29
- import org .springframework .security .authentication .password .CompromisedPasswordCheckResult ;
29
+ import org .springframework .security .authentication .password .CompromisedPasswordDecision ;
30
30
import org .springframework .security .authentication .password .ReactiveCompromisedPasswordChecker ;
31
31
import org .springframework .security .crypto .codec .Hex ;
32
32
import org .springframework .util .Assert ;
@@ -60,10 +60,10 @@ public HaveIBeenPwnedRestApiReactivePasswordChecker() {
60
60
}
61
61
62
62
@ Override
63
- public Mono <CompromisedPasswordCheckResult > check (String password ) {
63
+ public Mono <CompromisedPasswordDecision > check (String password ) {
64
64
return getHash (password ).map ((hash ) -> new String (Hex .encode (hash )))
65
65
.flatMap (this ::findLeakedPassword )
66
- .map (CompromisedPasswordCheckResult ::new );
66
+ .map (CompromisedPasswordDecision ::new );
67
67
}
68
68
69
69
private Mono <Boolean > findLeakedPassword (String encodedPassword ) {
You can’t perform that action at this time.
0 commit comments