org.springframework.security.access.hierarchicalroles.RoleHierarchy Java Examples

The following examples show how to use org.springframework.security.access.hierarchicalroles.RoleHierarchy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PermissionManager.java    From zhcet-web with Apache License 2.0 5 votes vote down vote up
@Autowired
public PermissionManager(RoleHierarchy roleHierarchy, CourseService courseService, FloatedCourseService floatedCourseService, NotificationRepository notificationRepository, NotificationRecipientRepository notificationRecipientRepository) {
    this.roleHierarchy = roleHierarchy;
    this.courseService = courseService;
    this.notificationRepository = notificationRepository;
    this.notificationRecipientRepository = notificationRecipientRepository;
}
 
Example #2
Source File: AclConfig.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
public AclConfig(
    DataSource dataSource,
    TransactionManager transactionManager,
    RoleHierarchy roleHierarchy,
    ConversionService conversionService,
    EntityHelper entityHelper) {
  this.dataSource = requireNonNull(dataSource);
  this.transactionManager = requireNonNull(transactionManager);
  this.roleHierarchy = requireNonNull(roleHierarchy);
  this.conversionService = requireNonNull(conversionService);
  this.entityHelper = requireNonNull(entityHelper);
}
 
Example #3
Source File: SecurityConfiguration.java    From haven-platform with Apache License 2.0 5 votes vote down vote up
@Bean
RoleHierarchy roleHierarchy() {
    return RoleHierarchyImpl.builder()
      .childs(Authorities.ADMIN_ROLE, /*SecuredType.CLUSTER.admin(),*/ Authorities.USER_ROLE)
      /*.childs(SecuredType.CLUSTER.admin(), Authorities.USER_ROLE)
      .childs(SecuredType.CLUSTER.admin(), SecuredType.CONTAINER.admin(),
         SecuredType.LOCAL_IMAGE.admin(),
         SecuredType.NETWORK.admin(),
         SecuredType.NODE.admin()
      )*/
      .build();
}
 
Example #4
Source File: WallRideSecurityConfiguration.java    From wallride with Apache License 2.0 5 votes vote down vote up
@Bean
public RoleHierarchy roleHierarchy() {
	RoleHierarchyImpl hierarchy = new RoleHierarchyImpl();
	hierarchy.setHierarchy("ROLE_ADMIN > ROLE_VIEWER");
	return hierarchy;
}
 
Example #5
Source File: OAuth2AutoConfigurationTests.java    From spring-security-oauth2-boot with Apache License 2.0 5 votes vote down vote up
@Test
public void methodSecurityExpressionHandlerIsConfiguredWithRoleHierarchyFromTheContext() {
	this.context = new AnnotationConfigServletWebServerApplicationContext();
	this.context.register(RoleHierarchyConfiguration.class, AuthorizationAndResourceServerConfiguration.class,
			MinimalSecureWebApplication.class);
	this.context.refresh();
	PreInvocationAuthorizationAdvice advice = this.context.getBean(PreInvocationAuthorizationAdvice.class);
	MethodSecurityExpressionHandler expressionHandler = (MethodSecurityExpressionHandler) ReflectionTestUtils
			.getField(advice, "expressionHandler");
	RoleHierarchy roleHierarchy = (RoleHierarchy) ReflectionTestUtils.getField(expressionHandler, "roleHierarchy");
	assertThat(roleHierarchy).isSameAs(this.context.getBean(RoleHierarchy.class));
}
 
Example #6
Source File: MethodSecurityConfig.java    From demo-spring-security-cas with Apache License 2.0 5 votes vote down vote up
@Bean
public RoleHierarchy roleHierarchy() {
	RoleHierarchyImpl rhi = new RoleHierarchyImpl();
	rhi.setHierarchy(AuthoritiesConstants.ADMIN + " > " + AuthoritiesConstants.USER + " "
			+ AuthoritiesConstants.USER + " > " + AuthoritiesConstants.ANONYMOUS);
	return rhi;
}
 
Example #7
Source File: TenantSidRetrievalStrategy.java    From haven-platform with Apache License 2.0 4 votes vote down vote up
public TenantSidRetrievalStrategy(RoleHierarchy roleHierarchy) {
    Assert.notNull(roleHierarchy, "RoleHierarchy must not be null");
    this.roleHierarchy = roleHierarchy;
}
 
Example #8
Source File: MySecurityExpressionRoot.java    From tutorials with MIT License 4 votes vote down vote up
public void setRoleHierarchy(RoleHierarchy roleHierarchy) {
    this.roleHierarchy = roleHierarchy;
}
 
Example #9
Source File: SecurityITConfig.java    From molgenis with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Bean
public RoleHierarchy roleHierarchy() {
  return mock(RoleHierarchy.class);
}
 
Example #10
Source File: MolgenisWebAppSecurityConfig.java    From molgenis with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Bean
public RoleHierarchy roleHierarchyBean() {
  return roleHierarchy();
}
 
Example #11
Source File: WebAppSecurityConfig.java    From molgenis with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public RoleHierarchy roleHierarchy() {
  return new CachedRoleHierarchyImpl(
      new DataserviceRoleHierarchy(dataService), transactionManager);
}
 
Example #12
Source File: SecurityConfiguration.java    From haven-platform with Apache License 2.0 4 votes vote down vote up
@Bean
SidRetrievalStrategy sidRetrievalStrategy(RoleHierarchy roleHierarchy) {
    return new TenantSidRetrievalStrategy(roleHierarchy);
}
 
Example #13
Source File: SecurityBeans.java    From zhcet-web with Apache License 2.0 4 votes vote down vote up
@Bean
protected DefaultWebSecurityExpressionHandler webExpressionHandler(RoleHierarchy roleHierarchy) {
    DefaultWebSecurityExpressionHandler defaultWebSecurityExpressionHandler = new DefaultWebSecurityExpressionHandler();
    defaultWebSecurityExpressionHandler.setRoleHierarchy(roleHierarchy);
    return defaultWebSecurityExpressionHandler;
}
 
Example #14
Source File: SecurityBeans.java    From zhcet-web with Apache License 2.0 4 votes vote down vote up
@Bean
RoleVoter roleVoter(RoleHierarchy roleHierarchy) {
    return new RoleHierarchyVoter(roleHierarchy);
}
 
Example #15
Source File: PermissionExpressionHandler.java    From zhcet-web with Apache License 2.0 4 votes vote down vote up
public PermissionExpressionHandler(RoleHierarchy roleHierarchy) {
    setRoleHierarchy(roleHierarchy);
}
 
Example #16
Source File: MethodSecurityConfig.java    From zhcet-web with Apache License 2.0 4 votes vote down vote up
@Autowired
public MethodSecurityConfig(RoleHierarchy roleHierarchy) {
    this.roleHierarchy = roleHierarchy;
}
 
Example #17
Source File: OAuth2AutoConfigurationTests.java    From spring-security-oauth2-boot with Apache License 2.0 4 votes vote down vote up
@Bean
public RoleHierarchy roleHierarchy() {
	return mock(RoleHierarchy.class);
}
 
Example #18
Source File: MolgenisWebAppSecurityConfig.java    From molgenis with GNU Lesser General Public License v3.0 votes vote down vote up
protected abstract RoleHierarchy roleHierarchy();