From 5ab82f83cb8d3168e24a5e743826f2385c140cd4 Mon Sep 17 00:00:00 2001 From: Joe Grandja Date: Wed, 23 Mar 2022 11:21:11 -0400 Subject: [PATCH] Polish gh-628 --- .../server/authorization/JwtEncodingContext.java | 12 +++++++++--- .../server/authorization/token/JwtGenerator.java | 5 ++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/JwtEncodingContext.java b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/JwtEncodingContext.java index 346716d5..41ff40d9 100644 --- a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/JwtEncodingContext.java +++ b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/JwtEncodingContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2021 the original author or authors. + * Copyright 2020-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,7 +58,8 @@ public final class JwtEncodingContext implements OAuth2TokenContext { } /** - * Returns the {@link JoseHeader.Builder headers}. + * Returns the {@link JoseHeader.Builder headers} + * allowing the ability to add, replace, or remove. * * @return the {@link JoseHeader.Builder} */ @@ -67,7 +68,8 @@ public final class JwtEncodingContext implements OAuth2TokenContext { } /** - * Returns the {@link JwtClaimsSet.Builder claims}. + * Returns the {@link JwtClaimsSet.Builder claims} + * allowing the ability to add, replace, or remove. * * @return the {@link JwtClaimsSet.Builder} */ @@ -102,9 +104,11 @@ public final class JwtEncodingContext implements OAuth2TokenContext { * A {@code Consumer} of the {@link JoseHeader.Builder headers} * allowing the ability to add, replace, or remove. * + * @deprecated Use {@link #getHeaders()} instead * @param headersConsumer a {@code Consumer} of the {@link JoseHeader.Builder headers} * @return the {@link Builder} for further configuration */ + @Deprecated public Builder headers(Consumer headersConsumer) { headersConsumer.accept(get(JoseHeader.Builder.class)); return this; @@ -114,9 +118,11 @@ public final class JwtEncodingContext implements OAuth2TokenContext { * A {@code Consumer} of the {@link JwtClaimsSet.Builder claims} * allowing the ability to add, replace, or remove. * + * @deprecated Use {@link #getClaims()} instead * @param claimsConsumer a {@code Consumer} of the {@link JwtClaimsSet.Builder claims} * @return the {@link Builder} for further configuration */ + @Deprecated public Builder claims(Consumer claimsConsumer) { claimsConsumer.accept(get(JwtClaimsSet.Builder.class)); return this; diff --git a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/token/JwtGenerator.java b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/token/JwtGenerator.java index 73f67c34..a66281e1 100644 --- a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/token/JwtGenerator.java +++ b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/token/JwtGenerator.java @@ -18,7 +18,6 @@ package org.springframework.security.oauth2.server.authorization.token; import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.Collections; -import java.util.function.Consumer; import org.springframework.lang.Nullable; import org.springframework.security.oauth2.core.AuthorizationGrantType; @@ -161,8 +160,8 @@ public final class JwtGenerator implements OAuth2TokenGenerator { /** * Sets the {@link OAuth2TokenCustomizer} that customizes the - * {@link JwtEncodingContext.Builder#headers(Consumer) headers} and/or - * {@link JwtEncodingContext.Builder#claims(Consumer) claims} for the generated {@link Jwt}. + * {@link JwtEncodingContext#getHeaders() headers} and/or + * {@link JwtEncodingContext#getClaims() claims} for the generated {@link Jwt}. * * @param jwtCustomizer the {@link OAuth2TokenCustomizer} that customizes the headers and/or claims for the generated {@code Jwt} */