Skip to content

Commit

Permalink
Revert "Add OAuth2AuthenticatedPrincipal.getNameAttributeKey"
Browse files Browse the repository at this point in the history
This reverts commit 464b078.
  • Loading branch information
andreblanke committed Dec 8, 2024
1 parent 88b0d4d commit 1cc7a73
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2019 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.
Expand Down Expand Up @@ -64,7 +64,7 @@ public DefaultOAuth2AuthenticatedPrincipal(String name, Map<String, Object> attr
this.attributes = Collections.unmodifiableMap(attributes);
this.authorities = (authorities != null) ? Collections.unmodifiableCollection(authorities)
: AuthorityUtils.NO_AUTHORITIES;
this.name = (name != null) ? name : (String) this.attributes.get(this.getNameAttributeKey());
this.name = (name != null) ? name : (String) this.attributes.get("sub");
}

/**
Expand All @@ -81,11 +81,6 @@ public Collection<? extends GrantedAuthority> getAuthorities() {
return this.authorities;
}

@Override
public String getNameAttributeKey() {
return "sub";
}

@Override
public String getName() {
return this.name;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2019 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.
Expand Down Expand Up @@ -57,11 +57,4 @@ default <A> A getAttribute(String name) {
*/
Collection<? extends GrantedAuthority> getAuthorities();

/**
* Get the key used to access the user's &quot;name&quot; from {@link #getAttributes()}
* @return the key used to access the user's &quot;name&quot;
* @since 6.4
*/
String getNameAttributeKey();

}
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ public Map<String, Object> getAttributes() {
return this.attributes;
}

@Override
public String getNameAttributeKey() {
return this.nameAttributeKey;
}

private Set<GrantedAuthority> sortAuthorities(Collection<? extends GrantedAuthority> authorities) {
SortedSet<GrantedAuthority> sortedAuthorities = new TreeSet<>(
Comparator.comparing(GrantedAuthority::getAuthority));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-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.
Expand Down Expand Up @@ -80,11 +80,6 @@ public Collection<? extends GrantedAuthority> getAuthorities() {
return this.delegate.getAuthorities();
}

@Override
public String getNameAttributeKey() {
return this.delegate.getNameAttributeKey();
}

@Override
public String getName() {
return this.delegate.getName();
Expand Down

0 comments on commit 1cc7a73

Please sign in to comment.