@Test public void testWithOsDetected() throws Exception { OperatingSystemDetails returnedOsDetails = new OperatingSystemDetails(); returnedOsDetails.setVersion("ultimate"); returnedOsDetails.setName("b os"); returnedOsDetails.setFamily("fam"); returnedOsDetails.setArchitecture("xYZ"); returnedOsDetails.addCommandOutput("some detector", singletonList("some output")); doReturn(returnedOsDetails).when(operatingSystemDetectorService).detectOs(any(OsDetectorInputs.class)); doReturn(true).when(osDetectorHelperService).foundOperatingSystem(any(OperatingSystemDetails.class)); Map<String, String> actualResult = osDetector.execute(HOST, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""); assertEquals("0", actualResult.get("returnCode")); assertEquals("Successfully detected the operating system.", actualResult.get("returnResult")); assertEquals("fam", actualResult.get("osFamily")); assertEquals("b os", actualResult.get("osName")); assertEquals("xYZ", actualResult.get("osArchitecture")); assertEquals("ultimate", actualResult.get("osVersion")); assertThat(actualResult.get("osCommands"), containsString("some detector detection")); assertThat(actualResult.get("osCommands"), containsString("some output")); assertNull(actualResult.get("exception")); }
@Action(name = "Operating System Detector", outputs = { @Output(RETURN_RESULT), @Output(RETURN_CODE), @Output(OS_FAMILY), @Output(OS_NAME), @Output(OS_ARCHITECTURE), @Output(OS_VERSION), @Output(OS_COMMANDS), @Output(EXCEPTION), }, responses = { @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = ReturnCodes.FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR), } ) public Map<String, String> execute(@Param(value = HOST, required = true) String host, @Param(USERNAME) String username, @Param(PASSWORD) String password, @Param(PORT) String port, @Param(PROXY_HOST) String proxyHost, @Param(PROXY_PORT) String proxyPort, @Param(PROXY_USERNAME) String proxyUsername, @Param(value = PROXY_PASSWORD, encrypted = true) String proxyPassword, @Param(PRIVATE_KEY_FILE) String privateKeyFile, @Param(value = PRIVATE_KEY_DATA, encrypted = true) String privateKeyData, @Param(KNOWN_HOSTS_POLICY) String knownHostsPolicy, @Param(KNOWN_HOSTS_PATH) String knownHostsPath, @Param(ALLOWED_CIPHERS) String allowedCiphers, @Param(value = AGENT_FORWARDING) String agentForwarding, @Param(SSH_TIMEOUT) String sshTimeout, @Param(SSH_CONNECT_TIMEOUT) String sshConnectTimeout, @Param(PROTOCOL) String protocol, @Param(AUTH_TYPE) String authType, @Param(TRUST_ALL_ROOTS) String trustAllRoots, @Param(X509_HOSTNAME_VERIFIER) String x509HostnameVerifier, @Param(TRUST_KEYSTORE) String trustKeystore, @Param(value = TRUST_PASSWORD, encrypted = true) String trustPassword, @Param(KEYSTORE) String keystore, @Param(value = KEYSTORE_PASSWORD, encrypted = true) String keystorePassword, @Param(KERBEROS_CONFIG_FILE) String kerberosConfFile, @Param(KERBEROS_LOGIN_CONFIG_FILE) String kerberosLoginConfFile, @Param(KERBEROS_SKIP_PORT_CHECK) String kerberosSkipPortForLookup, @Param(WINRM_LOCALE) String winrmLocale, @Param(POWERSHELL_OPERATION_TIMEOUT) String powerShellTimeout, @Param(NMAP_PATH) String nmapPath, @Param(NMAP_ARGUMENTS) String nmapArguments, @Param(NMAP_VALIDATOR) String nmapValidator, @Param(NMAP_TIMEOUT) String nmapTimeout) { try { OsDetectorInputs osDetectorInputs = new OsDetectorInputs.Builder() .withHost(host) .withPort(port) .withUsername(username) .withPassword(password) .withSshTimeout(defaultIfEmpty(sshTimeout, DEFAULT_SSH_TIMEOUT)) .withPowerShellTimeout(defaultIfEmpty(powerShellTimeout, DEFAULT_POWER_SHELL_OP_TIMEOUT)) .withNmapTimeout(defaultIfEmpty(nmapTimeout, DEFAULT_NMAP_TIMEOUT)) .withSshConnectTimeout(defaultIfEmpty(sshConnectTimeout, String.valueOf(DEFAULT_CONNECT_TIMEOUT))) .withNmapPath(defaultIfEmpty(nmapPath, DEFAULT_NMAP_PATH)) .withNmapArguments(defaultIfEmpty(nmapArguments, DEFAULT_NMAP_ARGUMENTS)) .withNmapValidator(defaultIfEmpty(nmapValidator, RESTRICTIVE_NMAP_VALIDATOR)) .withPrivateKeyFile(privateKeyFile) .withPrivateKeyData(privateKeyData) .withKnownHostsPolicy(defaultIfEmpty(knownHostsPolicy, KNOWN_HOSTS_STRICT)) .withKnownHostsPath(defaultIfEmpty(knownHostsPath, DEFAULT_KNOWN_HOSTS_PATH.toString())) .withAllowedCiphers(defaultIfEmpty(allowedCiphers, DEFAULT_ALLOWED_CIPHERS)) .withAgentForwarding(defaultIfEmpty(agentForwarding, valueOf(DEFAULT_USE_AGENT_FORWARDING))) .withProtocol(defaultIfEmpty(protocol, InputDefaults.PROTOCOL.getValue())) .withAuthType(defaultIfEmpty(authType, BASIC_AUTH)) .withProxyHost(proxyHost) .withProxyPort(defaultIfEmpty(proxyPort, DEFAULT_PROXY_PORT)) .withProxyUsername(proxyUsername) .withProxyPassword(proxyPassword) .withTrustAllRoots(defaultIfEmpty(trustAllRoots, valueOf(false))) .withX509HostnameVerifier(defaultIfEmpty(x509HostnameVerifier, X_509_HOSTNAME_VERIFIER.getValue())) .withTrustKeystore(trustKeystore) .withTrustPassword(trustPassword) .withKerberosConfFile(kerberosConfFile) .withKerberosLoginConfFile(kerberosLoginConfFile) .withKerberosSkipPortForLookup(kerberosSkipPortForLookup) .withKeystore(keystore) .withKeystorePassword(keystorePassword) .withWinrmLocale(defaultIfEmpty(winrmLocale, InputDefaults.WINRM_LOCALE.getValue())) .build(); OsDetectorHelperService osDetectorHelperService = new OsDetectorHelperService(); NmapOsDetectorService nmapOsDetectorService = new NmapOsDetectorService(osDetectorHelperService); OperatingSystemDetectorService service = new OperatingSystemDetectorService(new SshOsDetectorService(osDetectorHelperService, new ScoreSSHShellCommand()), new PowerShellOsDetectorService(osDetectorHelperService, new WSManRemoteShellService()), nmapOsDetectorService, new LocalOsDetectorService(osDetectorHelperService), osDetectorHelperService); osDetectorHelperService.validateNmapInputs(osDetectorInputs, nmapOsDetectorService); OperatingSystemDetails os = service.detectOs(osDetectorInputs); Map<String, String> returnResult; if (osDetectorHelperService.foundOperatingSystem(os)) { returnResult = getSuccessResultsMap("Successfully detected the operating system."); returnResult.put(OS_FAMILY, os.getFamily()); returnResult.put(OS_NAME, os.getName()); returnResult.put(OS_ARCHITECTURE, os.getArchitecture()); returnResult.put(OS_VERSION, os.getVersion()); } else { returnResult = getFailureResultsMap("Unable to detect the operating system."); } returnResult.put(OS_COMMANDS, osDetectorHelperService.formatOsCommandsOutput(os.getCommandsOutput())); return returnResult; } catch (Exception e) { return getFailureResultsMap(e); } }
OsDetector { @Action(name = "Operating System Detector", outputs = { @Output(RETURN_RESULT), @Output(RETURN_CODE), @Output(OS_FAMILY), @Output(OS_NAME), @Output(OS_ARCHITECTURE), @Output(OS_VERSION), @Output(OS_COMMANDS), @Output(EXCEPTION), }, responses = { @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = ReturnCodes.FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR), } ) public Map<String, String> execute(@Param(value = HOST, required = true) String host, @Param(USERNAME) String username, @Param(PASSWORD) String password, @Param(PORT) String port, @Param(PROXY_HOST) String proxyHost, @Param(PROXY_PORT) String proxyPort, @Param(PROXY_USERNAME) String proxyUsername, @Param(value = PROXY_PASSWORD, encrypted = true) String proxyPassword, @Param(PRIVATE_KEY_FILE) String privateKeyFile, @Param(value = PRIVATE_KEY_DATA, encrypted = true) String privateKeyData, @Param(KNOWN_HOSTS_POLICY) String knownHostsPolicy, @Param(KNOWN_HOSTS_PATH) String knownHostsPath, @Param(ALLOWED_CIPHERS) String allowedCiphers, @Param(value = AGENT_FORWARDING) String agentForwarding, @Param(SSH_TIMEOUT) String sshTimeout, @Param(SSH_CONNECT_TIMEOUT) String sshConnectTimeout, @Param(PROTOCOL) String protocol, @Param(AUTH_TYPE) String authType, @Param(TRUST_ALL_ROOTS) String trustAllRoots, @Param(X509_HOSTNAME_VERIFIER) String x509HostnameVerifier, @Param(TRUST_KEYSTORE) String trustKeystore, @Param(value = TRUST_PASSWORD, encrypted = true) String trustPassword, @Param(KEYSTORE) String keystore, @Param(value = KEYSTORE_PASSWORD, encrypted = true) String keystorePassword, @Param(KERBEROS_CONFIG_FILE) String kerberosConfFile, @Param(KERBEROS_LOGIN_CONFIG_FILE) String kerberosLoginConfFile, @Param(KERBEROS_SKIP_PORT_CHECK) String kerberosSkipPortForLookup, @Param(WINRM_LOCALE) String winrmLocale, @Param(POWERSHELL_OPERATION_TIMEOUT) String powerShellTimeout, @Param(NMAP_PATH) String nmapPath, @Param(NMAP_ARGUMENTS) String nmapArguments, @Param(NMAP_VALIDATOR) String nmapValidator, @Param(NMAP_TIMEOUT) String nmapTimeout) { try { OsDetectorInputs osDetectorInputs = new OsDetectorInputs.Builder() .withHost(host) .withPort(port) .withUsername(username) .withPassword(password) .withSshTimeout(defaultIfEmpty(sshTimeout, DEFAULT_SSH_TIMEOUT)) .withPowerShellTimeout(defaultIfEmpty(powerShellTimeout, DEFAULT_POWER_SHELL_OP_TIMEOUT)) .withNmapTimeout(defaultIfEmpty(nmapTimeout, DEFAULT_NMAP_TIMEOUT)) .withSshConnectTimeout(defaultIfEmpty(sshConnectTimeout, String.valueOf(DEFAULT_CONNECT_TIMEOUT))) .withNmapPath(defaultIfEmpty(nmapPath, DEFAULT_NMAP_PATH)) .withNmapArguments(defaultIfEmpty(nmapArguments, DEFAULT_NMAP_ARGUMENTS)) .withNmapValidator(defaultIfEmpty(nmapValidator, RESTRICTIVE_NMAP_VALIDATOR)) .withPrivateKeyFile(privateKeyFile) .withPrivateKeyData(privateKeyData) .withKnownHostsPolicy(defaultIfEmpty(knownHostsPolicy, KNOWN_HOSTS_STRICT)) .withKnownHostsPath(defaultIfEmpty(knownHostsPath, DEFAULT_KNOWN_HOSTS_PATH.toString())) .withAllowedCiphers(defaultIfEmpty(allowedCiphers, DEFAULT_ALLOWED_CIPHERS)) .withAgentForwarding(defaultIfEmpty(agentForwarding, valueOf(DEFAULT_USE_AGENT_FORWARDING))) .withProtocol(defaultIfEmpty(protocol, InputDefaults.PROTOCOL.getValue())) .withAuthType(defaultIfEmpty(authType, BASIC_AUTH)) .withProxyHost(proxyHost) .withProxyPort(defaultIfEmpty(proxyPort, DEFAULT_PROXY_PORT)) .withProxyUsername(proxyUsername) .withProxyPassword(proxyPassword) .withTrustAllRoots(defaultIfEmpty(trustAllRoots, valueOf(false))) .withX509HostnameVerifier(defaultIfEmpty(x509HostnameVerifier, X_509_HOSTNAME_VERIFIER.getValue())) .withTrustKeystore(trustKeystore) .withTrustPassword(trustPassword) .withKerberosConfFile(kerberosConfFile) .withKerberosLoginConfFile(kerberosLoginConfFile) .withKerberosSkipPortForLookup(kerberosSkipPortForLookup) .withKeystore(keystore) .withKeystorePassword(keystorePassword) .withWinrmLocale(defaultIfEmpty(winrmLocale, InputDefaults.WINRM_LOCALE.getValue())) .build(); OsDetectorHelperService osDetectorHelperService = new OsDetectorHelperService(); NmapOsDetectorService nmapOsDetectorService = new NmapOsDetectorService(osDetectorHelperService); OperatingSystemDetectorService service = new OperatingSystemDetectorService(new SshOsDetectorService(osDetectorHelperService, new ScoreSSHShellCommand()), new PowerShellOsDetectorService(osDetectorHelperService, new WSManRemoteShellService()), nmapOsDetectorService, new LocalOsDetectorService(osDetectorHelperService), osDetectorHelperService); osDetectorHelperService.validateNmapInputs(osDetectorInputs, nmapOsDetectorService); OperatingSystemDetails os = service.detectOs(osDetectorInputs); Map<String, String> returnResult; if (osDetectorHelperService.foundOperatingSystem(os)) { returnResult = getSuccessResultsMap("Successfully detected the operating system."); returnResult.put(OS_FAMILY, os.getFamily()); returnResult.put(OS_NAME, os.getName()); returnResult.put(OS_ARCHITECTURE, os.getArchitecture()); returnResult.put(OS_VERSION, os.getVersion()); } else { returnResult = getFailureResultsMap("Unable to detect the operating system."); } returnResult.put(OS_COMMANDS, osDetectorHelperService.formatOsCommandsOutput(os.getCommandsOutput())); return returnResult; } catch (Exception e) { return getFailureResultsMap(e); } } }
OsDetector { @Action(name = "Operating System Detector", outputs = { @Output(RETURN_RESULT), @Output(RETURN_CODE), @Output(OS_FAMILY), @Output(OS_NAME), @Output(OS_ARCHITECTURE), @Output(OS_VERSION), @Output(OS_COMMANDS), @Output(EXCEPTION), }, responses = { @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = ReturnCodes.FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR), } ) public Map<String, String> execute(@Param(value = HOST, required = true) String host, @Param(USERNAME) String username, @Param(PASSWORD) String password, @Param(PORT) String port, @Param(PROXY_HOST) String proxyHost, @Param(PROXY_PORT) String proxyPort, @Param(PROXY_USERNAME) String proxyUsername, @Param(value = PROXY_PASSWORD, encrypted = true) String proxyPassword, @Param(PRIVATE_KEY_FILE) String privateKeyFile, @Param(value = PRIVATE_KEY_DATA, encrypted = true) String privateKeyData, @Param(KNOWN_HOSTS_POLICY) String knownHostsPolicy, @Param(KNOWN_HOSTS_PATH) String knownHostsPath, @Param(ALLOWED_CIPHERS) String allowedCiphers, @Param(value = AGENT_FORWARDING) String agentForwarding, @Param(SSH_TIMEOUT) String sshTimeout, @Param(SSH_CONNECT_TIMEOUT) String sshConnectTimeout, @Param(PROTOCOL) String protocol, @Param(AUTH_TYPE) String authType, @Param(TRUST_ALL_ROOTS) String trustAllRoots, @Param(X509_HOSTNAME_VERIFIER) String x509HostnameVerifier, @Param(TRUST_KEYSTORE) String trustKeystore, @Param(value = TRUST_PASSWORD, encrypted = true) String trustPassword, @Param(KEYSTORE) String keystore, @Param(value = KEYSTORE_PASSWORD, encrypted = true) String keystorePassword, @Param(KERBEROS_CONFIG_FILE) String kerberosConfFile, @Param(KERBEROS_LOGIN_CONFIG_FILE) String kerberosLoginConfFile, @Param(KERBEROS_SKIP_PORT_CHECK) String kerberosSkipPortForLookup, @Param(WINRM_LOCALE) String winrmLocale, @Param(POWERSHELL_OPERATION_TIMEOUT) String powerShellTimeout, @Param(NMAP_PATH) String nmapPath, @Param(NMAP_ARGUMENTS) String nmapArguments, @Param(NMAP_VALIDATOR) String nmapValidator, @Param(NMAP_TIMEOUT) String nmapTimeout) { try { OsDetectorInputs osDetectorInputs = new OsDetectorInputs.Builder() .withHost(host) .withPort(port) .withUsername(username) .withPassword(password) .withSshTimeout(defaultIfEmpty(sshTimeout, DEFAULT_SSH_TIMEOUT)) .withPowerShellTimeout(defaultIfEmpty(powerShellTimeout, DEFAULT_POWER_SHELL_OP_TIMEOUT)) .withNmapTimeout(defaultIfEmpty(nmapTimeout, DEFAULT_NMAP_TIMEOUT)) .withSshConnectTimeout(defaultIfEmpty(sshConnectTimeout, String.valueOf(DEFAULT_CONNECT_TIMEOUT))) .withNmapPath(defaultIfEmpty(nmapPath, DEFAULT_NMAP_PATH)) .withNmapArguments(defaultIfEmpty(nmapArguments, DEFAULT_NMAP_ARGUMENTS)) .withNmapValidator(defaultIfEmpty(nmapValidator, RESTRICTIVE_NMAP_VALIDATOR)) .withPrivateKeyFile(privateKeyFile) .withPrivateKeyData(privateKeyData) .withKnownHostsPolicy(defaultIfEmpty(knownHostsPolicy, KNOWN_HOSTS_STRICT)) .withKnownHostsPath(defaultIfEmpty(knownHostsPath, DEFAULT_KNOWN_HOSTS_PATH.toString())) .withAllowedCiphers(defaultIfEmpty(allowedCiphers, DEFAULT_ALLOWED_CIPHERS)) .withAgentForwarding(defaultIfEmpty(agentForwarding, valueOf(DEFAULT_USE_AGENT_FORWARDING))) .withProtocol(defaultIfEmpty(protocol, InputDefaults.PROTOCOL.getValue())) .withAuthType(defaultIfEmpty(authType, BASIC_AUTH)) .withProxyHost(proxyHost) .withProxyPort(defaultIfEmpty(proxyPort, DEFAULT_PROXY_PORT)) .withProxyUsername(proxyUsername) .withProxyPassword(proxyPassword) .withTrustAllRoots(defaultIfEmpty(trustAllRoots, valueOf(false))) .withX509HostnameVerifier(defaultIfEmpty(x509HostnameVerifier, X_509_HOSTNAME_VERIFIER.getValue())) .withTrustKeystore(trustKeystore) .withTrustPassword(trustPassword) .withKerberosConfFile(kerberosConfFile) .withKerberosLoginConfFile(kerberosLoginConfFile) .withKerberosSkipPortForLookup(kerberosSkipPortForLookup) .withKeystore(keystore) .withKeystorePassword(keystorePassword) .withWinrmLocale(defaultIfEmpty(winrmLocale, InputDefaults.WINRM_LOCALE.getValue())) .build(); OsDetectorHelperService osDetectorHelperService = new OsDetectorHelperService(); NmapOsDetectorService nmapOsDetectorService = new NmapOsDetectorService(osDetectorHelperService); OperatingSystemDetectorService service = new OperatingSystemDetectorService(new SshOsDetectorService(osDetectorHelperService, new ScoreSSHShellCommand()), new PowerShellOsDetectorService(osDetectorHelperService, new WSManRemoteShellService()), nmapOsDetectorService, new LocalOsDetectorService(osDetectorHelperService), osDetectorHelperService); osDetectorHelperService.validateNmapInputs(osDetectorInputs, nmapOsDetectorService); OperatingSystemDetails os = service.detectOs(osDetectorInputs); Map<String, String> returnResult; if (osDetectorHelperService.foundOperatingSystem(os)) { returnResult = getSuccessResultsMap("Successfully detected the operating system."); returnResult.put(OS_FAMILY, os.getFamily()); returnResult.put(OS_NAME, os.getName()); returnResult.put(OS_ARCHITECTURE, os.getArchitecture()); returnResult.put(OS_VERSION, os.getVersion()); } else { returnResult = getFailureResultsMap("Unable to detect the operating system."); } returnResult.put(OS_COMMANDS, osDetectorHelperService.formatOsCommandsOutput(os.getCommandsOutput())); return returnResult; } catch (Exception e) { return getFailureResultsMap(e); } }  }
OsDetector { @Action(name = "Operating System Detector", outputs = { @Output(RETURN_RESULT), @Output(RETURN_CODE), @Output(OS_FAMILY), @Output(OS_NAME), @Output(OS_ARCHITECTURE), @Output(OS_VERSION), @Output(OS_COMMANDS), @Output(EXCEPTION), }, responses = { @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = ReturnCodes.FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR), } ) public Map<String, String> execute(@Param(value = HOST, required = true) String host, @Param(USERNAME) String username, @Param(PASSWORD) String password, @Param(PORT) String port, @Param(PROXY_HOST) String proxyHost, @Param(PROXY_PORT) String proxyPort, @Param(PROXY_USERNAME) String proxyUsername, @Param(value = PROXY_PASSWORD, encrypted = true) String proxyPassword, @Param(PRIVATE_KEY_FILE) String privateKeyFile, @Param(value = PRIVATE_KEY_DATA, encrypted = true) String privateKeyData, @Param(KNOWN_HOSTS_POLICY) String knownHostsPolicy, @Param(KNOWN_HOSTS_PATH) String knownHostsPath, @Param(ALLOWED_CIPHERS) String allowedCiphers, @Param(value = AGENT_FORWARDING) String agentForwarding, @Param(SSH_TIMEOUT) String sshTimeout, @Param(SSH_CONNECT_TIMEOUT) String sshConnectTimeout, @Param(PROTOCOL) String protocol, @Param(AUTH_TYPE) String authType, @Param(TRUST_ALL_ROOTS) String trustAllRoots, @Param(X509_HOSTNAME_VERIFIER) String x509HostnameVerifier, @Param(TRUST_KEYSTORE) String trustKeystore, @Param(value = TRUST_PASSWORD, encrypted = true) String trustPassword, @Param(KEYSTORE) String keystore, @Param(value = KEYSTORE_PASSWORD, encrypted = true) String keystorePassword, @Param(KERBEROS_CONFIG_FILE) String kerberosConfFile, @Param(KERBEROS_LOGIN_CONFIG_FILE) String kerberosLoginConfFile, @Param(KERBEROS_SKIP_PORT_CHECK) String kerberosSkipPortForLookup, @Param(WINRM_LOCALE) String winrmLocale, @Param(POWERSHELL_OPERATION_TIMEOUT) String powerShellTimeout, @Param(NMAP_PATH) String nmapPath, @Param(NMAP_ARGUMENTS) String nmapArguments, @Param(NMAP_VALIDATOR) String nmapValidator, @Param(NMAP_TIMEOUT) String nmapTimeout) { try { OsDetectorInputs osDetectorInputs = new OsDetectorInputs.Builder() .withHost(host) .withPort(port) .withUsername(username) .withPassword(password) .withSshTimeout(defaultIfEmpty(sshTimeout, DEFAULT_SSH_TIMEOUT)) .withPowerShellTimeout(defaultIfEmpty(powerShellTimeout, DEFAULT_POWER_SHELL_OP_TIMEOUT)) .withNmapTimeout(defaultIfEmpty(nmapTimeout, DEFAULT_NMAP_TIMEOUT)) .withSshConnectTimeout(defaultIfEmpty(sshConnectTimeout, String.valueOf(DEFAULT_CONNECT_TIMEOUT))) .withNmapPath(defaultIfEmpty(nmapPath, DEFAULT_NMAP_PATH)) .withNmapArguments(defaultIfEmpty(nmapArguments, DEFAULT_NMAP_ARGUMENTS)) .withNmapValidator(defaultIfEmpty(nmapValidator, RESTRICTIVE_NMAP_VALIDATOR)) .withPrivateKeyFile(privateKeyFile) .withPrivateKeyData(privateKeyData) .withKnownHostsPolicy(defaultIfEmpty(knownHostsPolicy, KNOWN_HOSTS_STRICT)) .withKnownHostsPath(defaultIfEmpty(knownHostsPath, DEFAULT_KNOWN_HOSTS_PATH.toString())) .withAllowedCiphers(defaultIfEmpty(allowedCiphers, DEFAULT_ALLOWED_CIPHERS)) .withAgentForwarding(defaultIfEmpty(agentForwarding, valueOf(DEFAULT_USE_AGENT_FORWARDING))) .withProtocol(defaultIfEmpty(protocol, InputDefaults.PROTOCOL.getValue())) .withAuthType(defaultIfEmpty(authType, BASIC_AUTH)) .withProxyHost(proxyHost) .withProxyPort(defaultIfEmpty(proxyPort, DEFAULT_PROXY_PORT)) .withProxyUsername(proxyUsername) .withProxyPassword(proxyPassword) .withTrustAllRoots(defaultIfEmpty(trustAllRoots, valueOf(false))) .withX509HostnameVerifier(defaultIfEmpty(x509HostnameVerifier, X_509_HOSTNAME_VERIFIER.getValue())) .withTrustKeystore(trustKeystore) .withTrustPassword(trustPassword) .withKerberosConfFile(kerberosConfFile) .withKerberosLoginConfFile(kerberosLoginConfFile) .withKerberosSkipPortForLookup(kerberosSkipPortForLookup) .withKeystore(keystore) .withKeystorePassword(keystorePassword) .withWinrmLocale(defaultIfEmpty(winrmLocale, InputDefaults.WINRM_LOCALE.getValue())) .build(); OsDetectorHelperService osDetectorHelperService = new OsDetectorHelperService(); NmapOsDetectorService nmapOsDetectorService = new NmapOsDetectorService(osDetectorHelperService); OperatingSystemDetectorService service = new OperatingSystemDetectorService(new SshOsDetectorService(osDetectorHelperService, new ScoreSSHShellCommand()), new PowerShellOsDetectorService(osDetectorHelperService, new WSManRemoteShellService()), nmapOsDetectorService, new LocalOsDetectorService(osDetectorHelperService), osDetectorHelperService); osDetectorHelperService.validateNmapInputs(osDetectorInputs, nmapOsDetectorService); OperatingSystemDetails os = service.detectOs(osDetectorInputs); Map<String, String> returnResult; if (osDetectorHelperService.foundOperatingSystem(os)) { returnResult = getSuccessResultsMap("Successfully detected the operating system."); returnResult.put(OS_FAMILY, os.getFamily()); returnResult.put(OS_NAME, os.getName()); returnResult.put(OS_ARCHITECTURE, os.getArchitecture()); returnResult.put(OS_VERSION, os.getVersion()); } else { returnResult = getFailureResultsMap("Unable to detect the operating system."); } returnResult.put(OS_COMMANDS, osDetectorHelperService.formatOsCommandsOutput(os.getCommandsOutput())); return returnResult; } catch (Exception e) { return getFailureResultsMap(e); } }  @Action(name = "Operating System Detector", outputs = { @Output(RETURN_RESULT), @Output(RETURN_CODE), @Output(OS_FAMILY), @Output(OS_NAME), @Output(OS_ARCHITECTURE), @Output(OS_VERSION), @Output(OS_COMMANDS), @Output(EXCEPTION), }, responses = { @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = ReturnCodes.FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR), } ) Map<String, String> execute(@Param(value = HOST, required = true) String host,

                                       @Param(USERNAME) String username,
                                       @Param(PASSWORD) String password,
                                       @Param(PORT) String port,

                                       @Param(PROXY_HOST) String proxyHost,
                                       @Param(PROXY_PORT) String proxyPort,
                                       @Param(PROXY_USERNAME) String proxyUsername,
                                       @Param(value = PROXY_PASSWORD, encrypted = true) String proxyPassword,

                                       @Param(PRIVATE_KEY_FILE) String privateKeyFile,
                                       @Param(value = PRIVATE_KEY_DATA, encrypted = true) String privateKeyData,
                                       @Param(KNOWN_HOSTS_POLICY) String knownHostsPolicy,
                                       @Param(KNOWN_HOSTS_PATH) String knownHostsPath,
                                       @Param(ALLOWED_CIPHERS) String allowedCiphers,
                                       @Param(value = AGENT_FORWARDING) String agentForwarding,
                                       @Param(SSH_TIMEOUT) String sshTimeout,
                                       @Param(SSH_CONNECT_TIMEOUT) String sshConnectTimeout,

                                       @Param(PROTOCOL) String protocol,
                                       @Param(AUTH_TYPE) String authType,
                                       @Param(TRUST_ALL_ROOTS) String trustAllRoots,
                                       @Param(X509_HOSTNAME_VERIFIER) String x509HostnameVerifier,
                                       @Param(TRUST_KEYSTORE) String trustKeystore,
                                       @Param(value = TRUST_PASSWORD, encrypted = true) String trustPassword,
                                       @Param(KEYSTORE) String keystore,
                                       @Param(value = KEYSTORE_PASSWORD, encrypted = true) String keystorePassword,
                                       @Param(KERBEROS_CONFIG_FILE) String kerberosConfFile,
                                       @Param(KERBEROS_LOGIN_CONFIG_FILE) String kerberosLoginConfFile,
                                       @Param(KERBEROS_SKIP_PORT_CHECK) String kerberosSkipPortForLookup,
                                       @Param(WINRM_LOCALE) String winrmLocale,
                                       @Param(POWERSHELL_OPERATION_TIMEOUT) String powerShellTimeout,

                                       @Param(NMAP_PATH) String nmapPath,
                                       @Param(NMAP_ARGUMENTS) String nmapArguments,
                                       @Param(NMAP_VALIDATOR) String nmapValidator,
                                       @Param(NMAP_TIMEOUT) String nmapTimeout); }
