mirror of
https://github.com/spring-projects/spring-security.git
synced 2026-02-24 22:25:18 +00:00
Add nullability contract to PasswordEncoder#encode implementations
Signed-off-by: Stefano Cordio <stefano.cordio@gmail.com>AbstractValidatingPasswordEncoder.java
This commit is contained in:
parent
d65625e399
commit
f8ac095d48
@ -36,6 +36,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.core.log.LogMessage;
|
||||
import org.springframework.lang.Contract;
|
||||
import org.springframework.security.authentication.AuthenticationEventPublisher;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.DefaultAuthenticationEventPublisher;
|
||||
@ -302,6 +303,7 @@ public class AuthenticationConfiguration {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Contract("!null -> !null; null -> null")
|
||||
public String encode(CharSequence rawPassword) {
|
||||
return getPasswordEncoder().encode(rawPassword);
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||
import org.springframework.lang.Contract;
|
||||
import org.springframework.security.authentication.AuthenticationEventPublisher;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.DefaultAuthenticationEventPublisher;
|
||||
@ -293,6 +294,7 @@ class HttpSecurityConfiguration {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Contract("!null -> !null; null -> null")
|
||||
public String encode(CharSequence rawPassword) {
|
||||
return getPasswordEncoder().encode(rawPassword);
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ package org.springframework.security.crypto.password;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.lang.Contract;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@ -33,6 +34,7 @@ import org.springframework.util.StringUtils;
|
||||
public abstract class AbstractValidatingPasswordEncoder implements PasswordEncoder {
|
||||
|
||||
@Override
|
||||
@Contract("!null -> !null; null -> null")
|
||||
public final @Nullable String encode(@Nullable CharSequence rawPassword) {
|
||||
if (rawPassword == null) {
|
||||
return null;
|
||||
|
||||
@ -38,7 +38,7 @@ public interface PasswordEncoder {
|
||||
* @return A non-null encoded password, unless the rawPassword was null in which case
|
||||
* the result must be null.
|
||||
*/
|
||||
@Contract("null -> null; !null -> !null")
|
||||
@Contract("!null -> !null; null -> null")
|
||||
@Nullable String encode(@Nullable CharSequence rawPassword);
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user