Skip to content

Commit 1bbbd04

Browse files
evgeniychebanjzheaux
authored andcommitted
Polish gh-12231
- Update copyright header - Use Set.of instead of HashSet in AuthorityAuthorizationManager - Align roleHierarchy test name with other tests in AuthoritiesAuthorizationManagerTests
1 parent e0d676c commit 1bbbd04

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

core/src/main/java/org/springframework/security/authorization/AuthorityAuthorizationManager.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,8 +16,6 @@
1616

1717
package org.springframework.security.authorization;
1818

19-
import java.util.Arrays;
20-
import java.util.HashSet;
2119
import java.util.Set;
2220
import java.util.function.Supplier;
2321

@@ -43,7 +41,7 @@ public final class AuthorityAuthorizationManager<T> implements AuthorizationMana
4341
private final Set<String> authorities;
4442

4543
private AuthorityAuthorizationManager(String... authorities) {
46-
this.authorities = new HashSet<>(Arrays.asList(authorities));
44+
this.authorities = Set.of(authorities);
4745
}
4846

4947
/**

core/src/test/java/org/springframework/security/authorization/AuthoritiesAuthorizationManagerTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -74,14 +74,14 @@ void checkWhenUserHasNotAnyAuthorityThenDeniedDecision() {
7474
}
7575

7676
@Test
77-
void hasRoleWhenRoleHierarchySetThenGreaterRoleTakesPrecedence() {
77+
void checkWhenRoleHierarchySetThenGreaterRoleTakesPrecedence() {
7878
AuthoritiesAuthorizationManager manager = new AuthoritiesAuthorizationManager();
7979
RoleHierarchyImpl roleHierarchy = new RoleHierarchyImpl();
8080
roleHierarchy.setHierarchy("ROLE_ADMIN > ROLE_USER");
8181
manager.setRoleHierarchy(roleHierarchy);
8282
Supplier<Authentication> authentication = () -> new TestingAuthenticationToken("user", "password",
8383
"ROLE_ADMIN");
84-
assertThat(manager.check(authentication, Collections.singleton("ROLE_ADMIN")).isGranted()).isTrue();
84+
assertThat(manager.check(authentication, Collections.singleton("ROLE_USER")).isGranted()).isTrue();
8585
}
8686

8787
}

0 commit comments

Comments
 (0)