* Used by the {@link AuthorizationCodeRequestRedirectFilter} for persisting the Authorization Request
@@ -32,16 +32,16 @@ import javax.servlet.http.HttpServletResponse;
*
* @author Joe Grandja
* @since 5.0
- * @see AuthorizationRequestAttributes
+ * @see AuthorizationRequest
* @see HttpSessionAuthorizationRequestRepository
*/
public interface AuthorizationRequestRepository {
- AuthorizationRequestAttributes loadAuthorizationRequest(HttpServletRequest request);
+ AuthorizationRequest loadAuthorizationRequest(HttpServletRequest request);
- void saveAuthorizationRequest(AuthorizationRequestAttributes authorizationRequest, HttpServletRequest request,
- HttpServletResponse response);
+ void saveAuthorizationRequest(AuthorizationRequest authorizationRequest, HttpServletRequest request,
+ HttpServletResponse response);
- AuthorizationRequestAttributes removeAuthorizationRequest(HttpServletRequest request);
+ AuthorizationRequest removeAuthorizationRequest(HttpServletRequest request);
}
diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/AuthorizationRequestUriBuilder.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/AuthorizationRequestUriBuilder.java
index a2fe694c36..e474fc8ca7 100644
--- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/AuthorizationRequestUriBuilder.java
+++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/AuthorizationRequestUriBuilder.java
@@ -16,7 +16,7 @@
package org.springframework.security.oauth2.client.web;
-import org.springframework.security.oauth2.core.endpoint.AuthorizationRequestAttributes;
+import org.springframework.security.oauth2.core.endpoint.AuthorizationRequest;
import java.net.URI;
@@ -37,10 +37,10 @@ import java.net.URI;
*
* @author Joe Grandja
* @since 5.0
- * @see AuthorizationRequestAttributes
+ * @see AuthorizationRequest
* @see Section 4.1.1 Authorization Request
*/
public interface AuthorizationRequestUriBuilder {
- URI build(AuthorizationRequestAttributes authorizationRequestAttributes);
+ URI build(AuthorizationRequest authorizationRequest);
}
diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/DefaultAuthorizationRequestUriBuilder.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/DefaultAuthorizationRequestUriBuilder.java
index f5e7b6d7bf..45896bc9a3 100644
--- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/DefaultAuthorizationRequestUriBuilder.java
+++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/DefaultAuthorizationRequestUriBuilder.java
@@ -15,7 +15,7 @@
*/
package org.springframework.security.oauth2.client.web;
-import org.springframework.security.oauth2.core.endpoint.AuthorizationRequestAttributes;
+import org.springframework.security.oauth2.core.endpoint.AuthorizationRequest;
import org.springframework.security.oauth2.core.endpoint.OAuth2Parameter;
import org.springframework.security.oauth2.core.endpoint.ResponseType;
import org.springframework.web.util.UriComponentsBuilder;
@@ -29,24 +29,24 @@ import java.util.stream.Collectors;
*
* @author Joe Grandja
* @since 5.0
- * @see AuthorizationRequestAttributes
+ * @see AuthorizationRequest
* @see Section 4.1.1 Authorization Request
*/
public class DefaultAuthorizationRequestUriBuilder implements AuthorizationRequestUriBuilder {
@Override
- public URI build(AuthorizationRequestAttributes authorizationRequestAttributes) {
+ public URI build(AuthorizationRequest authorizationRequest) {
UriComponentsBuilder uriBuilder = UriComponentsBuilder
- .fromUriString(authorizationRequestAttributes.getAuthorizeUri())
+ .fromUriString(authorizationRequest.getAuthorizeUri())
.queryParam(OAuth2Parameter.RESPONSE_TYPE, ResponseType.CODE.getValue());
- if (authorizationRequestAttributes.getRedirectUri() != null) {
- uriBuilder.queryParam(OAuth2Parameter.REDIRECT_URI, authorizationRequestAttributes.getRedirectUri());
+ if (authorizationRequest.getRedirectUri() != null) {
+ uriBuilder.queryParam(OAuth2Parameter.REDIRECT_URI, authorizationRequest.getRedirectUri());
}
uriBuilder
- .queryParam(OAuth2Parameter.CLIENT_ID, authorizationRequestAttributes.getClientId())
+ .queryParam(OAuth2Parameter.CLIENT_ID, authorizationRequest.getClientId())
.queryParam(OAuth2Parameter.SCOPE,
- authorizationRequestAttributes.getScope().stream().collect(Collectors.joining(" ")))
- .queryParam(OAuth2Parameter.STATE, authorizationRequestAttributes.getState());
+ authorizationRequest.getScope().stream().collect(Collectors.joining(" ")))
+ .queryParam(OAuth2Parameter.STATE, authorizationRequest.getState());
return uriBuilder.build().encode().toUri();
}
diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/HttpSessionAuthorizationRequestRepository.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/HttpSessionAuthorizationRequestRepository.java
index 926b74d6d5..b05ce8600c 100644
--- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/HttpSessionAuthorizationRequestRepository.java
+++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/HttpSessionAuthorizationRequestRepository.java
@@ -15,7 +15,7 @@
*/
package org.springframework.security.oauth2.client.web;
-import org.springframework.security.oauth2.core.endpoint.AuthorizationRequestAttributes;
+import org.springframework.security.oauth2.core.endpoint.AuthorizationRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -23,11 +23,11 @@ import javax.servlet.http.HttpSession;
/**
* An implementation of an {@link AuthorizationRequestRepository} that stores
- * {@link AuthorizationRequestAttributes} in the {@link HttpSession}.
+ * {@link AuthorizationRequest} in the {@link HttpSession}.
*
* @author Joe Grandja
* @since 5.0
- * @see AuthorizationRequestAttributes
+ * @see AuthorizationRequest
*/
public final class HttpSessionAuthorizationRequestRepository implements AuthorizationRequestRepository {
private static final String DEFAULT_AUTHORIZATION_REQUEST_ATTR_NAME =
@@ -35,18 +35,18 @@ public final class HttpSessionAuthorizationRequestRepository implements Authoriz
private String sessionAttributeName = DEFAULT_AUTHORIZATION_REQUEST_ATTR_NAME;
@Override
- public AuthorizationRequestAttributes loadAuthorizationRequest(HttpServletRequest request) {
- AuthorizationRequestAttributes authorizationRequest = null;
+ public AuthorizationRequest loadAuthorizationRequest(HttpServletRequest request) {
+ AuthorizationRequest authorizationRequest = null;
HttpSession session = request.getSession(false);
if (session != null) {
- authorizationRequest = (AuthorizationRequestAttributes) session.getAttribute(this.sessionAttributeName);
+ authorizationRequest = (AuthorizationRequest) session.getAttribute(this.sessionAttributeName);
}
return authorizationRequest;
}
@Override
- public void saveAuthorizationRequest(AuthorizationRequestAttributes authorizationRequest, HttpServletRequest request,
- HttpServletResponse response) {
+ public void saveAuthorizationRequest(AuthorizationRequest authorizationRequest, HttpServletRequest request,
+ HttpServletResponse response) {
if (authorizationRequest == null) {
this.removeAuthorizationRequest(request);
return;
@@ -55,8 +55,8 @@ public final class HttpSessionAuthorizationRequestRepository implements Authoriz
}
@Override
- public AuthorizationRequestAttributes removeAuthorizationRequest(HttpServletRequest request) {
- AuthorizationRequestAttributes authorizationRequest = this.loadAuthorizationRequest(request);
+ public AuthorizationRequest removeAuthorizationRequest(HttpServletRequest request) {
+ AuthorizationRequest authorizationRequest = this.loadAuthorizationRequest(request);
if (authorizationRequest != null) {
request.getSession().removeAttribute(this.sessionAttributeName);
}
diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/converter/AuthorizationResponseConverter.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/converter/AuthorizationResponseConverter.java
index 65b1c392f5..68ebac7c92 100644
--- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/converter/AuthorizationResponseConverter.java
+++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/converter/AuthorizationResponseConverter.java
@@ -17,7 +17,7 @@ package org.springframework.security.oauth2.client.web.converter;
import org.springframework.security.oauth2.core.endpoint.AuthorizationResponse;
import org.springframework.security.oauth2.core.endpoint.OAuth2Parameter;
-import org.springframework.util.Assert;
+import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletRequest;
import java.util.function.Function;
@@ -36,12 +36,23 @@ public final class AuthorizationResponseConverter implements Function
- * An error response may be returned from either of the following locations:
- *
- *
- *
- * @author Joe Grandja
- * @since 5.0
- */
-public final class ErrorResponseAttributes {
- private OAuth2Error errorObject;
- private String state;
-
- private ErrorResponseAttributes() {
- }
-
- public String getErrorCode() {
- return this.errorObject.getErrorCode();
- }
-
- public String getDescription() {
- return this.errorObject.getDescription();
- }
-
- public String getUri() {
- return this.errorObject.getUri();
- }
-
- public String getState() {
- return this.state;
- }
-
- public static Builder withErrorCode(String errorCode) {
- return new Builder(errorCode);
- }
-
- public static class Builder {
- private String errorCode;
- private String description;
- private String uri;
- private String state;
-
- private Builder(String errorCode) {
- Assert.hasText(errorCode, "errorCode cannot be empty");
- this.errorCode = errorCode;
- }
-
- public Builder description(String description) {
- this.description = description;
- return this;
- }
-
- public Builder uri(String uri) {
- this.uri = uri;
- return this;
- }
-
- public Builder state(String state) {
- this.state = state;
- return this;
- }
-
- public ErrorResponseAttributes build() {
- ErrorResponseAttributes errorResponse = new ErrorResponseAttributes();
- errorResponse.errorObject = new OAuth2Error(this.errorCode, this.description, this.uri);
- errorResponse.state = this.state;
- return errorResponse;
- }
- }
-}
diff --git a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/TokenResponseAttributes.java b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/TokenResponse.java
similarity index 93%
rename from oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/TokenResponseAttributes.java
rename to oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/TokenResponse.java
index ffb9ca81ea..a4aa50f8d4 100644
--- a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/TokenResponseAttributes.java
+++ b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/TokenResponse.java
@@ -31,11 +31,11 @@ import java.util.Set;
* @see AccessToken
* @see Section 5.1 Access Token Response
*/
-public final class TokenResponseAttributes {
+public final class TokenResponse {
private AccessToken accessToken;
private Map