@Test void testGetAllGrantedAuthorityInclusions() { when(bbmriViewer.getName()).thenReturn("BBMRI_VIEWER"); when(bbmriViewer.getIncludes()).thenReturn(singleton(viewer)); when(dataExplorer.getName()).thenReturn("DATA_EXPLORER"); when(viewer.getName()).thenReturn("VIEWER"); when(su.getName()).thenReturn("SU"); when(su.getIncludes()) .thenReturn(ImmutableList.of(aclTakeOwnership, aclModifyAuditing, aclGeneralChanges)); when(aclTakeOwnership.getName()).thenReturn("ACL_TAKE_OWNERSHIP"); when(aclModifyAuditing.getName()).thenReturn("ACL_MODIFY_AUDITING"); when(aclGeneralChanges.getName()).thenReturn("ACL_GENERAL_CHANGES"); Builder<Object, Object> authorityBuilder = ImmutableMap.builder(); authorityBuilder.put( new SimpleGrantedAuthority("ROLE_BBMRI_VIEWER"), ImmutableSet.of(new SimpleGrantedAuthority("ROLE_VIEWER"))); authorityBuilder.put(new SimpleGrantedAuthority("ROLE_DATA_EXPLORER"), ImmutableSet.of()); authorityBuilder.put(new SimpleGrantedAuthority("ROLE_VIEWER"), ImmutableSet.of()); authorityBuilder.put( new SimpleGrantedAuthority("ROLE_SU"), ImmutableSet.of( new SimpleGrantedAuthority("ROLE_ACL_TAKE_OWNERSHIP"), new SimpleGrantedAuthority("ROLE_ACL_MODIFY_AUDITING"), new SimpleGrantedAuthority("ROLE_ACL_GENERAL_CHANGES"))); authorityBuilder.put(new SimpleGrantedAuthority("ROLE_ACL_TAKE_OWNERSHIP"), ImmutableSet.of()); authorityBuilder.put(new SimpleGrantedAuthority("ROLE_ACL_MODIFY_AUDITING"), ImmutableSet.of()); authorityBuilder.put(new SimpleGrantedAuthority("ROLE_ACL_GENERAL_CHANGES"), ImmutableSet.of()); assertEquals( authorityBuilder.build(), molgenisRoleHierarchy.getAllGrantedAuthorityInclusions()); }
public ImmutableMap<GrantedAuthority, ImmutableSet<GrantedAuthority>> getAllGrantedAuthorityInclusions() { ImmutableMap.Builder<GrantedAuthority, ImmutableSet<GrantedAuthority>> builder = ImmutableMap.builder(); for (Role role : getAllRoles()) { ImmutableSet.Builder<GrantedAuthority> includesBuilder = ImmutableSet.builder(); for (Role included : role.getIncludes()) { includesBuilder.add(createGrantedAuthority(included)); } builder.put(createGrantedAuthority(role), includesBuilder.build()); } return builder.build(); }
DataserviceRoleHierarchy implements RoleHierarchy { public ImmutableMap<GrantedAuthority, ImmutableSet<GrantedAuthority>> getAllGrantedAuthorityInclusions() { ImmutableMap.Builder<GrantedAuthority, ImmutableSet<GrantedAuthority>> builder = ImmutableMap.builder(); for (Role role : getAllRoles()) { ImmutableSet.Builder<GrantedAuthority> includesBuilder = ImmutableSet.builder(); for (Role included : role.getIncludes()) { includesBuilder.add(createGrantedAuthority(included)); } builder.put(createGrantedAuthority(role), includesBuilder.build()); } return builder.build(); } }
DataserviceRoleHierarchy implements RoleHierarchy { public ImmutableMap<GrantedAuthority, ImmutableSet<GrantedAuthority>> getAllGrantedAuthorityInclusions() { ImmutableMap.Builder<GrantedAuthority, ImmutableSet<GrantedAuthority>> builder = ImmutableMap.builder(); for (Role role : getAllRoles()) { ImmutableSet.Builder<GrantedAuthority> includesBuilder = ImmutableSet.builder(); for (Role included : role.getIncludes()) { includesBuilder.add(createGrantedAuthority(included)); } builder.put(createGrantedAuthority(role), includesBuilder.build()); } return builder.build(); } DataserviceRoleHierarchy(DataService dataService); }
DataserviceRoleHierarchy implements RoleHierarchy { public ImmutableMap<GrantedAuthority, ImmutableSet<GrantedAuthority>> getAllGrantedAuthorityInclusions() { ImmutableMap.Builder<GrantedAuthority, ImmutableSet<GrantedAuthority>> builder = ImmutableMap.builder(); for (Role role : getAllRoles()) { ImmutableSet.Builder<GrantedAuthority> includesBuilder = ImmutableSet.builder(); for (Role included : role.getIncludes()) { includesBuilder.add(createGrantedAuthority(included)); } builder.put(createGrantedAuthority(role), includesBuilder.build()); } return builder.build(); } DataserviceRoleHierarchy(DataService dataService); @Override Collection<? extends GrantedAuthority> getReachableGrantedAuthorities(
      Collection<? extends GrantedAuthority> authorities); ImmutableMap<GrantedAuthority, ImmutableSet<GrantedAuthority>> getAllGrantedAuthorityInclusions(); }
DataserviceRoleHierarchy implements RoleHierarchy { public ImmutableMap<GrantedAuthority, ImmutableSet<GrantedAuthority>> getAllGrantedAuthorityInclusions() { ImmutableMap.Builder<GrantedAuthority, ImmutableSet<GrantedAuthority>> builder = ImmutableMap.builder(); for (Role role : getAllRoles()) { ImmutableSet.Builder<GrantedAuthority> includesBuilder = ImmutableSet.builder(); for (Role included : role.getIncludes()) { includesBuilder.add(createGrantedAuthority(included)); } builder.put(createGrantedAuthority(role), includesBuilder.build()); } return builder.build(); } DataserviceRoleHierarchy(DataService dataService); @Override Collection<? extends GrantedAuthority> getReachableGrantedAuthorities(
      Collection<? extends GrantedAuthority> authorities); ImmutableMap<GrantedAuthority, ImmutableSet<GrantedAuthority>> getAllGrantedAuthorityInclusions();  }