Polish RoleHierachyImpl#of
- Change to #fromHierarchy to match naming convention - Keep existing test methods the same - Deprecate setHierarchy and default constructor - Add private Map constructor - Change Adjust RoleHierarchyBuilder to use Map constructor Issue gh-13788
This commit is contained in:
@@ -273,14 +273,14 @@ Xml::
|
||||
[source,java,role="secondary"]
|
||||
----
|
||||
<bean id="roleHierarchy"
|
||||
class="org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl">
|
||||
<property name="hierarchy">
|
||||
class="org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl" factory-method="fromHierarchy">
|
||||
<constructor-arg>
|
||||
<value>
|
||||
ROLE_ADMIN > ROLE_STAFF
|
||||
ROLE_STAFF > ROLE_USER
|
||||
ROLE_USER > ROLE_GUEST
|
||||
</value>
|
||||
</property>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<!-- and, if using method security also add -->
|
||||
|
||||
@@ -233,7 +233,7 @@ Java::
|
||||
----
|
||||
@Bean
|
||||
static RoleHierarchy roleHierarchy() {
|
||||
return new RoleHierarchyImpl("ROLE_ADMIN > permission:read");
|
||||
return RoleHierarchyImpl.fromHierarchy("ROLE_ADMIN > permission:read");
|
||||
}
|
||||
----
|
||||
|
||||
@@ -244,7 +244,7 @@ Kotlin::
|
||||
companion object {
|
||||
@Bean
|
||||
fun roleHierarchy(): RoleHierarchy {
|
||||
return RoleHierarchyImpl("ROLE_ADMIN > permission:read")
|
||||
return RoleHierarchyImpl.fromHierarchy("ROLE_ADMIN > permission:read")
|
||||
}
|
||||
}
|
||||
----
|
||||
@@ -253,7 +253,8 @@ Xml::
|
||||
+
|
||||
[source,xml,role="secondary"]
|
||||
----
|
||||
<bean id="roleHierarchy" class="org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl">
|
||||
<bean id="roleHierarchy"
|
||||
class="org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl" factory-method="fromHierarchy">
|
||||
<constructor-arg value="ROLE_ADMIN > permission:read"/>
|
||||
</bean>
|
||||
----
|
||||
|
||||
Reference in New Issue
Block a user