diff --git a/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/introspection/OAuth2IntrospectionAuthenticatedPrincipal.java b/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/introspection/OAuth2IntrospectionAuthenticatedPrincipal.java
index 0f4f925440..8e9427831e 100644
--- a/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/introspection/OAuth2IntrospectionAuthenticatedPrincipal.java
+++ b/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/introspection/OAuth2IntrospectionAuthenticatedPrincipal.java
@@ -16,16 +16,13 @@
package org.springframework.security.oauth2.server.resource.introspection;
-import static org.springframework.security.core.authority.AuthorityUtils.NO_AUTHORITIES;
-
import java.io.Serializable;
import java.util.Collection;
-import java.util.Collections;
import java.util.Map;
import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.oauth2.core.DefaultOAuth2AuthenticatedPrincipal;
import org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal;
-import org.springframework.util.Assert;
/**
* A domain object that wraps the attributes of OAuth 2.0 Token Introspection.
@@ -34,11 +31,9 @@ import org.springframework.util.Assert;
* @since 5.4
* @see Introspection Response
*/
-public final class OAuth2IntrospectionAuthenticatedPrincipal implements OAuth2AuthenticatedPrincipal,
- OAuth2IntrospectionClaimAccessor, Serializable {
- private final Map attributes;
- private final Collection authorities;
- private final String name;
+public final class OAuth2IntrospectionAuthenticatedPrincipal implements OAuth2IntrospectionClaimAccessor,
+ OAuth2AuthenticatedPrincipal, Serializable {
+ private final OAuth2AuthenticatedPrincipal delegate;
/**
* Constructs an {@code OAuth2IntrospectionAuthenticatedPrincipal} using the provided parameters.
@@ -49,7 +44,7 @@ public final class OAuth2IntrospectionAuthenticatedPrincipal implements OAuth2Au
public OAuth2IntrospectionAuthenticatedPrincipal(Map attributes,
Collection authorities) {
- this(null, attributes, authorities);
+ this.delegate = new DefaultOAuth2AuthenticatedPrincipal(attributes, authorities);
}
/**
@@ -62,11 +57,7 @@ public final class OAuth2IntrospectionAuthenticatedPrincipal implements OAuth2Au
public OAuth2IntrospectionAuthenticatedPrincipal(String name, Map attributes,
Collection authorities) {
- Assert.notEmpty(attributes, "attributes cannot be empty");
- this.attributes = Collections.unmodifiableMap(attributes);
- this.authorities = authorities == null ?
- NO_AUTHORITIES : Collections.unmodifiableCollection(authorities);
- this.name = name == null ? getSubject() : name;
+ this.delegate = new DefaultOAuth2AuthenticatedPrincipal(name, attributes, authorities);
}
/**
@@ -76,7 +67,7 @@ public final class OAuth2IntrospectionAuthenticatedPrincipal implements OAuth2Au
*/
@Override
public Map getAttributes() {
- return this.attributes;
+ return this.delegate.getAttributes();
}
/**
@@ -87,7 +78,7 @@ public final class OAuth2IntrospectionAuthenticatedPrincipal implements OAuth2Au
*/
@Override
public Collection extends GrantedAuthority> getAuthorities() {
- return this.authorities;
+ return this.delegate.getAuthorities();
}
/**
@@ -95,7 +86,7 @@ public final class OAuth2IntrospectionAuthenticatedPrincipal implements OAuth2Au
*/
@Override
public String getName() {
- return this.name;
+ return this.delegate.getName();
}
/**