parent
9f6af4f3b8
commit
268a1dc06e
|
@ -24,6 +24,7 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
|
@ -58,7 +59,7 @@ public class DefaultOAuth2User implements OAuth2User, Serializable {
|
|||
if (!attributes.containsKey(nameAttributeKey)) {
|
||||
throw new IllegalArgumentException("Missing attribute '" + nameAttributeKey + "' in attributes");
|
||||
}
|
||||
this.authorities = Collections.unmodifiableSet(this.sortAuthorities(authorities));
|
||||
this.authorities = Collections.unmodifiableSet(new LinkedHashSet<>(this.sortAuthorities(authorities)));
|
||||
this.attributes = Collections.unmodifiableMap(new LinkedHashMap<>(attributes));
|
||||
this.nameAttributeKey = nameAttributeKey;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.springframework.security.oauth2.core.user;
|
|||
import org.junit.Test;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.util.SerializationUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
@ -79,4 +80,11 @@ public class DefaultOAuth2UserTests {
|
|||
assertThat(user.getAuthorities().iterator().next()).isEqualTo(AUTHORITY);
|
||||
assertThat(user.getAttributes()).containsOnlyKeys(ATTRIBUTE_NAME_KEY);
|
||||
}
|
||||
|
||||
// gh-4917
|
||||
@Test
|
||||
public void constructorWhenCreatedThenIsSerializable() {
|
||||
DefaultOAuth2User user = new DefaultOAuth2User(AUTHORITIES, ATTRIBUTES, ATTRIBUTE_NAME_KEY);
|
||||
SerializationUtils.serialize(user);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue