Polish One-Time Token Component Names

Aligning parts of speech so that names are using nouns/verbs
where comparable components are using nouns/verbs.

Issue gh-15114
This commit is contained in:
Josh Cummings
2024-10-14 13:58:23 -06:00
parent b8aa78829c
commit c40334317d
19 changed files with 158 additions and 142 deletions

View File

@@ -43,18 +43,18 @@ import static org.springframework.security.web.util.matcher.AntPathRequestMatche
*/
public final class GenerateOneTimeTokenFilter extends OncePerRequestFilter {
private final OneTimeTokenService oneTimeTokenService;
private final OneTimeTokenService tokenService;
private final GeneratedOneTimeTokenHandler generatedOneTimeTokenHandler;
private final OneTimeTokenGenerationSuccessHandler tokenGenerationSuccessHandler;
private RequestMatcher requestMatcher = antMatcher(HttpMethod.POST, "/ott/generate");
public GenerateOneTimeTokenFilter(OneTimeTokenService oneTimeTokenService,
GeneratedOneTimeTokenHandler generatedOneTimeTokenHandler) {
Assert.notNull(oneTimeTokenService, "oneTimeTokenService cannot be null");
Assert.notNull(generatedOneTimeTokenHandler, "generatedOneTimeTokenHandler cannot be null");
this.oneTimeTokenService = oneTimeTokenService;
this.generatedOneTimeTokenHandler = generatedOneTimeTokenHandler;
public GenerateOneTimeTokenFilter(OneTimeTokenService tokenService,
OneTimeTokenGenerationSuccessHandler tokenGenerationSuccessHandler) {
Assert.notNull(tokenService, "tokenService cannot be null");
Assert.notNull(tokenGenerationSuccessHandler, "tokenGenerationSuccessHandler cannot be null");
this.tokenService = tokenService;
this.tokenGenerationSuccessHandler = tokenGenerationSuccessHandler;
}
@Override
@@ -70,8 +70,8 @@ public final class GenerateOneTimeTokenFilter extends OncePerRequestFilter {
return;
}
GenerateOneTimeTokenRequest generateRequest = new GenerateOneTimeTokenRequest(username);
OneTimeToken ott = this.oneTimeTokenService.generate(generateRequest);
this.generatedOneTimeTokenHandler.handle(request, response, ott);
OneTimeToken ott = this.tokenService.generate(generateRequest);
this.tokenGenerationSuccessHandler.handle(request, response, ott);
}
/**

View File

@@ -31,7 +31,7 @@ import org.springframework.security.authentication.ott.OneTimeToken;
* @since 6.4
*/
@FunctionalInterface
public interface GeneratedOneTimeTokenHandler {
public interface OneTimeTokenGenerationSuccessHandler {
/**
* Handles generated one-time tokens

View File

@@ -27,12 +27,13 @@ import org.springframework.security.web.RedirectStrategy;
import org.springframework.util.Assert;
/**
* A {@link GeneratedOneTimeTokenHandler} that performs a redirect to a specific location
* A {@link OneTimeTokenGenerationSuccessHandler} that performs a redirect to a specific
* location
*
* @author Marcus da Coregio
* @since 6.4
*/
public final class RedirectGeneratedOneTimeTokenHandler implements GeneratedOneTimeTokenHandler {
public final class RedirectOneTimeTokenGenerationSuccessHandler implements OneTimeTokenGenerationSuccessHandler {
private final RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
@@ -42,7 +43,7 @@ public final class RedirectGeneratedOneTimeTokenHandler implements GeneratedOneT
* Constructs an instance of this class that redirects to the specified URL.
* @param redirectUrl
*/
public RedirectGeneratedOneTimeTokenHandler(String redirectUrl) {
public RedirectOneTimeTokenGenerationSuccessHandler(String redirectUrl) {
Assert.hasText(redirectUrl, "redirectUrl cannot be empty or null");
this.redirectUrl = redirectUrl;
}

View File

@@ -157,7 +157,7 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
this.authenticationUrl = authenticationUrl;
}
public void setGenerateOneTimeTokenUrl(String generateOneTimeTokenUrl) {
public void setOneTimeTokenGenerationUrl(String generateOneTimeTokenUrl) {
this.generateOneTimeTokenUrl = generateOneTimeTokenUrl;
}

View File

@@ -43,10 +43,10 @@ public final class GenerateOneTimeTokenWebFilter implements WebFilter {
private ServerWebExchangeMatcher matcher = ServerWebExchangeMatchers.pathMatchers(HttpMethod.POST, "/ott/generate");
private final ServerGeneratedOneTimeTokenHandler generatedOneTimeTokenHandler;
private final ServerOneTimeTokenGenerationSuccessHandler generatedOneTimeTokenHandler;
public GenerateOneTimeTokenWebFilter(ReactiveOneTimeTokenService oneTimeTokenService,
ServerGeneratedOneTimeTokenHandler generatedOneTimeTokenHandler) {
ServerOneTimeTokenGenerationSuccessHandler generatedOneTimeTokenHandler) {
Assert.notNull(generatedOneTimeTokenHandler, "generatedOneTimeTokenHandler cannot be null");
Assert.notNull(oneTimeTokenService, "oneTimeTokenService cannot be null");
this.generatedOneTimeTokenHandler = generatedOneTimeTokenHandler;

View File

@@ -28,7 +28,7 @@ import org.springframework.web.server.ServerWebExchange;
* @since 6.4
*/
@FunctionalInterface
public interface ServerGeneratedOneTimeTokenHandler {
public interface ServerOneTimeTokenGenerationSuccessHandler {
/**
* Handles generated one-time tokens

View File

@@ -27,19 +27,20 @@ import org.springframework.util.Assert;
import org.springframework.web.server.ServerWebExchange;
/**
* A {@link ServerGeneratedOneTimeTokenHandler} that performs a redirect to a specific
* location
* A {@link ServerOneTimeTokenGenerationSuccessHandler} that performs a redirect to a
* specific location
*
* @author Max Batischev
* @since 6.4
*/
public final class ServerRedirectGeneratedOneTimeTokenHandler implements ServerGeneratedOneTimeTokenHandler {
public final class ServerRedirectOneTimeTokenGenerationSuccessHandler
implements ServerOneTimeTokenGenerationSuccessHandler {
private final ServerRedirectStrategy redirectStrategy = new DefaultServerRedirectStrategy();
private final URI redirectUri;
public ServerRedirectGeneratedOneTimeTokenHandler(String redirectUri) {
public ServerRedirectOneTimeTokenGenerationSuccessHandler(String redirectUri) {
Assert.hasText(redirectUri, "redirectUri cannot be empty or null");
this.redirectUri = URI.create(redirectUri);
}