OsDetector { @Action(name = "Operating System Detector", outputs = { @Output(RETURN_RESULT), @Output(RETURN_CODE), @Output(OS_FAMILY), @Output(OS_NAME), @Output(OS_ARCHITECTURE), @Output(OS_VERSION), @Output(OS_COMMANDS), @Output(EXCEPTION), }, responses = { @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = ReturnCodes.FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR), } ) public Map<String, String> execute(@Param(value = HOST, required = true) String host, @Param(USERNAME) String username, @Param(PASSWORD) String password, @Param(PORT) String port, @Param(PROXY_HOST) String proxyHost, @Param(PROXY_PORT) String proxyPort, @Param(PROXY_USERNAME) String proxyUsername, @Param(value = PROXY_PASSWORD, encrypted = true) String proxyPassword, @Param(PRIVATE_KEY_FILE) String privateKeyFile, @Param(value = PRIVATE_KEY_DATA, encrypted = true) String privateKeyData, @Param(KNOWN_HOSTS_POLICY) String knownHostsPolicy, @Param(KNOWN_HOSTS_PATH) String knownHostsPath, @Param(ALLOWED_CIPHERS) String allowedCiphers, @Param(value = AGENT_FORWARDING) String agentForwarding, @Param(SSH_TIMEOUT) String sshTimeout, @Param(SSH_CONNECT_TIMEOUT) String sshConnectTimeout, @Param(PROTOCOL) String protocol, @Param(AUTH_TYPE) String authType, @Param(TRUST_ALL_ROOTS) String trustAllRoots, @Param(X509_HOSTNAME_VERIFIER) String x509HostnameVerifier, @Param(TRUST_KEYSTORE) String trustKeystore, @Param(value = TRUST_PASSWORD, encrypted = true) String trustPassword, @Param(KEYSTORE) String keystore, @Param(value = KEYSTORE_PASSWORD, encrypted = true) String keystorePassword, @Param(KERBEROS_CONFIG_FILE) String kerberosConfFile, @Param(KERBEROS_LOGIN_CONFIG_FILE) String kerberosLoginConfFile, @Param(KERBEROS_SKIP_PORT_CHECK) String kerberosSkipPortForLookup, @Param(WINRM_LOCALE) String winrmLocale, @Param(POWERSHELL_OPERATION_TIMEOUT) String powerShellTimeout, @Param(NMAP_PATH) String nmapPath, @Param(NMAP_ARGUMENTS) String nmapArguments, @Param(NMAP_VALIDATOR) String nmapValidator, @Param(NMAP_TIMEOUT) String nmapTimeout) { try { OsDetectorInputs osDetectorInputs = new OsDetectorInputs.Builder() .withHost(host) .withPort(port) .withUsername(username) .withPassword(password) .withSshTimeout(defaultIfEmpty(sshTimeout, DEFAULT_SSH_TIMEOUT)) .withPowerShellTimeout(defaultIfEmpty(powerShellTimeout, DEFAULT_POWER_SHELL_OP_TIMEOUT)) .withNmapTimeout(defaultIfEmpty(nmapTimeout, DEFAULT_NMAP_TIMEOUT)) .withSshConnectTimeout(defaultIfEmpty(sshConnectTimeout, String.valueOf(DEFAULT_CONNECT_TIMEOUT))) .withNmapPath(defaultIfEmpty(nmapPath, DEFAULT_NMAP_PATH)) .withNmapArguments(defaultIfEmpty(nmapArguments, DEFAULT_NMAP_ARGUMENTS)) .withNmapValidator(defaultIfEmpty(nmapValidator, RESTRICTIVE_NMAP_VALIDATOR)) .withPrivateKeyFile(privateKeyFile) .withPrivateKeyData(privateKeyData) .withKnownHostsPolicy(defaultIfEmpty(knownHostsPolicy, KNOWN_HOSTS_STRICT)) .withKnownHostsPath(defaultIfEmpty(knownHostsPath, DEFAULT_KNOWN_HOSTS_PATH.toString())) .withAllowedCiphers(defaultIfEmpty(allowedCiphers, DEFAULT_ALLOWED_CIPHERS)) .withAgentForwarding(defaultIfEmpty(agentForwarding, valueOf(DEFAULT_USE_AGENT_FORWARDING))) .withProtocol(defaultIfEmpty(protocol, InputDefaults.PROTOCOL.getValue())) .withAuthType(defaultIfEmpty(authType, BASIC_AUTH)) .withProxyHost(proxyHost) .withProxyPort(defaultIfEmpty(proxyPort, DEFAULT_PROXY_PORT)) .withProxyUsername(proxyUsername) .withProxyPassword(proxyPassword) .withTrustAllRoots(defaultIfEmpty(trustAllRoots, valueOf(false))) .withX509HostnameVerifier(defaultIfEmpty(x509HostnameVerifier, X_509_HOSTNAME_VERIFIER.getValue())) .withTrustKeystore(trustKeystore) .withTrustPassword(trustPassword) .withKerberosConfFile(kerberosConfFile) .withKerberosLoginConfFile(kerberosLoginConfFile) .withKerberosSkipPortForLookup(kerberosSkipPortForLookup) .withKeystore(keystore) .withKeystorePassword(keystorePassword) .withWinrmLocale(defaultIfEmpty(winrmLocale, InputDefaults.WINRM_LOCALE.getValue())) .build(); OsDetectorHelperService osDetectorHelperService = new OsDetectorHelperService(); NmapOsDetectorService nmapOsDetectorService = new NmapOsDetectorService(osDetectorHelperService); OperatingSystemDetectorService service = new OperatingSystemDetectorService(new SshOsDetectorService(osDetectorHelperService, new ScoreSSHShellCommand()), new PowerShellOsDetectorService(osDetectorHelperService, new WSManRemoteShellService()), nmapOsDetectorService, new LocalOsDetectorService(osDetectorHelperService), osDetectorHelperService); osDetectorHelperService.validateNmapInputs(osDetectorInputs, nmapOsDetectorService); OperatingSystemDetails os = service.detectOs(osDetectorInputs); Map<String, String> returnResult; if (osDetectorHelperService.foundOperatingSystem(os)) { returnResult = getSuccessResultsMap("Successfully detected the operating system."); returnResult.put(OS_FAMILY, os.getFamily()); returnResult.put(OS_NAME, os.getName()); returnResult.put(OS_ARCHITECTURE, os.getArchitecture()); returnResult.put(OS_VERSION, os.getVersion()); } else { returnResult = getFailureResultsMap("Unable to detect the operating system."); } returnResult.put(OS_COMMANDS, osDetectorHelperService.formatOsCommandsOutput(os.getCommandsOutput())); return returnResult; } catch (Exception e) { return getFailureResultsMap(e); } }  @Action(name = "Operating System Detector", outputs = { @Output(RETURN_RESULT), @Output(RETURN_CODE), @Output(OS_FAMILY), @Output(OS_NAME), @Output(OS_ARCHITECTURE), @Output(OS_VERSION), @Output(OS_COMMANDS), @Output(EXCEPTION), }, responses = { @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = ReturnCodes.FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR), } ) Map<String, String> execute(@Param(value = HOST, required = true) String host,

                                       @Param(USERNAME) String username,
                                       @Param(PASSWORD) String password,
                                       @Param(PORT) String port,

                                       @Param(PROXY_HOST) String proxyHost,
                                       @Param(PROXY_PORT) String proxyPort,
                                       @Param(PROXY_USERNAME) String proxyUsername,
                                       @Param(value = PROXY_PASSWORD, encrypted = true) String proxyPassword,

                                       @Param(PRIVATE_KEY_FILE) String privateKeyFile,
                                       @Param(value = PRIVATE_KEY_DATA, encrypted = true) String privateKeyData,
                                       @Param(KNOWN_HOSTS_POLICY) String knownHostsPolicy,
                                       @Param(KNOWN_HOSTS_PATH) String knownHostsPath,
                                       @Param(ALLOWED_CIPHERS) String allowedCiphers,
                                       @Param(value = AGENT_FORWARDING) String agentForwarding,
                                       @Param(SSH_TIMEOUT) String sshTimeout,
                                       @Param(SSH_CONNECT_TIMEOUT) String sshConnectTimeout,

                                       @Param(PROTOCOL) String protocol,
                                       @Param(AUTH_TYPE) String authType,
                                       @Param(TRUST_ALL_ROOTS) String trustAllRoots,
                                       @Param(X509_HOSTNAME_VERIFIER) String x509HostnameVerifier,
                                       @Param(TRUST_KEYSTORE) String trustKeystore,
                                       @Param(value = TRUST_PASSWORD, encrypted = true) String trustPassword,
                                       @Param(KEYSTORE) String keystore,
                                       @Param(value = KEYSTORE_PASSWORD, encrypted = true) String keystorePassword,
                                       @Param(KERBEROS_CONFIG_FILE) String kerberosConfFile,
                                       @Param(KERBEROS_LOGIN_CONFIG_FILE) String kerberosLoginConfFile,
                                       @Param(KERBEROS_SKIP_PORT_CHECK) String kerberosSkipPortForLookup,
                                       @Param(WINRM_LOCALE) String winrmLocale,
                                       @Param(POWERSHELL_OPERATION_TIMEOUT) String powerShellTimeout,

                                       @Param(NMAP_PATH) String nmapPath,
                                       @Param(NMAP_ARGUMENTS) String nmapArguments,
                                       @Param(NMAP_VALIDATOR) String nmapValidator,
                                       @Param(NMAP_TIMEOUT) String nmapTimeout);  }