InterpreterSetting { public boolean isUserAuthorized(List<String> userAndRoles) { if (!option.permissionIsSet()) { return true; } Set<String> intersection = new HashSet<>(userAndRoles); intersection.retainAll(option.getOwners()); return !intersection.isEmpty(); } InterpreterSetting();  InterpreterSetting(InterpreterSetting o); AngularObjectRegistryListener getAngularObjectRegistryListener(); RemoteInterpreterProcessListener getRemoteInterpreterProcessListener(); ApplicationEventListener getAppEventListener(); DependencyResolver getDependencyResolver(); InterpreterSettingManager getInterpreterSettingManager(); InterpreterSetting setAngularObjectRegistryListener(AngularObjectRegistryListener
                                                   angularObjectRegistryListener); InterpreterSetting setAppEventListener(ApplicationEventListener appEventListener); InterpreterSetting setRemoteInterpreterProcessListener(RemoteInterpreterProcessListener
                                                      remoteInterpreterProcessListener); InterpreterSetting setDependencyResolver(DependencyResolver dependencyResolver); InterpreterSetting setInterpreterSettingManager(
      InterpreterSettingManager interpreterSettingManager); InterpreterSetting setRecoveryStorage(RecoveryStorage recoveryStorage); InterpreterSetting setInterpreterEventServer(
      RemoteInterpreterEventServer interpreterEventServer); InterpreterInfo getInterpreterInfo(String name); Map<String, Object> getConfig(String className); RecoveryStorage getRecoveryStorage(); String getId(); void setId(String id); String getName(); String getGroup(); ManagedInterpreterGroup getOrCreateInterpreterGroup(String user, String noteId); ManagedInterpreterGroup getOrCreateInterpreterGroup(ExecutionContext executionContext); ManagedInterpreterGroup getInterpreterGroup(String user, String noteId); ManagedInterpreterGroup getInterpreterGroup(ExecutionContext executionContext); List<ManagedInterpreterGroup> getAllInterpreterGroups(); void closeInterpreters(String user, String noteId); void closeInterpreters(String interpreterGroupId); void closeInterpreters(ExecutionContext executionContext); void close(); void setProperties(Object object); void fillPropertyDescription(Object propertiesInTemplate); void sortPropertiesByTemplate(Object propertiesInTemplate); Object getProperties(); @VisibleForTesting void setProperty(String name, String value); Properties getJavaProperties(); ZeppelinConfiguration getConf(); InterpreterSetting setConf(ZeppelinConfiguration conf); List<Dependency> getDependencies(); void setDependencies(List<Dependency> dependencies); InterpreterOption getOption(); void setOption(InterpreterOption option); String getInterpreterDir(); void setInterpreterDir(String interpreterDir); List<InterpreterInfo> getInterpreterInfos(); void setProperties(Properties p); Status getStatus(); void setStatus(Status status); String getErrorReason(); void setErrorReason(String errorReason); void setInterpreterInfos(List<InterpreterInfo> interpreterInfos); InterpreterRunner getInterpreterRunner(); void setInterpreterRunner(InterpreterRunner interpreterRunner); String getLauncherPlugin(Properties properties); boolean isUserAuthorized(List<String> userAndRoles); Interpreter getDefaultInterpreter(String user, String noteId); Interpreter getDefaultInterpreter(ExecutionContext executionContext); Interpreter getInterpreter(String user, String noteId, String replName); Interpreter getInterpreter(ExecutionContext executionContext, String replName); void setInterpreterGroupProperties(String interpreterGroupId, Properties properties); void convertPermissionsFromUsersToOwners(JsonObject jsonObject); void waitForReady(long timeout); void waitForReady(); InterpreterInfo getDefaultInterpreterInfo(); static String toJson(InterpreterSetting intpSetting); static InterpreterSetting fromJson(String json); static String PARAGRAPH_CONFIG_RUNONSELECTIONCHANGE; static String PARAGRAPH_CONFIG_TITLE; static String PARAGRAPH_CONFIG_CHECK_EMTPY; static final String CLUSTER_INTERPRETER_LAUNCHER_NAME; }
@Test public void testIsUserAuthorized() { List<String> userAndRoles = new ArrayList<>(); userAndRoles.add("User1"); userAndRoles.add("Role1"); userAndRoles.add("Role2"); List<String> owners; InterpreterSetting interpreterSetting; InterpreterOption interpreterOption; owners = new ArrayList<>(); owners.add("Role1"); interpreterOption = new InterpreterOption(); interpreterOption.setUserPermission(true); interpreterOption.owners = owners; interpreterSetting = new InterpreterSetting.Builder() .setId("id") .setName("id") .setGroup("group") .setOption(interpreterOption) .create(); assertTrue(interpreterSetting.isUserAuthorized(userAndRoles)); owners = new ArrayList<>(); owners.add("Role88"); interpreterOption = new InterpreterOption(); interpreterOption.setUserPermission(true); interpreterOption.owners = owners; interpreterSetting = new InterpreterSetting.Builder() .setId("id") .setName("id") .setGroup("group") .setOption(interpreterOption) .create(); assertFalse(interpreterSetting.isUserAuthorized(userAndRoles)); owners = new ArrayList<>(); interpreterOption = new InterpreterOption(); interpreterOption.setUserPermission(false); interpreterOption.owners = owners; interpreterSetting = new InterpreterSetting.Builder() .setId("id") .setName("id") .setGroup("group") .setOption(interpreterOption) .create(); assertTrue(interpreterSetting.isUserAuthorized(userAndRoles)); }