From 599ed3e96b5432d4b9b57bce03d5546e90faf246 Mon Sep 17 00:00:00 2001 From: Josh Cummings Date: Mon, 24 Apr 2023 12:52:26 -0600 Subject: [PATCH] Polish Format Issue gh-13079 --- .../security/authorization/AuthorityAuthorizationManager.java | 4 ++-- .../authorization/AuthorityAuthorizationManagerTests.java | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/springframework/security/authorization/AuthorityAuthorizationManager.java b/core/src/main/java/org/springframework/security/authorization/AuthorityAuthorizationManager.java index 983bee7fbe..bf95c18fb8 100644 --- a/core/src/main/java/org/springframework/security/authorization/AuthorityAuthorizationManager.java +++ b/core/src/main/java/org/springframework/security/authorization/AuthorityAuthorizationManager.java @@ -130,8 +130,8 @@ public final class AuthorityAuthorizationManager implements AuthorizationMana String[] result = new String[roles.length]; for (int i = 0; i < roles.length; i++) { String role = roles[i]; - Assert.isTrue(rolePrefix.isEmpty() || !role.startsWith(rolePrefix), () -> role + " should not start with " + rolePrefix + " since " - + rolePrefix + Assert.isTrue(rolePrefix.isEmpty() || !role.startsWith(rolePrefix), () -> role + " should not start with " + + rolePrefix + " since " + rolePrefix + " is automatically prepended when using hasAnyRole. Consider using hasAnyAuthority instead."); result[i] = rolePrefix + role; } diff --git a/core/src/test/java/org/springframework/security/authorization/AuthorityAuthorizationManagerTests.java b/core/src/test/java/org/springframework/security/authorization/AuthorityAuthorizationManagerTests.java index 3bec282dc0..176de1ee40 100644 --- a/core/src/test/java/org/springframework/security/authorization/AuthorityAuthorizationManagerTests.java +++ b/core/src/test/java/org/springframework/security/authorization/AuthorityAuthorizationManagerTests.java @@ -271,4 +271,5 @@ public class AuthorityAuthorizationManagerTests { void hasAnyRoleWhenEmptyRolePrefixThenNoException() { AuthorityAuthorizationManager.hasAnyRole("", new String[] { "USER" }); } + }