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

The following examples show how to use org.springframework.security.access.hierarchicalroles.RoleHierarchy. These examples are extracted from open source projects. 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
@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 2
Source Project: zhcet-web   Source File: PermissionManager.java    License: 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 3
Source Project: haven-platform   Source File: SecurityConfiguration.java    License: 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
@Bean
public RoleHierarchy roleHierarchy() {
	RoleHierarchyImpl rhi = new RoleHierarchyImpl();
	rhi.setHierarchy(AuthoritiesConstants.ADMIN + " > " + AuthoritiesConstants.USER + " "
			+ AuthoritiesConstants.USER + " > " + AuthoritiesConstants.ANONYMOUS);
	return rhi;
}
 
Example 5
Source Project: molgenis   Source File: AclConfig.java    License: 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 6
@Bean
public RoleHierarchy roleHierarchy() {
	return mock(RoleHierarchy.class);
}
 
Example 7
Source Project: zhcet-web   Source File: MethodSecurityConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Autowired
public MethodSecurityConfig(RoleHierarchy roleHierarchy) {
    this.roleHierarchy = roleHierarchy;
}
 
Example 8
Source Project: zhcet-web   Source File: PermissionExpressionHandler.java    License: Apache License 2.0 4 votes vote down vote up
public PermissionExpressionHandler(RoleHierarchy roleHierarchy) {
    setRoleHierarchy(roleHierarchy);
}
 
Example 9
Source Project: zhcet-web   Source File: SecurityBeans.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
RoleVoter roleVoter(RoleHierarchy roleHierarchy) {
    return new RoleHierarchyVoter(roleHierarchy);
}
 
Example 10
Source Project: zhcet-web   Source File: SecurityBeans.java    License: 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 11
Source Project: haven-platform   Source File: SecurityConfiguration.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
SidRetrievalStrategy sidRetrievalStrategy(RoleHierarchy roleHierarchy) {
    return new TenantSidRetrievalStrategy(roleHierarchy);
}
 
Example 12
Source Project: haven-platform   Source File: TenantSidRetrievalStrategy.java    License: 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 13
Source Project: wallride   Source File: WallRideSecurityConfiguration.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public RoleHierarchy roleHierarchy() {
	RoleHierarchyImpl hierarchy = new RoleHierarchyImpl();
	hierarchy.setHierarchy("ROLE_ADMIN > ROLE_VIEWER");
	return hierarchy;
}
 
Example 14
@Override
public RoleHierarchy roleHierarchy() {
  return new CachedRoleHierarchyImpl(
      new DataserviceRoleHierarchy(dataService), transactionManager);
}
 
Example 15
@Bean
public RoleHierarchy roleHierarchyBean() {
  return roleHierarchy();
}
 
Example 16
@Bean
public RoleHierarchy roleHierarchy() {
  return mock(RoleHierarchy.class);
}
 
Example 17
Source Project: tutorials   Source File: MySecurityExpressionRoot.java    License: MIT License 4 votes vote down vote up
public void setRoleHierarchy(RoleHierarchy roleHierarchy) {
    this.roleHierarchy = roleHierarchy;
}
 
Example 18
protected abstract RoleHierarchy roleHierarchy();