Skip to content

Commit e10e837

Browse files
committed
Polish SimpleGrantedAuthority
1. Add Javadoc to state that role is prefixed. 2. Rename constructor argument from `role` to `authority` for better readability. Signed-off-by: Yanming Zhou <[email protected]>
1 parent 0d261e9 commit e10e837

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

core/src/main/java/org/springframework/security/core/authority/SimpleGrantedAuthority.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,22 @@
2727
* {@link org.springframework.security.core.Authentication Authentication} object.
2828
*
2929
* @author Luke Taylor
30+
* @author Yanming Zhou
3031
*/
3132
public final class SimpleGrantedAuthority implements GrantedAuthority {
3233

3334
private static final long serialVersionUID = 620L;
3435

36+
// CAUTION renaming to authority will break serialization compatibility
3537
private final String role;
3638

37-
public SimpleGrantedAuthority(String role) {
38-
Assert.hasText(role, "A granted authority textual representation is required");
39-
this.role = role;
39+
/**
40+
* Constructs a {@code SimpleGrantedAuthority} using the provided authority.
41+
* @param authority The provided authority such as prefixed role
42+
*/
43+
public SimpleGrantedAuthority(String authority) {
44+
Assert.hasText(authority, "A granted authority textual representation is required");
45+
this.role = authority;
4046
}
4147

4248
@Override

0 commit comments

Comments
 (0)