UserRoleDaoService { public SystemRolesMap getRoleBindingStruct( String locale ) throws SecurityException { if ( canAdminister() ) { RoleBindingStruct roleBindingStruct = getRoleBindingDao().getRoleBindingStruct( locale ); SystemRolesMap systemRolesMap = new SystemRolesMap(); for ( Map.Entry<String, String> localalizeNameEntry : roleBindingStruct.logicalRoleNameMap.entrySet() ) { systemRolesMap.getLocalizedRoleNames().add( new LocalizedLogicalRoleName( localalizeNameEntry.getKey(), localalizeNameEntry.getValue() ) ); } for ( Map.Entry<String, List<String>> logicalRoleAssignments : roleBindingStruct.bindingMap.entrySet() ) { systemRolesMap.getAssignments().add( new LogicalRoleAssignment( logicalRoleAssignments.getKey(), logicalRoleAssignments.getValue(), roleBindingStruct.immutableRoles.contains( logicalRoleAssignments.getKey() ) ) ); } return systemRolesMap; } else { throw new SecurityException(); } }  UserListWrapper getUsers(); RoleListWrapper getRolesForUser( String user ); void assignRolesToUser( String userName, String roleNames ); void removeRolesFromUser( String userName, String roleNames ); void createRole( String roleName ); RoleListWrapper getRoles(); UserListWrapper getRoleMembers( String roleName ); void createUser( User user ); void changeUserPassword( final String userName, final String newPass, String oldPass ); void deleteUsers( String userNames ); void deleteRoles( String roleNames ); SystemRolesMap getRoleBindingStruct( String locale ); void setLogicalRoles( LogicalRoleAssignments roleAssignments ); void updatePassword( User user, String administratorPassword ); void updatePassword( User user ); static final String PUC_USER_PASSWORD_LENGTH; static final String PUC_USER_PASSWORD_REQUIRE_SPECIAL_CHARACTER; }
@Test public void testGetRoleBindingStruct() { setupMockSessionUser( SESSION_USER_NAME, true ); Map<String, String> localizedNameEntry = new HashMap<>(); localizedNameEntry.put( "testEntry", "testValue" ); Map<String, List<String>> testBindingMap = new HashMap<>(); testBindingMap.put( "testBinding", new ArrayList<String>() ); RoleBindingStruct roleBindingStruct = mock( RoleBindingStruct.class ); roleBindingStruct.logicalRoleNameMap = localizedNameEntry; roleBindingStruct.bindingMap = testBindingMap; roleBindingStruct.immutableRoles = new HashSet<>(); IRoleAuthorizationPolicyRoleBindingDao roleBindingDao = mock( IRoleAuthorizationPolicyRoleBindingDao.class ); when( roleBindingDao.getRoleBindingStruct( anyString() ) ).thenReturn( roleBindingStruct ); PentahoSystem.registerObject( roleBindingDao ); SystemRolesMap validateMap = userRoleService.getRoleBindingStruct( "en" ); assert ( 1 == validateMap.getLocalizedRoleNames().size() ); assertEquals( "testEntry", validateMap.getLocalizedRoleNames().get( 0 ).getRoleName() ); assertEquals( "testValue", validateMap.getLocalizedRoleNames().get( 0 ).getLocalizedName() ); }
@Test( expected = SecurityException.class ) public void testGetRoleBindingStructSecurityException() { setupMockSessionUser( SESSION_USER_NAME, false ); userRoleService.getRoleBindingStruct( "en" ); }