List of usage examples for org.apache.commons.lang SystemUtils IS_OS_WINDOWS
boolean IS_OS_WINDOWS
To view the source code for org.apache.commons.lang SystemUtils IS_OS_WINDOWS.
Click Source Link
Is true
if this is Windows.
The field will return false
if OS_NAME
is null
.
From source file:com.sonar.runner.it.JavaTest.java
@Test public void use_old_script_and_old_env_variable() { SonarScanner build = newScanner(new File("projects/java-sample")).setUseOldSonarRunnerScript(true) .setEnvironmentVariable("SONAR_RUNNER_OPTS", "-Xmx2m"); BuildResult executeBuild = orchestrator.executeBuildQuietly(build); assertThat(executeBuild.getStatus()).isNotEqualTo(0); String logs = executeBuild.getLogs(); if (SystemUtils.IS_OS_WINDOWS) { assertThat(logs)/*www.j a v a2 s. com*/ .contains("WARN: sonar-runner.bat script is deprecated. Please use sonar-scanner.bat instead."); assertThat(logs) .contains("WARN: SONAR_RUNNER_OPTS is deprecated. Please use SONAR_SCANNER_OPTS instead."); } else { assertThat(logs).contains("WARN: sonar-runner script is deprecated. Please use sonar-scanner instead."); assertThat(logs) .contains("WARN: $SONAR_RUNNER_OPTS is deprecated. Please use $SONAR_SCANNER_OPTS instead."); } assertThat(logs).contains("java.lang.OutOfMemoryError"); }
From source file:com.vmware.identity.idm.server.ServerUtils.java
private static ILdapConnectionEx getLdapConnection(URI uri, String userName, String password, AuthenticationType authType, boolean useGcPort, LdapCertificateValidationSettings certValidationsettings) throws Exception { ValidateUtil.validateNotNull(uri, "uri"); boolean isLdaps = uri.getScheme().compareToIgnoreCase(DirectoryStoreProtocol.LDAPS.getName()) == 0; List<LdapSetting> connOptions = null; List<LdapSetting> settings = new ArrayList<LdapSetting>(); settings.add(new LdapSetting(LdapOption.LDAP_OPT_PROTOCOL_VERSION, LdapConstants.LDAP_VERSION3)); settings.add(new LdapSetting(LdapOption.LDAP_OPT_REFERRALS, Boolean.FALSE)); settings.add(new LdapSetting(LdapOption.LDAP_OPT_NETWORK_TIMEOUT, DEFAULT_LDAP_NETWORK_TIMEOUT)); if (isLdaps) { //if is ldaps connection and certificate validation is enabled set the options for validation boolean isLdapsCertValidationEnabled = certValidationsettings != null && (certValidationsettings.isForceValidation() || IdmServerConfig.getInstance().isLdapsCertValidationEnabled() || !certValidationsettings.isLegacy()); if (isLdapsCertValidationEnabled) { ISslX509VerificationCallback certVerifierCallback = certValidationsettings .getCertVerificationCallback(uri); settings.add(new LdapSetting(LdapOption.LDAP_OPT_X_TLS_REQUIRE_CERT, LdapConstants.LDAP_OPT_X_TLS_DEMAND)); settings.add(/*from w w w. j av a 2s .com*/ new LdapSetting(LdapOption.LDAP_OPT_X_CLIENT_TRUSTED_FP_CALLBACK, certVerifierCallback)); int sslMinProtocol = certValidationsettings.isLegacy() ? LdapSSLProtocols.getDefaultLegacyMinProtocol().getCode() : LdapSSLProtocols.getDefaultMinProtocol().getCode(); settings.add(new LdapSetting(LdapOption.LDAP_OPT_X_TLS_PROTOCOL, sslMinProtocol)); } else { settings.add(new LdapSetting(LdapOption.LDAP_OPT_X_TLS_REQUIRE_CERT, LdapConstants.LDAP_OPT_X_TLS_NEVER)); } } // When doing GSSAPI authentication, LDAP SASL binding by default does reverse DNS lookup to validate the // target name, this causes authentication failures because Most DNS servers in AD do not have PTR records // registered for all DCs, any of which could be the binding target. if (!SystemUtils.IS_OS_WINDOWS && authType == AuthenticationType.USE_KERBEROS || authType == AuthenticationType.SRP) { settings.add(new LdapSetting(LdapOption.LDAP_OPT_X_SASL_NOCANON, LdapConstants.LDAP_OPT_ON)); } connOptions = Collections.unmodifiableList(settings); ILdapConnectionEx connection = null; // if No port# or the default port of 389 (ldap) or 636 (ldaps) is specified then useGcport takes effect; // otherwise, go with the explicit specified port# if (authType == AuthenticationType.SRP) { connection = (ILdapConnectionEx) LdapConnectionFactory.getInstance().getLdapConnection(uri, connOptions, true); } else if ((uri.getPort() == -1 || uri.getPort() == LdapConstants.LDAP_PORT || uri.getPort() == LdapConstants.LDAP_SSL_PORT) && useGcPort) { connection = LdapConnectionFactoryEx.getInstance().getLdapConnection(uri.getHost(), isLdaps ? LdapConstants.LDAP_SSL_GC_PORT : LdapConstants.LDAP_GC_PORT, connOptions); } else { connection = LdapConnectionFactoryEx.getInstance().getLdapConnection(uri, connOptions); } try { // All the client options are set, bind now long startTime = System.nanoTime(); if (AuthenticationType.SRP == authType) { ValidateUtil.validateNotEmpty(userName, "userName"); ValidateUtil.validateNotEmpty(password, "password"); ((ILdapConnectionExWithGetConnectionString) connection).bindSaslSrpConnection(userName, password); } else if (AuthenticationType.USE_KERBEROS == authType) { String userUPN = null; int idxSep = 0; if (!ServerUtils.isNullOrEmpty(userName)) { userUPN = ValidateUtil.normalizeIdsKrbUserName(userName); idxSep = userUPN.indexOf(ValidateUtil.UPN_SEPARATOR); } connection.bindSaslConnection( ServerUtils.isNullOrEmpty(userUPN) ? null : userUPN.substring(0, idxSep), ServerUtils.isNullOrEmpty(userUPN) ? null : userUPN.substring(idxSep + 1), password); } else if (AuthenticationType.PASSWORD == authType) { ValidateUtil.validateNotEmpty(userName, "userName"); ValidateUtil.validateNotEmpty(password, "password"); connection.bindConnection(userName, password, LdapBindMethod.LDAP_BIND_SIMPLE); } else { String errMsg = String.format("Unsupported authenticationType to bind connection: [%s, %s]", uri, userName); logger.warn(errMsg); throw new IllegalStateException(errMsg); } long delta = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime); if (logger.isTraceEnabled()) { logger.trace(String.format("\tbinding connection took [%d] ms", delta)); } if (IdmServer.getPerfDataSinkInstance() != null) { IdmServer.getPerfDataSinkInstance().addMeasurement( new PerfBucketKey(PerfMeasurementPoint.LdapBindConnection, uri.toString()), delta); } } catch (Exception ex) { logger.warn(String.format("cannot bind connection: [%s, %s]", uri, userName)); if (connection != null) { connection.close(); } throw ex; } return connection; }
From source file:com.kixeye.chassis.bootstrap.configuration.ConfigurationBuilder.java
@SuppressWarnings({ "unchecked", "rawtypes" }) private void initApplicationFileConfiguration() { if (applicationPropertiesPath == null) { LOGGER.debug("No client application properties to configure. Skipping..."); applicationFileConfiguration = new ConcurrentMapConfiguration(); return;/* w ww . ja va 2 s. com*/ } this.applicationFileConfiguration = new ConcurrentCompositeConfiguration(); String path = SystemPropertyUtils.resolvePlaceholders(applicationPropertiesPath); LOGGER.debug("Configuring client application properties from path " + applicationPropertiesPath); Map applicationProperties = new Properties(); if (SystemUtils.IS_OS_WINDOWS) { if (path.startsWith("file://")) { if (!path.startsWith("file:///")) { path = path.replaceFirst(Pattern.quote("file://"), "file:///"); } } } try (InputStream is = resourceLoader.getResource(path).getInputStream()) { ((Properties) applicationProperties).load(is); } catch (Exception e) { BootstrapException.resourceLoadingFailed(path, applicationPropertiesPath, e); } Map environmentApplicationProperties = getEnvironmentSpecificProperties(path); if (environmentApplicationProperties != null) { ((ConcurrentCompositeConfiguration) this.applicationFileConfiguration) .addConfiguration(new ConcurrentMapConfiguration(environmentApplicationProperties)); } ((ConcurrentCompositeConfiguration) this.applicationFileConfiguration) .addConfiguration(new ConcurrentMapConfiguration(applicationProperties)); if (applicationFileConfiguration.containsKey(BootstrapConfigKeys.PUBLISH_DEFAULTS_KEY.getPropertyName())) { this.publishDefaults = applicationFileConfiguration .getBoolean(BootstrapConfigKeys.PUBLISH_DEFAULTS_KEY.getPropertyName()); } }
From source file:com.wavemaker.tools.project.LocalStudioFileSystem.java
protected static Resource getDefaultWaveMakerHome() { Resource userHome = null;//from w w w . j av a 2s .c o m if (SystemUtils.IS_OS_WINDOWS) { String userProfileEnvVar = System.getenv("USERPROFILE"); if (StringUtils.hasText(userProfileEnvVar)) { userProfileEnvVar = userProfileEnvVar.endsWith("/") ? userProfileEnvVar : userProfileEnvVar + "/"; userHome = new FileSystemResource(System.getenv("USERPROFILE")); } } if (userHome == null) { String userHomeProp = System.getProperty("user.home"); userHomeProp = userHomeProp.endsWith("/") ? userHomeProp : userHomeProp + "/"; userHome = new FileSystemResource(userHomeProp); } String osVersionStr = System.getProperty("os.version"); if (osVersionStr.contains(".")) { String sub = osVersionStr.substring(osVersionStr.indexOf(".") + 1); if (sub.contains(".")) { osVersionStr = osVersionStr.substring(0, osVersionStr.indexOf('.', osVersionStr.indexOf('.') + 1)); } } try { if (SystemUtils.IS_OS_WINDOWS) { userHome = new FileSystemResource( javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory()); } else if (SystemUtils.IS_OS_MAC) { userHome = userHome.createRelative("Documents/"); } if (!userHome.exists()) { throw new WMRuntimeException(MessageResource.PROJECT_USERHOMEDNE, userHome); } Resource wmHome = userHome.createRelative(WAVEMAKER_HOME); if (!wmHome.exists()) { wmHome.getFile().mkdir(); } return wmHome; } catch (IOException ex) { throw new WMRuntimeException(ex); } }
From source file:com.topsec.tsm.sim.sysconfig.web.SystemConfigController.java
/** * ?//from www . j a va2 s. com * @param backupConfig * @param storeConfig * @return * @throws Exception */ private boolean backupPartitionInStorePartition(Config backupConfig, Config storeConfig) throws Exception { if (backupConfig == null) { return false; } Block block = backupConfig.getBlockbyKey("local"); if (block == null || StringUtil.isBlank(block.getItemValue("path"))) { return false; } String backupPath = block.getItemValue("path"); if (StringUtil.isBlank(backupPath)) { return false; } Block storeBlock = storeConfig.getBlockbyKey("archive_path"); String archivePathList = StringUtil.ifBlank(storeBlock.getItemValue("archive_path_list"), storeBlock.getItemValue("archive_path")); String[] storePathList = StringUtil.split(archivePathList, ";"); String[] storePathPartition = new String[storePathList.length]; String backupPartition; if (SystemUtils.IS_OS_WINDOWS) { backupPartition = backupPath.substring(0, backupPath.indexOf(':')); for (int i = 0; i < storePathList.length; i++) { String storePath = storePathList[i]; storePathPartition[i] = storePath.substring(0, storePath.indexOf(':')).toLowerCase();//?? } if (ArrayUtils.indexOf(storePathPartition, backupPartition.toLowerCase()) > -1) { return true; } } else { Node auditorNode = nodeMgrFacade.getKernelAuditor(false); try { //??? String[] params = new String[storePathList.length + 1]; params[0] = backupPath;//? System.arraycopy(storePathList, 0, params, 1, storePathList.length); String[] pathPartition = (String[]) NodeUtil.dispatchCommand(NodeUtil.getRoute(auditorNode), MessageDefinition.CMD_QUERY_PATH_PARTITION, params, 60 * 1000); backupPartition = pathPartition[0]; System.arraycopy(pathPartition, 1, storePathPartition, 0, storePathPartition.length); if (ArrayUtils.indexOf(storePathPartition, backupPartition) > -1) { return true; } } catch (Exception e) { throw e; } } return false; }
From source file:com.ibm.team.build.internal.hjplugin.tests.BuildConfigurationIT.java
public void testBadFetchLocationWin() throws Exception { if (Config.DEFAULT.isConfigured() && SystemUtils.IS_OS_WINDOWS) { RTCLoginInfo loginInfo = Config.DEFAULT.getLoginInfo(); String testName = getTestName() + System.currentTimeMillis(); String fetchLocation = "invalid/questionmark?/character/is/not/ok"; @SuppressWarnings("unchecked") Map<String, String> setupArtifacts = (Map<String, String>) testingFacade.invoke("testBadFetchLocation", new Class[] { String.class, // serverURL, String.class, // userId, String.class, // password, int.class, // timeout, String.class, // workspaceName, String.class, // componentName, String.class, // hjPath, String.class }, // buildPath loginInfo.getServerUri(), loginInfo.getUserId(), loginInfo.getPassword(), loginInfo.getTimeout(), testName, getTestName(), sandboxDir.getPath(), fetchLocation); // clean up testingFacade.invoke("tearDown", new Class[] { String.class, // serverURL, String.class, // userId, String.class, // password, int.class, // timeout, Map.class }, // setupArtifacts loginInfo.getServerUri(), loginInfo.getUserId(), loginInfo.getPassword(), loginInfo.getTimeout(), setupArtifacts); }//from www . jav a 2 s. c o m }
From source file:com.theoryinpractise.clojure.AbstractClojureCompilerMojo.java
protected void callClojureWith(ExecutionMode executionMode, File[] sourceDirectory, File outputDirectory, List<String> compileClasspathElements, String mainClass, String[] clojureArgs) throws MojoExecutionException { outputDirectory.mkdirs();//from w ww . j a v a 2 s .c o m String classpath = manifestClasspath(sourceDirectory, outputDirectory, compileClasspathElements); final String javaExecutable = getJavaExecutable(); getLog().debug("Java exectuable used: " + javaExecutable); getLog().debug("Clojure manifest classpath: " + classpath); CommandLine cl = null; if (ExecutionMode.INTERACTIVE == executionMode && SystemUtils.IS_OS_WINDOWS && spawnInteractiveConsoleOnWindows) { Scanner sc = new Scanner(windowsConsole); Pattern pattern = Pattern.compile("\"[^\"]*\"|'[^']*'|[\\w'/]+"); cl = new CommandLine(sc.findInLine(pattern)); String param; while ((param = sc.findInLine(pattern)) != null) { cl.addArgument(param); } cl.addArgument(javaExecutable); } else { cl = new CommandLine(javaExecutable); } if (vmargs != null) { cl.addArguments(vmargs, false); } cl.addArgument("-Dclojure.compile.path=" + escapeFilePath(outputDirectory), false); if (warnOnReflection) cl.addArgument("-Dclojure.compile.warn-on-reflection=true"); cl.addArguments(clojureOptions, false); cl.addArgument("-jar"); File jar; if (prependClasses != null && prependClasses.size() > 0) { jar = createJar(classpath, prependClasses.get(0)); cl.addArgument(jar.getAbsolutePath(), false); List<String> allButFirst = prependClasses.subList(1, prependClasses.size()); cl.addArguments(allButFirst.toArray(new String[allButFirst.size()])); cl.addArgument(mainClass); } else { jar = createJar(classpath, mainClass); cl.addArgument(jar.getAbsolutePath(), false); } if (clojureArgs != null) { cl.addArguments(clojureArgs, false); } getLog().debug("Command line: " + cl.toString()); Executor exec = new DefaultExecutor(); Map<String, String> env = new HashMap<String, String>(System.getenv()); // env.put("path", ";"); // env.put("path", System.getProperty("java.home")); ExecuteStreamHandler handler = new PumpStreamHandler(System.out, System.err, System.in); exec.setStreamHandler(handler); exec.setWorkingDirectory(getWorkingDirectory()); ShutdownHookProcessDestroyer destroyer = new ShutdownHookProcessDestroyer(); exec.setProcessDestroyer(destroyer); int status; try { status = exec.execute(cl, env); } catch (ExecuteException e) { status = e.getExitValue(); } catch (IOException e) { status = 1; } if (status != 0) { throw new MojoExecutionException("Clojure failed."); } }
From source file:configuration.Config.java
/** * This set the default configuration properties *///from ww w . j a v a 2 s . c o m public void setDefaultProperties() { //--Ask to set Email and other helpfull //--Path set("Name", "Configuration file (config.dat)"); set("currentPath", currentPath); //== //==Note: //==This databasePath represent the default project filename set("databasePath", currentPath + File.separator + "projects" + File.separator + "New_Untitled.db"); set("propertiesPath", currentPath + File.separator + "data" + File.separator + "properties"); // Reflect armadillo properties path set("classPath", currentPath + File.separator + "build" + File.separator + "classes" + File.separator + "programs"); //Running program class set("editorPath", currentPath + File.separator + "build" + File.separator + "classes" + File.separator + "editors"); //editor class set("dataPath", currentPath + File.separator + "data"); set("ExecutableDir", currentPath + File.separator + "Executable"); set("tmpDir", currentPath + File.separator + "tmp"); set("temporaryDir", currentPath + File.separator + "tmp" + File.separator + "temporary"); set("resultsDir", currentPath + File.separator + "results"); set("testDir", currentPath + File.separator + "test"); set("iconsPath", currentPath + File.separator + "data" + File.separator + "icons"); set("projectsDir", currentPath + File.separator + "projects"); // Projects Directory set("hgncDataPath", dataPath() + File.separator + "hgnc.txt"); //default hgnc database... set("hgncWebDownload", "http://www.genenames.org/cgi-bin/hgnc_downloads.cgi?title=HGNC+output+data&hgnc_dbtag=on&preset=all&status=Approved&status=Entry+Withdrawn&status_opt=2&level=pri&=on&where=&order_by=gd_app_sym_sort&limit=&format=text&submit=submit&.cgifields=&.cgifields=level&.cgifields=chr&.cgifields=status&.cgifields=hgnc_dbtag"); set("log", currentPath + File.separator + "armadillo.log"); //--Try to create the tempDir (temporary file directory) if doesn't exists Util.CreateDir(get("tmpDir")); Util.CreateDir(get("resultsDir")); Util.CreateDir(get("projectsDir")); try { if (Util.FileExists(dataPath("New_Untitled_default.db"))) { Util.copy(dataPath("New_Untitled_default.db"), this.projectsDir() + File.separator + "New_Untitled.db"); } else { log("Unable to find the default project file..."); } } catch (Exception e) { } Util.CreateDir(get("temporaryDir")); //--Version and Other set("authorArmadillo", "Etienne Lord, Mickael Leclercq, Alix Boc, Abdoulaye Banir Diallo, Vladimir Makarenkov"); set("version", "2.0"); set("applicationName", "Armadillo Workflow Platform"); set("webpageArmadillo", "http://adn.bioinfo.uqam.ca/armadillo/"); //--Armadillo default webpage set("webserverArmadillo", "http://trex.uqam.ca/armadillo/"); //--Armadillo webserver set("helpArmadillo", "http://adn.bioinfo.uqam.ca/armadillo/wiki/index.php/Main_Page"); //--Armadillo default help page set("getting_startedArmadillo", dataPath() + File.separator + "Documents" + File.separator + "getting_started.html"); //--Getting started page shown at start up set("splashIconPath", currentPath + File.separator + "data" + File.separator + "splash1.png"); set("smallIconPath", currentPath + File.separator + "data" + File.separator + "armadillo.png"); set("imagePath", currentPath + File.separator + "data" + File.separator + "images"); set("imageNcbiLoading", currentPath + File.separator + "data" + File.separator + "LoadingNcbi.jpg"); set("imageEnsemblLoading", currentPath + File.separator + "data" + File.separator + "LoadingEnsembl.jpg"); set("imageSequenceLoading", currentPath + File.separator + "data" + File.separator + "LoadingSequence.jpg"); //--Editor version and name set("editorApplicationName", "Armadillo Editor"); set("editorVersion", "0.1"); set("editorAuthor", "Etienne Lord, Mickael Leclercq"); set("workflow_w", 2000); //Initial workflow size set("workflow_h", 600); set("font_size_adjuster", 0); //--Increase of decrease workflow font size; set("FirstTime", 1); //--Special (Tree Editor, etc...) set("LoadPhyloWidget", false); //--By default, display the Start page set("DisplayStartPage", true); //--Programs currentPath = new File("").getAbsolutePath(); //Databases used set("HGNCData", currentPath + File.separator + "data" + File.separator + "hgnc.txt"); set("Tooltip", currentPath + File.separator + "data" + File.separator + "tooltips.csv"); //set("iso",currentPath+"//data//iso.txt"); set("EnsemblDb", currentPath + File.separator + "data" + File.separator + "EnsemblDB.tsv"); //Others set("defaultSplashPath", currentPath + File.separator + "data" + File.separator + "splash" + File.separator); set("urlToModelTest", "http://www.hiv.lanl.gov/content/sequence/findmodel/findmodel.html"); set("download_genbank", false); set("debugEditor", false); //--System environment specific options if (SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_MAC) { set("MacOSX", true); set("font_size_adjuster", -1); } else if (SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_UNIX) { set("Linux", true); } else if (SystemUtils.IS_OS_WINDOWS) { set("Windows", true); } Save(); }
From source file:com.vmware.identity.idm.server.LocalOsIdentityProviderTest.java
@BeforeClass public static void testSetup() { ISecurityAccountsLibrary lib = getSamLib(); if (lib != null) { GroupInfo g1 = new GroupInfo(group1Name, group1Description); GroupInfo g2 = new GroupInfo(group2Name, group2Description); _groups = new HashMap<String, GroupInfo>(); _groups.put(g1.getName(), g1);/*ww w . j a va 2 s. c o m*/ _groups.put(g2.getName(), g2); _found_os_groups = new HashMap<String, GroupInfo>(); _found_os_groups.put(g1.getName(), g1); if (SystemUtils.IS_OS_WINDOWS) {// Windows samlib makes g2 a search hit _found_os_groups.put(g2.getName(), g2); } UserInfo u1 = new UserInfo(user1Name, user1FirstName, user1LastName, userPassword, user1Description, false, false); UserInfo u2 = new UserInfo(user2Name, user2FirstName, user2LastName, userPassword, user2Description, false, false); UserInfo u3 = new UserInfo(user3Name, user3FirstName, user3LastName, userPassword, user3Description, true, false); UserInfo u4 = new UserInfo(user4Name, user4FirstName, user4LastName, userPassword, user4Description, false, true); UserInfo u5 = new UserInfo(user5Name, user5FirstName, user5LastName, userPassword, user5Description, true, true); UserInfo u6 = new UserInfo(user6Name, user6FirstName, user6LastName, userPassword, user6Description, false, false); _users = new HashMap<String, UserInfo>(); _users.put(u1.getName(), u1); _users.put(u2.getName(), u2); _users.put(u3.getName(), u3); _users.put(u4.getName(), u4); _users.put(u5.getName(), u5); _users.put(u6.getName(), u6); _found_os_users = new HashMap<String, UserInfo>(); _found_os_users.put(u1.getName(), u1); _found_os_users.put(u3.getName(), u3); _found_os_users.put(u5.getName(), u5); _found_os_users.put(u6.getName(), u6); if (SystemUtils.IS_OS_WINDOWS) {//For Windows, we are getting two additional users due to samlib impl. _found_os_users.put(u2.getName(), u2); _found_os_users.put(u4.getName(), u4); } _groupsToUsers = new HashMap<String, Set<UserInfo>>(); _groupsToUsers.put(g1.getName(), new HashSet<UserInfo>()); _groupsToUsers.put(g2.getName(), new HashSet<UserInfo>()); _groupsToUsers.get(g1.getName()).add(u1); _groupsToUsers.get(g1.getName()).add(u2); _groupsToUsers.get(g1.getName()).add(u3); _groupsToUsers.get(g1.getName()).add(u4); _groupsToUsers.get(g1.getName()).add(u5); _groupsToUsers.get(g2.getName()).add(u1); _groupsToUsers.get(g2.getName()).add(u3); _usersToGroups = new HashMap<String, Set<GroupInfo>>(); _usersToGroups.put(u1.getName(), new HashSet<GroupInfo>()); _usersToGroups.put(u2.getName(), new HashSet<GroupInfo>()); _usersToGroups.put(u3.getName(), new HashSet<GroupInfo>()); _usersToGroups.put(u4.getName(), new HashSet<GroupInfo>()); _usersToGroups.put(u5.getName(), new HashSet<GroupInfo>()); _usersToGroups.put(u6.getName(), new HashSet<GroupInfo>()); _usersToGroups.get(u1.getName()).add(g1); _usersToGroups.get(u1.getName()).add(g2); _usersToGroups.get(u2.getName()).add(g1); _usersToGroups.get(u3.getName()).add(g1); _usersToGroups.get(u3.getName()).add(g2); _usersToGroups.get(u4.getName()).add(g1); _usersToGroups.get(u5.getName()).add(g1); for (UserInfo userInfo : _users.values()) { lib.AddUser(userInfo.getName(), userInfo.getPassword(), userInfo.getFirstName() + " " + userInfo.getLastName(), userInfo.getDescription(), userInfo.isDisabled(), userInfo.isLocked()); } for (GroupInfo groupInfo : _groups.values()) { lib.AddGroup(groupInfo.getName(), groupInfo.getDescription()); } for (Map.Entry<String, Set<UserInfo>> entry : _groupsToUsers.entrySet()) { ArrayList<String> usersList = new ArrayList<String>(); for (UserInfo info : entry.getValue()) { usersList.add(info.getName()); } if (usersList.isEmpty() == false) { lib.AddUsersToGroup(entry.getKey(), usersList); } } // create the localOs provider ProviderFactory factory = new ProviderFactory(); ServerIdentityStoreData storeData = new ServerIdentityStoreData(DomainType.LOCAL_OS_DOMAIN, domainName); storeData.setAuthenticationType(AuthenticationType.PASSWORD); storeData.setProviderType(IdentityStoreType.IDENTITY_STORE_TYPE_LOCAL_OS); storeData.setAlias(domainAlias); Map<String, String> map = new HashMap<String, String>(); map.put("http://rsa.com/schemas/attr-names/2009/01/GroupIdentity", LocalOsIdentityProvider.GROUPS_ATTRIBUTE); map.put("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname", LocalOsIdentityProvider.FIRST_NAME_ATTRIBUTE); map.put("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname", LocalOsIdentityProvider.LAST_NAME_ATTRIBUTE); map.put("http://vmware.com/schemas/attr-names/2011/07/isSolution", LocalOsIdentityProvider.SUBJECT_TYPE_ATTRIBUTE); map.put("http://schemas.xmlsoap.org/claims/UPN", LocalOsIdentityProvider.USER_PRINCIPAL_NAME_ATTRIBUTE); storeData.setAttributeMap(map); try { localOsProvider = factory.buildProvider("vsphere.local", storeData, null); } catch (Exception e) { Assert.fail("Building local provider failed"); } } }
From source file:com.asakusafw.operation.tools.hadoop.fs.CleanTest.java
private File link(String path, File target, int day) throws IOException { Assume.assumeFalse("In Windows, tests with symlink are skipped", SystemUtils.IS_OS_WINDOWS); File link = file(path);//from w w w. j av a 2 s . c o m link.getParentFile().mkdirs(); try { Process process = new ProcessBuilder() .command("ln", "-s", target.getCanonicalPath(), link.getAbsolutePath()) .redirectErrorStream(true).start(); try { int exit = process.waitFor(); Assume.assumeThat(exit, is(0)); } finally { process.destroy(); } } catch (Exception e) { Assume.assumeNoException(e); } touch(path, day); return link; }