|
|
|
@ -55,12 +55,6 @@ public class HaveIBeenPwnedRestApiReactivePasswordChecker implements ReactiveCom |
|
|
|
|
|
|
|
|
|
|
|
private WebClient webClient = WebClient.builder().baseUrl(API_URL).build(); |
|
|
|
private WebClient webClient = WebClient.builder().baseUrl(API_URL).build(); |
|
|
|
|
|
|
|
|
|
|
|
private final MessageDigest sha1Digest; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public HaveIBeenPwnedRestApiReactivePasswordChecker() { |
|
|
|
|
|
|
|
this.sha1Digest = getSha1Digest(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Mono<CompromisedPasswordDecision> check(@Nullable String password) { |
|
|
|
public Mono<CompromisedPasswordDecision> check(@Nullable String password) { |
|
|
|
return getHash(password).map((hash) -> new String(Hex.encode(hash))) |
|
|
|
return getHash(password).map((hash) -> new String(Hex.encode(hash))) |
|
|
|
@ -98,7 +92,7 @@ public class HaveIBeenPwnedRestApiReactivePasswordChecker implements ReactiveCom |
|
|
|
|
|
|
|
|
|
|
|
private Mono<byte[]> getHash(@Nullable String rawPassword) { |
|
|
|
private Mono<byte[]> getHash(@Nullable String rawPassword) { |
|
|
|
return Mono.justOrEmpty(rawPassword) |
|
|
|
return Mono.justOrEmpty(rawPassword) |
|
|
|
.map((password) -> this.sha1Digest.digest(password.getBytes(StandardCharsets.UTF_8))) |
|
|
|
.map((password) -> getSha1Digest().digest(password.getBytes(StandardCharsets.UTF_8))) |
|
|
|
.subscribeOn(Schedulers.boundedElastic()) |
|
|
|
.subscribeOn(Schedulers.boundedElastic()) |
|
|
|
.publishOn(Schedulers.parallel()); |
|
|
|
.publishOn(Schedulers.parallel()); |
|
|
|
} |
|
|
|
} |
|
|
|
|