Search in sources :

Example 91 with Action

use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.

the class CreateComputerAccountAction method execute.

/**
 * Creates a new computer account in Active Directory.
 *
 * @param host                 The domain controller to connect to.
 * @param distinguishedName    The Organizational Unit DN or Common Name DN to add the computer to.
 *                             (i.e. OU=OUTest1,DC=battleground,DC=ad).
 * @param computerCommonName   The name of the computer (its CN).
 * @param sAMAccountName       Computer's sAMAccountName (ex. MYHYPNOS$). If not provided it will be assigned
 *                             from computerCommonName. It can't contain any of the following characters: '"','\','/',
 *                             '[',']',':',';','|','=',',','+','*','?','<','>'.
 * @param username             The user to connect to Active Directory as.
 * @param password             The password of the user to connect to Active Directory.
 * @param protocol             The protocol to use when connecting to the Active Directory server.
 *                             Valid values: HTTP and HTTPS.
 * @param proxyHost            The proxy server used to access the web site.
 * @param proxyPort            The proxy server port.
 *                             Default value: 8080.
 * @param proxyUsername        The username used when connecting to the proxy.
 * @param proxyPassword        The proxy server password associated with the "proxyUsername" input value.
 * @param tlsVersion           The version of TLS to use. The value of this input will be ignored if "protocol"
 *                             is set to "HTTP". This capability is provided “as is”, please see product documentation
 *                             for further information.
 *                             Valid values: TLSv1, TLSv1.1, TLSv1.2.
 *                             Default value: TLSv1.2.
 * @param allowedCiphers         A list of ciphers to use. The value of this input will be ignored if 'tlsVersion' does
 *                             not contain 'TLSv1.2'. This capability is provided “as is”, please see product documentation
 *                             for further security considerations. In order to connect successfully to the target host,
 *                             it should accept at least one of the following ciphers. If this is not the case, it is
 *                             the user's responsibility to configure the host accordingly or to update the list of
 *                             allowed ciphers. This capability is provided “as is”, please see product documentation
 *                             for further security considerations. In order to connect successfully to the target host,
 *                             it should accept at least one of the following ciphers. If this is not the case, it is
 *                             the user's responsibility to configure the host accordingly or to update the list of
 *                             allowed ciphers.
 *                             Default value: TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,
 *                             TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
 *                             TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,
 *                             TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
 *                             TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
 *                             TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
 *                             TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256,
 *                             TLS_RSA_WITH_AES_128_CBC_SHA256.
 * @param trustAllRoots        Specifies whether to enable weak security over SSL. A SSL certificate is trusted
 *                             even if no trusted certification authority issued it.
 *                             Valid values: true, false.
 *                             Default value: false.
 * @param x509HostnameVerifier Specifies the way the server hostname must match a domain name in the subject's Common
 *                             Name (CN) or subjectAltName field of the X.509 certificate. Set this to "allow_all" to
 *                             skip any checking, but you become vulnerable to attacks.
 *                             For the value "browser_compatible" the hostname verifier works the same way as Curl
 *                             and Firefox. The hostname must match either the first CN, or any of the subject-alts.
 *                             A wildcard can occur in the CN, and in any of the subject-alts. The only difference
 *                             between "browser_compatible" and "strict" is that a wildcard (such as "*.foo.com")
 *                             with "browser_compatible" matches all subdomains, including "a.b.foo.com". From the
 *                             security perspective, to provide protection against possible Man-In-The-Middle attacks,
 *                             we strongly recommend to use "strict" option.
 *                             Default value: strict.
 *                             Valid values: strict, browser_compatible, allow_all.
 * @param trustKeystore        The location of the TrustStore file.
 *                             Example: %JAVA_HOME%/jre/lib/security/cacerts.
 * @param trustPassword        The password associated with the TrustStore file.
 * @param escapeChars          Specifies whether to escape the special Active Directory characters:
 *                             '#','=','"','<','>',',','+',';','\','"''.
 *                             Default value: false.
 *                             Valid values: true, false.
 * @param timeout              Time in seconds to wait for the command to complete.
 *                             Default value: 60.
 * @return a map containing the output of the operations. Keys present in the map are:
 * returnResult - The return result of the operation.
 * returnCode - The return code of the operation. 0 if the operation succeeded, -1 if the operation fails.
 * exception - The exception message if the operation fails.
 * computerDN - The distinguished name of the newly created computer account.
 */
@Action(name = "Create Computer Account", description = CREATE_COMPUTER_ACCOUNT_DESC, outputs = { @Output(value = OutputNames.RETURN_RESULT, description = RETURN_RESULT_DESC), @Output(value = OutputNames.RESULT_COMPUTER_DN, description = RESULT_COMPUTER_DN_DESC), @Output(value = OutputNames.RETURN_CODE, description = RETURN_CODE_DESC), @Output(value = OutputNames.EXCEPTION, description = EXCEPTION_DESC) }, responses = { @Response(text = ResponseNames.SUCCESS, field = OutputNames.RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED, description = SUCCESS_DESC), @Response(text = ResponseNames.FAILURE, field = OutputNames.RETURN_CODE, value = ReturnCodes.FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, description = FAILURE_DESC) })
public Map<String, String> execute(@Param(value = InputNames.HOST, required = true, description = HOST_DESC) String host, @Param(value = InputNames.PROTOCOL, description = PROTOCOL_DESC) String protocol, @Param(value = InputNames.USERNAME, required = true, description = USERNAME_DESC) String username, @Param(value = InputNames.PASSWORD, required = true, encrypted = true, description = PASSWORD_DESC) String password, @Param(value = InputNames.DISTINGUISHED_NAME, required = true, description = DISTINGUISHED_NAME_DESC) String distinguishedName, @Param(value = InputNames.COMPUTER_COMMON_NAME, required = true, description = COMPUTER_COMMON_NAME_DESC) String computerCommonName, @Param(value = InputNames.SAM_ACCOUNT_NAME, description = SAM_ACCOUNT_NAME_DESC) String sAMAccountName, @Param(value = InputNames.PROXY_HOST, description = PROXY_HOST_DESC) String proxyHost, @Param(value = InputNames.PROXY_PORT, description = PROXY_PORT_DESC) String proxyPort, @Param(value = InputNames.PROXY_USERNAME, description = PROXY_USERNAME_DESC) String proxyUsername, @Param(value = InputNames.PROXY_PASSWORD, description = PROXY_PASSWORD_DESC) String proxyPassword, @Param(value = InputNames.TLS_VERSION, description = TLS_VERSION_DESC) String tlsVersion, @Param(value = InputNames.ALLOWED_CIPHERS, description = ALLOWED_CIPHERS_DESC) String allowedCiphers, @Param(value = InputNames.X_509_HOSTNAME_VERIFIER, description = X_509_DESC) String x509HostnameVerifier, @Param(value = InputNames.TRUST_ALL_ROOTS, description = TRUST_ALL_ROOTS_DESC) String trustAllRoots, @Param(value = InputNames.TRUST_KEYSTORE, description = TRUST_KEYSTORE_DESC) String trustKeystore, @Param(value = InputNames.TRUST_PASSWORD, encrypted = true, description = TRUST_PASSWORD_DESC) String trustPassword, @Param(value = InputNames.ESCAPE_CHARS, description = ESCAPE_CHARS_DESC) String escapeChars, @Param(value = InputNames.TIMEOUT, description = TIMEOUT_DESC) String timeout) {
    protocol = defaultIfEmpty(protocol, HTTPS);
    proxyPort = defaultIfEmpty(proxyPort, DEFAULT_PROXY_PORT);
    tlsVersion = defaultIfEmpty(tlsVersion, TLSv1_2);
    allowedCiphers = defaultIfEmpty(allowedCiphers, ALLOWED_CIPHERS_LIST);
    x509HostnameVerifier = defaultIfEmpty(x509HostnameVerifier, STRICT);
    trustAllRoots = defaultIfEmpty(trustAllRoots, BOOLEAN_FALSE);
    trustPassword = defaultIfEmpty(trustPassword, DEFAULT_PASSWORD_FOR_STORE);
    escapeChars = defaultIfEmpty(escapeChars, BOOLEAN_FALSE);
    timeout = defaultIfEmpty(timeout, TIMEOUT_VALUE);
    CreateComputerAccountInput.Builder inputBuilder = new CreateComputerAccountInput.Builder().host(host).distinguishedName(distinguishedName).computerCommonName(computerCommonName).sAMAccountName(sAMAccountName).username(username).password(password).protocol(protocol).proxyHost(proxyHost).proxyPort(proxyPort).proxyUsername(proxyUsername).proxyPassword(proxyPassword).tlsVersion(tlsVersion).allowedCiphers(allowedCiphers).x509HostnameVerifier(x509HostnameVerifier).trustAllRoots(trustAllRoots).trustKeystore(trustKeystore).trustPassword(trustPassword).escapeChars(escapeChars).timeout(timeout);
    try {
        return new CreateComputerAccountService().execute(inputBuilder.build());
    } catch (Exception e) {
        return ResultUtils.fromException(e);
    }
}
Also used : CreateComputerAccountInput(io.cloudslang.content.active_directory.entities.CreateComputerAccountInput) CreateComputerAccountService(io.cloudslang.content.active_directory.services.computers.CreateComputerAccountService) Action(com.hp.oo.sdk.content.annotations.Action)

Example 92 with Action

use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.

the class DisableComputerAccountAction method execute.

/**
 * Disables a computer account in Active Directory.
 *
 * @param host                 The domain controller to connect to.
 * @param distinguishedName    The Organizational Unit DN or Common Name DN to disable the computer from.
 *                             (i.e. OU=OUTest1,DC=battleground,DC=ad)
 * @param computerCommonName   The name of the computer (its CN).
 * @param username             The user to connect to Active Directory as.
 * @param password             The password of the user to connect to Active Directory.
 * @param protocol             The protocol to use when connecting to the Active Directory server.
 *                             Valid values: HTTP and HTTPS.
 * @param proxyHost            The proxy server used to access the web site.
 * @param proxyPort            The proxy server port.
 *                             Default value: 8080.
 * @param proxyUsername        The username used when connecting to the proxy.
 * @param proxyPassword        The proxy server password associated with the "proxyUsername" input value.
 * @param tlsVersion           The version of TLS to use. The value of this input will be ignored if "protocol"
 *                             is set to "HTTP". This capability is provided “as is”, please see product documentation
 *                             for further information.
 *                             Valid values: TLSv1, TLSv1.1, TLSv1.2.
 *                             Default value: TLSv1.2.
 * @param allowedCiphers       A list of ciphers to use. The value of this input will be ignored if 'tlsVersion' does
 *                             not contain 'TLSv1.2'. This capability is provided “as is”, please see product documentation
 *                             for further security considerations. In order to connect successfully to the target host,
 *                             it should accept at least one of the following ciphers. If this is not the case, it is
 *                             the user's responsibility to configure the host accordingly or to update the list of
 *                             allowed ciphers.
 *                             Default value: TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,
 *                             TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
 *                             TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,
 *                             TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
 *                             TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
 *                             TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
 *                             TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256,
 *                             TLS_RSA_WITH_AES_128_CBC_SHA256.
 * @param trustAllRoots        Specifies whether to enable weak security over SSL. A SSL certificate is trusted
 *                             even if no trusted certification authority issued it.
 *                             Valid values: true, false.
 *                             Default value: false.
 * @param x509HostnameVerifier Specifies the way the server hostname must match a domain name in the subject's Common
 *                             Name (CN) or subjectAltName field of the X.509 certificate. Set this to "allow_all" to
 *                             skip any checking, but you become vulnerable to attacks.
 *                             For the value "browser_compatible" the hostname verifier works the same way as Curl
 *                             and Firefox. The hostname must match either the first CN, or any of the subject-alts.
 *                             A wildcard can occur in the CN, and in any of the subject-alts. The only difference
 *                             between "browser_compatible" and "strict" is that a wildcard (such as "*.foo.com")
 *                             with "browser_compatible" matches all subdomains, including "a.b.foo.com". From the
 *                             security perspective, to provide protection against possible Man-In-The-Middle attacks,
 *                             we strongly recommend to use "strict" option.
 *                             Default value: strict.
 *                             Valid values: strict, browser_compatible, allow_all.
 * @param trustKeystore        The location of the TrustStore file.
 *                             Example: %JAVA_HOME%/jre/lib/security/cacerts.
 * @param trustPassword        The password associated with the TrustStore file.
 * @param timeout              Time in seconds to wait for the command to complete.
 *                             Default value: 60.
 * @return a map containing the output of the operations. Keys present in the map are:
 * returnResult - The return result of the operation.
 * returnCode - The return code of the operation. 0 if the operation succeeded, -1 if the operation fails.
 * exception - The exception message if the operation fails.
 * computerDN - The distinguished name of the computer account that was disabled.
 */
@Action(name = "Disable Computer Account", description = DISABLE_COMPUTER_ACCOUNT_DESC, outputs = { @Output(value = OutputNames.RETURN_RESULT, description = RETURN_RESULT_DESC), @Output(value = OutputNames.RESULT_COMPUTER_DN, description = RESULT_DISABLE_COMPUTER_DN_DESC), @Output(value = OutputNames.RETURN_CODE, description = RETURN_CODE_DESC), @Output(value = OutputNames.EXCEPTION, description = EXCEPTION_DESC) }, responses = { @Response(text = ResponseNames.SUCCESS, field = OutputNames.RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED, description = SUCCESS_DESC), @Response(text = ResponseNames.FAILURE, field = OutputNames.RETURN_CODE, value = ReturnCodes.FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, description = FAILURE_DESC) })
public Map<String, String> execute(@Param(value = InputNames.HOST, required = true, description = HOST_DESC) String host, @Param(value = InputNames.PROTOCOL, description = PROTOCOL_DESC) String protocol, @Param(value = InputNames.USERNAME, required = true, description = USERNAME_DESC) String username, @Param(value = InputNames.PASSWORD, required = true, encrypted = true, description = PASSWORD_DESC) String password, @Param(value = InputNames.DISTINGUISHED_NAME, required = true, description = DISTINGUISHED_NAME_DESC) String distinguishedName, @Param(value = InputNames.COMPUTER_COMMON_NAME, required = true, description = COMPUTER_COMMON_NAME_DESC) String computerCommonName, @Param(value = InputNames.PROXY_HOST, description = PROXY_HOST_DESC) String proxyHost, @Param(value = InputNames.PROXY_PORT, description = PROXY_PORT_DESC) String proxyPort, @Param(value = InputNames.PROXY_USERNAME, description = PROXY_USERNAME_DESC) String proxyUsername, @Param(value = InputNames.PROXY_PASSWORD, description = PROXY_PASSWORD_DESC) String proxyPassword, @Param(value = InputNames.TLS_VERSION, description = TLS_VERSION_DESC) String tlsVersion, @Param(value = InputNames.ALLOWED_CIPHERS, description = ALLOWED_CIPHERS_DESC) String allowedCiphers, @Param(value = InputNames.X_509_HOSTNAME_VERIFIER, description = X_509_DESC) String x509HostnameVerifier, @Param(value = InputNames.TRUST_ALL_ROOTS, description = TRUST_ALL_ROOTS_DESC) String trustAllRoots, @Param(value = InputNames.TRUST_KEYSTORE, description = TRUST_KEYSTORE_DESC) String trustKeystore, @Param(value = InputNames.TRUST_PASSWORD, encrypted = true, description = TRUST_PASSWORD_DESC) String trustPassword, @Param(value = InputNames.TIMEOUT, description = TIMEOUT_DESC) String timeout) {
    protocol = defaultIfEmpty(protocol, HTTPS);
    proxyPort = defaultIfEmpty(proxyPort, DEFAULT_PROXY_PORT);
    tlsVersion = defaultIfEmpty(tlsVersion, TLSv1_2);
    allowedCiphers = defaultIfEmpty(allowedCiphers, ALLOWED_CIPHERS_LIST);
    x509HostnameVerifier = defaultIfEmpty(x509HostnameVerifier, STRICT);
    trustAllRoots = defaultIfEmpty(trustAllRoots, BOOLEAN_FALSE);
    trustPassword = defaultIfEmpty(trustPassword, DEFAULT_PASSWORD_FOR_STORE);
    timeout = defaultIfEmpty(timeout, TIMEOUT_VALUE);
    DisableComputerAccountInput.Builder inputBuilder = new DisableComputerAccountInput.Builder().host(host).distinguishedName(distinguishedName).computerCommonName(computerCommonName).username(username).password(password).protocol(protocol).proxyHost(proxyHost).proxyPort(proxyPort).proxyUsername(proxyUsername).proxyPassword(proxyPassword).tlsVersion(tlsVersion).allowedCiphers(allowedCiphers).x509HostnameVerifier(x509HostnameVerifier).trustAllRoots(trustAllRoots).trustKeystore(trustKeystore).trustPassword(trustPassword).timeout(timeout);
    try {
        return new DisableComputerAccountService().execute(inputBuilder.build());
    } catch (Exception e) {
        return ResultUtils.fromException(e);
    }
}
Also used : DisableComputerAccountService(io.cloudslang.content.active_directory.services.computers.DisableComputerAccountService) DisableComputerAccountInput(io.cloudslang.content.active_directory.entities.DisableComputerAccountInput) Action(com.hp.oo.sdk.content.annotations.Action)

Example 93 with Action

use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.

the class EnableComputerAccountAction method execute.

/**
 * Enables a computer account in Active Directory.
 *
 * @param host                 The domain controller to connect to.
 * @param distinguishedName    The Organizational Unit DN or Common Name DN on which to enable the computer.
 *                             (i.e. OU=OUTest1,DC=battleground,DC=ad)
 * @param computerCommonName   The name of the computer (its CN).
 * @param username             The user to connect to Active Directory as.
 * @param password             The password of the user to connect to Active Directory.
 * @param protocol             The protocol to use when connecting to the Active Directory server.
 *                             Valid values: HTTP and HTTPS.
 * @param proxyHost            The proxy server used to access the web site.
 * @param proxyPort            The proxy server port.
 *                             Default value: 8080.
 * @param proxyUsername        The username used when connecting to the proxy.
 * @param proxyPassword        The proxy server password associated with the "proxyUsername" input value.
 * @param tlsVersion           The version of TLS to use. The value of this input will be ignored if "protocol"
 *                             is set to "HTTP". This capability is provided “as is”, please see product documentation
 *                             for further information.
 *                             Valid values: TLSv1, TLSv1.1, TLSv1.2.
 *                             Default value: TLSv1.2.
 * @param allowedCiphers       A list of ciphers to use. The value of this input will be ignored if 'tlsVersion' does
 *                             not contain 'TLSv1.2'. This capability is provided “as is”, please see product documentation
 *                             for further security considerations. In order to connect successfully to the target host,
 *                             it should accept at least one of the following ciphers. If this is not the case, it is
 *                             the user's responsibility to configure the host accordingly or to update the list of
 *                             allowed ciphers.
 *                             Default value: TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,
 *                             TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
 *                             TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,
 *                             TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
 *                             TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
 *                             TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
 *                             TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256,
 *                             TLS_RSA_WITH_AES_128_CBC_SHA256.
 * @param trustAllRoots        Specifies whether to enable weak security over SSL. A SSL certificate is trusted
 *                             even if no trusted certification authority issued it.
 *                             Valid values: true, false.
 *                             Default value: false.
 * @param x509HostnameVerifier Specifies the way the server hostname must match a domain name in the subject's Common
 *                             Name (CN) or subjectAltName field of the X.509 certificate. Set this to "allow_all" to
 *                             skip any checking, but you become vulnerable to attacks.
 *                             For the value "browser_compatible" the hostname verifier works the same way as Curl
 *                             and Firefox. The hostname must match either the first CN, or any of the subject-alts.
 *                             A wildcard can occur in the CN, and in any of the subject-alts. The only difference
 *                             between "browser_compatible" and "strict" is that a wildcard (such as "*.foo.com")
 *                             with "browser_compatible" matches all subdomains, including "a.b.foo.com". From the
 *                             security perspective, to provide protection against possible Man-In-The-Middle attacks,
 *                             we strongly recommend to use "strict" option.
 *                             Default value: strict.
 *                             Valid values: strict, browser_compatible, allow_all.
 * @param trustKeystore        The location of the TrustStore file.
 *                             Example: %JAVA_HOME%/jre/lib/security/cacerts.
 * @param trustPassword        The password associated with the TrustStore file.
 * @param timeout              Time in seconds to wait for the command to complete.
 *                             Default value: 60.
 * @return a map containing the output of the operations. Keys present in the map are:
 * returnResult - The return result of the operation.
 * returnCode - The return code of the operation. 0 if the operation succeeded, -1 if the operation fails.
 * exception - The exception message if the operation fails.
 * computerDN - The distinguished name of the computer account that was enabled.
 */
@Action(name = "Enable Computer Account", description = ENABLE_COMPUTER_ACCOUNT_DESC, outputs = { @Output(value = OutputNames.RETURN_RESULT, description = RESULT_ENABLE_COMPUTER_DN_DESC), @Output(value = OutputNames.RESULT_COMPUTER_DN, description = RESULT_ENABLE_COMPUTER_DN_DESC), @Output(value = OutputNames.RETURN_CODE, description = RETURN_CODE_DESC), @Output(value = OutputNames.EXCEPTION, description = EXCEPTION_DESC) }, responses = { @Response(text = ResponseNames.SUCCESS, field = OutputNames.RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED, description = SUCCESS_DESC), @Response(text = ResponseNames.FAILURE, field = OutputNames.RETURN_CODE, value = ReturnCodes.FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, description = FAILURE_DESC) })
public Map<String, String> execute(@Param(value = InputNames.HOST, required = true, description = HOST_DESC) String host, @Param(value = InputNames.PROTOCOL, description = PROTOCOL_DESC) String protocol, @Param(value = InputNames.USERNAME, required = true, description = USERNAME_DESC) String username, @Param(value = InputNames.PASSWORD, encrypted = true, required = true, description = PASSWORD_DESC) String password, @Param(value = InputNames.DISTINGUISHED_NAME, required = true, description = DISTINGUISHED_NAME_DESC) String distinguishedName, @Param(value = InputNames.COMPUTER_COMMON_NAME, required = true, description = COMPUTER_COMMON_NAME_DESC) String computerCommonName, @Param(value = InputNames.PROXY_HOST, description = PROXY_HOST_DESC) String proxyHost, @Param(value = InputNames.PROXY_PORT, description = PROXY_PORT_DESC) String proxyPort, @Param(value = InputNames.PROXY_USERNAME, description = PROXY_USERNAME_DESC) String proxyUsername, @Param(value = InputNames.PROXY_PASSWORD, description = PROXY_PASSWORD_DESC) String proxyPassword, @Param(value = InputNames.TLS_VERSION, description = TLS_VERSION_DESC) String tlsVersion, @Param(value = InputNames.ALLOWED_CIPHERS, description = ALLOWED_CIPHERS_DESC) String allowedCiphers, @Param(value = InputNames.X_509_HOSTNAME_VERIFIER, description = X_509_DESC) String x509HostnameVerifier, @Param(value = InputNames.TRUST_ALL_ROOTS, description = TRUST_ALL_ROOTS_DESC) String trustAllRoots, @Param(value = InputNames.TRUST_KEYSTORE, description = TRUST_KEYSTORE_DESC) String trustKeystore, @Param(value = InputNames.TRUST_PASSWORD, encrypted = true, description = TRUST_PASSWORD_DESC) String trustPassword, @Param(value = InputNames.TIMEOUT, description = TIMEOUT_DESC) String timeout) {
    protocol = defaultIfEmpty(protocol, HTTPS);
    proxyPort = defaultIfEmpty(proxyPort, DEFAULT_PROXY_PORT);
    tlsVersion = defaultIfEmpty(tlsVersion, TLSv1_2);
    allowedCiphers = defaultIfEmpty(allowedCiphers, ALLOWED_CIPHERS_LIST);
    x509HostnameVerifier = defaultIfEmpty(x509HostnameVerifier, STRICT);
    trustAllRoots = defaultIfEmpty(trustAllRoots, BOOLEAN_FALSE);
    trustPassword = defaultIfEmpty(trustPassword, DEFAULT_PASSWORD_FOR_STORE);
    timeout = defaultIfEmpty(timeout, TIMEOUT_VALUE);
    EnableComputerAccountInput.Builder inputBuilder = new EnableComputerAccountInput.Builder().host(host).distinguishedName(distinguishedName).computerCommonName(computerCommonName).username(username).password(password).protocol(protocol).proxyHost(proxyHost).proxyPort(proxyPort).proxyUsername(proxyUsername).proxyPassword(proxyPassword).tlsVersion(tlsVersion).allowedCiphers(allowedCiphers).x509HostnameVerifier(x509HostnameVerifier).trustAllRoots(trustAllRoots).trustKeystore(trustKeystore).trustPassword(trustPassword).timeout(timeout);
    try {
        return new EnableComputerAccountService().execute(inputBuilder.build());
    } catch (Exception e) {
        return ResultUtils.fromException(e);
    }
}
Also used : EnableComputerAccountService(io.cloudslang.content.active_directory.services.computers.EnableComputerAccountService) EnableComputerAccountInput(io.cloudslang.content.active_directory.entities.EnableComputerAccountInput) Action(com.hp.oo.sdk.content.annotations.Action)

Example 94 with Action

use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.

the class IsComputerAccountEnabledAction method execute.

/**
 * Checks to see if a computer account is enabled in Active Directory.
 *
 * @param host                 The domain controller to connect to.
 * @param distinguishedName    The Organizational Unit DN or Common Name DN the computer is in.
 *                             (i.e. OU=OUTest1,DC=battleground,DC=ad)
 * @param computerCommonName   The name of the computer (its CN).
 * @param username             The user to connect to Active Directory as.
 * @param password             The password of the user to connect to Active Directory.
 * @param protocol             The protocol to use when connecting to the Active Directory server.
 *                             Valid values: HTTP and HTTPS.
 * @param proxyHost            The proxy server used to access the web site.
 * @param proxyPort            The proxy server port.
 *                             Default value: 8080.
 * @param proxyUsername        The username used when connecting to the proxy.
 * @param proxyPassword        The proxy server password associated with the "proxyUsername" input value.
 * @param tlsVersion           The version of TLS to use. The value of this input will be ignored if "protocol"
 *                             is set to "HTTP". This capability is provided “as is”, please see product documentation
 *                             for further information.
 *                             Valid values: TLSv1, TLSv1.1, TLSv1.2.
 *                             Default value: TLSv1.2.
 * @param allowedCiphers       A list of ciphers to use. The value of this input will be ignored if 'tlsVersion' does
 *                             not contain 'TLSv1.2'. This capability is provided “as is”, please see product documentation
 *                             for further security considerations. In order to connect successfully to the target host,
 *                             it should accept at least one of the following ciphers. If this is not the case, it is
 *                             the user's responsibility to configure the host accordingly or to update the list of
 *                             allowed ciphers.
 *                             Default value: TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,
 *                             TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
 *                             TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,
 *                             TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
 *                             TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
 *                             TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
 *                             TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256,
 *                             TLS_RSA_WITH_AES_128_CBC_SHA256.
 * @param trustAllRoots        Specifies whether to enable weak security over SSL. A SSL certificate is trusted
 *                             even if no trusted certification authority issued it.
 *                             Valid values: true, false.
 *                             Default value: false.
 * @param x509HostnameVerifier Specifies the way the server hostname must match a domain name in the subject's Common
 *                             Name (CN) or subjectAltName field of the X.509 certificate. Set this to "allow_all" to
 *                             skip any checking, but you become vulnerable to attacks.
 *                             For the value "browser_compatible" the hostname verifier works the same way as Curl
 *                             and Firefox. The hostname must match either the first CN, or any of the subject-alts.
 *                             A wildcard can occur in the CN, and in any of the subject-alts. The only difference
 *                             between "browser_compatible" and "strict" is that a wildcard (such as "*.foo.com")
 *                             with "browser_compatible" matches all subdomains, including "a.b.foo.com". From the
 *                             security perspective, to provide protection against possible Man-In-The-Middle attacks,
 *                             we strongly recommend to use "strict" option.
 *                             Default value: strict.
 *                             Valid values: strict, browser_compatible, allow_all.
 * @param trustKeystore        The location of the TrustStore file.
 *                             Example: %JAVA_HOME%/jre/lib/security/cacerts.
 * @param trustPassword        The password associated with the TrustStore file.
 * @param timeout              Time in seconds to wait for the command to complete.
 *                             Default value: 60.
 * @return a map containing the output of the operations. Keys present in the map are:
 * returnResult - The return result of the operation.
 * returnCode - The return code of the operation. 0 if the operation succeeded, -1 if the operation fails.
 * exception - The exception message if the operation fails.
 * computerDN - The distinguished Name of the computer account.
 */
@Action(name = "Is Computer Account Enabled", description = IS_COMPUTER_ACCOUNT_ENABLED_DESC, outputs = { @Output(value = OutputNames.RETURN_RESULT, description = RETURN_RESULT_DESC), @Output(value = OutputNames.RESULT_COMPUTER_DN, description = IS_COMPUTER_ACCOUNT_ENABLED_RESULT_OU_DESC), @Output(value = OutputNames.RETURN_CODE, description = RETURN_CODE_DESC), @Output(value = OutputNames.EXCEPTION, description = EXCEPTION_DESC) }, responses = { @Response(text = ResponseNames.SUCCESS, field = OutputNames.RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED, description = SUCCESS_DESC), @Response(text = ResponseNames.FAILURE, field = OutputNames.RETURN_CODE, value = ReturnCodes.FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, description = FAILURE_DESC) })
public Map<String, String> execute(@Param(value = InputNames.HOST, required = true, description = HOST_DESC) String host, @Param(value = InputNames.PROTOCOL, description = PROTOCOL_DESC) String protocol, @Param(value = InputNames.USERNAME, required = true, description = USERNAME_DESC) String username, @Param(value = InputNames.PASSWORD, encrypted = true, required = true, description = PASSWORD_DESC) String password, @Param(value = InputNames.DISTINGUISHED_NAME, required = true, description = IS_COMPUTER_ACCOUNT_ENABLED_DISTINGUISHED_NAME_DESC) String distinguishedName, @Param(value = InputNames.COMPUTER_COMMON_NAME, required = true, description = IS_COMPUTER_ACCOUNT_ENABLED_COMPUTER_COMMON_NAME_DESC) String computerCommonName, @Param(value = InputNames.PROXY_HOST, description = PROXY_HOST_DESC) String proxyHost, @Param(value = InputNames.PROXY_PORT, description = PROXY_PORT_DESC) String proxyPort, @Param(value = InputNames.PROXY_USERNAME, description = PROXY_USERNAME_DESC) String proxyUsername, @Param(value = InputNames.PROXY_PASSWORD, description = PROXY_PASSWORD_DESC) String proxyPassword, @Param(value = InputNames.TLS_VERSION, description = TLS_VERSION_DESC) String tlsVersion, @Param(value = InputNames.ALLOWED_CIPHERS, description = ALLOWED_CIPHERS_DESC) String allowedCiphers, @Param(value = InputNames.X_509_HOSTNAME_VERIFIER, description = X_509_DESC) String x509HostnameVerifier, @Param(value = InputNames.TRUST_ALL_ROOTS, description = TRUST_ALL_ROOTS_DESC) String trustAllRoots, @Param(value = InputNames.TRUST_KEYSTORE, description = TRUST_KEYSTORE_DESC) String trustKeystore, @Param(value = InputNames.TRUST_PASSWORD, encrypted = true, description = TRUST_PASSWORD_DESC) String trustPassword, @Param(value = InputNames.TIMEOUT, description = TIMEOUT_DESC) String timeout) {
    protocol = defaultIfEmpty(protocol, HTTPS);
    proxyPort = defaultIfEmpty(proxyPort, DEFAULT_PROXY_PORT);
    tlsVersion = defaultIfEmpty(tlsVersion, TLSv1_2);
    allowedCiphers = defaultIfEmpty(allowedCiphers, ALLOWED_CIPHERS_LIST);
    x509HostnameVerifier = defaultIfEmpty(x509HostnameVerifier, STRICT);
    trustAllRoots = defaultIfEmpty(trustAllRoots, BOOLEAN_FALSE);
    trustPassword = defaultIfEmpty(trustPassword, DEFAULT_PASSWORD_FOR_STORE);
    timeout = defaultIfEmpty(timeout, TIMEOUT_VALUE);
    IsComputerAccountEnabledInput.Builder inputBuilder = new IsComputerAccountEnabledInput.Builder().host(host).distinguishedName(distinguishedName).computerCommonName(computerCommonName).username(username).password(password).protocol(protocol).proxyHost(proxyHost).proxyPort(proxyPort).proxyUsername(proxyUsername).proxyPassword(proxyPassword).tlsVersion(tlsVersion).allowedCiphers(allowedCiphers).x509HostnameVerifier(x509HostnameVerifier).trustAllRoots(trustAllRoots).trustKeystore(trustKeystore).trustPassword(trustPassword).timeout(timeout);
    try {
        return new IsComputerAccountEnabledService().execute(inputBuilder.build());
    } catch (Exception e) {
        return ResultUtils.fromException(e);
    }
}
Also used : IsComputerAccountEnabledService(io.cloudslang.content.active_directory.services.computers.IsComputerAccountEnabledService) IsComputerAccountEnabledInput(io.cloudslang.content.active_directory.entities.IsComputerAccountEnabledInput) Action(com.hp.oo.sdk.content.annotations.Action)

Example 95 with Action

use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.

the class ResetComputerAccountAction method execute.

/**
 * Resets a computer account in Active Directory, by resetting the password to an initial password.
 *
 * @param host                      The domain controller to connect to.
 * @param computerDistinguishedName The distinguished name of the computer account we want to reset.
 *                                  Example: CN=computer_name,DC=example,DC=com
 * @param username                  The user to connect to Active Directory as.
 * @param password                  The password of the user to connect to Active Directory.
 * @param protocol                  The protocol to use when connecting to the Active Directory server.
 *                                  Valid values: HTTP and HTTPS.
 * @param proxyHost                 The proxy server used to access the web site.
 * @param proxyPort                 The proxy server port.
 *                                  Default value: 8080.
 * @param proxyUsername             The username used when connecting to the proxy.
 * @param proxyPassword             The proxy server password associated with the "proxyUsername" input value.
 * @param tlsVersion                The version of TLS to use. The value of this input will be ignored if "protocol"
 *                                  is set to "HTTP". This capability is provided “as is”, please see product documentation
 *                                  for further information.
 *                                  Valid values: TLSv1, TLSv1.1, TLSv1.2.
 *                                  Default value: TLSv1.2.
 * @param allowedCiphers            A list of ciphers to use. The value of this input will be ignored if 'tlsVersion' does
 *                                  not contain 'TLSv1.2'. This capability is provided “as is”, please see product documentation
 *                                  for further security considerations. In order to connect successfully to the target host,
 *                                  it should accept at least one of the following ciphers. If this is not the case, it is
 *                                  the user's responsibility to configure the host accordingly or to update the list of
 *                                  allowed ciphers. This capability is provided “as is”, please see product documentation
 *                                  for further security considerations. In order to connect successfully to the target host,
 *                                  it should accept at least one of the following ciphers. If this is not the case, it is
 *                                  the user's responsibility to configure the host accordingly or to update the list of
 *                                  allowed ciphers.
 *                                  Default value: TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,
 *                                  TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
 *                                  TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,
 *                                  TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
 *                                  TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
 *                                  TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
 *                                  TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256,
 *                                  TLS_RSA_WITH_AES_128_CBC_SHA256.
 * @param trustAllRoots             Specifies whether to enable weak security over SSL. A SSL certificate is trusted
 *                                  even if no trusted certification authority issued it.
 *                                  Valid values: true, false.
 *                                  Default value: false.
 * @param x509HostnameVerifier      Specifies the way the server hostname must match a domain name in the subject's Common
 *                                  Name (CN) or subjectAltName field of the X.509 certificate. Set this to "allow_all" to
 *                                  skip any checking, but you become vulnerable to attacks.
 *                                  For the value "browser_compatible" the hostname verifier works the same way as Curl
 *                                  and Firefox. The hostname must match either the first CN, or any of the subject-alts.
 *                                  A wildcard can occur in the CN, and in any of the subject-alts. The only difference
 *                                  between "browser_compatible" and "strict" is that a wildcard (such as "*.foo.com")
 *                                  with "browser_compatible" matches all subdomains, including "a.b.foo.com". From the
 *                                  security perspective, to provide protection against possible Man-In-The-Middle attacks,
 *                                  we strongly recommend to use "strict" option.
 *                                  Default value: strict.
 *                                  Valid values: strict, browser_compatible, allow_all.
 * @param trustKeystore             The location of the TrustStore file.
 *                                  Example: %JAVA_HOME%/jre/lib/security/cacerts.
 * @param trustPassword             The password associated with the TrustStore file.
 * @param timeout                   Time in seconds to wait for the command to complete.
 *                                  Default value: 60.
 * @return a map containing the output of the operations. Keys present in the map are:
 * returnResult - The return result of the operation.
 * returnCode - The return code of the operation. 0 if the operation succeeded, -1 if the operation fails.
 * exception - The exception message if the operation fails.
 */
@Action(name = "Reset Computer Account", description = RESET_COMPUTER_ACCOUNT_DESC, outputs = { @Output(value = OutputNames.RETURN_RESULT, description = RETURN_RESULT_DESC), @Output(value = OutputNames.RETURN_CODE, description = RETURN_CODE_DESC), @Output(value = OutputNames.EXCEPTION, description = EXCEPTION_DESC) }, responses = { @Response(text = ResponseNames.SUCCESS, field = OutputNames.RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED, description = SUCCESS_DESC), @Response(text = ResponseNames.FAILURE, field = OutputNames.RETURN_CODE, value = ReturnCodes.FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, description = FAILURE_DESC) })
public Map<String, String> execute(@Param(value = InputNames.HOST, required = true, description = HOST_DESC) String host, @Param(value = InputNames.PROTOCOL, description = PROTOCOL_DESC) String protocol, @Param(value = InputNames.USERNAME, required = true, description = USERNAME_DESC) String username, @Param(value = InputNames.PASSWORD, encrypted = true, required = true, description = PASSWORD_DESC) String password, @Param(value = InputNames.COMPUTER_DISTINGUISHED_NAME, required = true, description = COMPUTER_DISTINGUISHED_NAME_DESC) String computerDistinguishedName, @Param(value = InputNames.PROXY_HOST, description = PROXY_HOST_DESC) String proxyHost, @Param(value = InputNames.PROXY_PORT, description = PROXY_PORT_DESC) String proxyPort, @Param(value = InputNames.PROXY_USERNAME, description = PROXY_USERNAME_DESC) String proxyUsername, @Param(value = InputNames.PROXY_PASSWORD, description = PROXY_PASSWORD_DESC) String proxyPassword, @Param(value = InputNames.TLS_VERSION, description = TLS_VERSION_DESC) String tlsVersion, @Param(value = InputNames.ALLOWED_CIPHERS, description = ALLOWED_CIPHERS_DESC) String allowedCiphers, @Param(value = InputNames.X_509_HOSTNAME_VERIFIER, description = X_509_DESC) String x509HostnameVerifier, @Param(value = InputNames.TRUST_ALL_ROOTS, description = TRUST_ALL_ROOTS_DESC) String trustAllRoots, @Param(value = InputNames.TRUST_KEYSTORE, description = TRUST_KEYSTORE_DESC) String trustKeystore, @Param(value = InputNames.TRUST_PASSWORD, encrypted = true, description = TRUST_PASSWORD_DESC) String trustPassword, @Param(value = InputNames.TIMEOUT, description = TIMEOUT_DESC) String timeout) {
    protocol = defaultIfEmpty(protocol, HTTPS);
    proxyPort = defaultIfEmpty(proxyPort, DEFAULT_PROXY_PORT);
    tlsVersion = defaultIfEmpty(tlsVersion, TLSv1_2);
    allowedCiphers = defaultIfEmpty(allowedCiphers, ALLOWED_CIPHERS_LIST);
    x509HostnameVerifier = defaultIfEmpty(x509HostnameVerifier, STRICT);
    trustAllRoots = defaultIfEmpty(trustAllRoots, BOOLEAN_FALSE);
    trustPassword = defaultIfEmpty(trustPassword, DEFAULT_PASSWORD_FOR_STORE);
    timeout = defaultIfEmpty(timeout, TIMEOUT_VALUE);
    ResetComputerAccountInput.Builder inputBuilder = new ResetComputerAccountInput.Builder().host(host).computerDistinguishedName(computerDistinguishedName).username(username).password(password).protocol(protocol).proxyHost(proxyHost).proxyPort(proxyPort).proxyUsername(proxyUsername).proxyPassword(proxyPassword).tlsVersion(tlsVersion).allowedCiphers(allowedCiphers).x509HostnameVerifier(x509HostnameVerifier).trustAllRoots(trustAllRoots).trustKeystore(trustKeystore).trustPassword(trustPassword).timeout(timeout);
    try {
        return new ResetComputerAccountService().execute(inputBuilder.build());
    } catch (Exception e) {
        return ResultUtils.fromException(e);
    }
}
Also used : ResetComputerAccountInput(io.cloudslang.content.active_directory.entities.ResetComputerAccountInput) ResetComputerAccountService(io.cloudslang.content.active_directory.services.computers.ResetComputerAccountService) Action(com.hp.oo.sdk.content.annotations.Action)

Aggregations

Action (com.hp.oo.sdk.content.annotations.Action)230 CommonInputs (io.cloudslang.content.amazon.entities.inputs.CommonInputs)48 QueryApiExecutor (io.cloudslang.content.amazon.execute.QueryApiExecutor)47 CustomInputs (io.cloudslang.content.amazon.entities.inputs.CustomInputs)32 HttpClientInputs (io.cloudslang.content.httpclient.entities.HttpClientInputs)29 HashMap (java.util.HashMap)22 VmInputs (io.cloudslang.content.vmware.entities.VmInputs)21 HttpInputs (io.cloudslang.content.vmware.entities.http.HttpInputs)21 CommonInputs (io.cloudslang.content.couchbase.entities.inputs.CommonInputs)15 CouchbaseService (io.cloudslang.content.couchbase.execute.CouchbaseService)15 InputsUtil.getHttpClientInputs (io.cloudslang.content.couchbase.utils.InputsUtil.getHttpClientInputs)15 NetworkInputs (io.cloudslang.content.amazon.entities.inputs.NetworkInputs)11 Map (java.util.Map)11 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)10 CommonInputs (io.cloudslang.content.amazon.entities.constants.Inputs.CommonInputs)9 InstanceInputs (io.cloudslang.content.amazon.entities.inputs.InstanceInputs)9 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 JsonParser (com.google.gson.JsonParser)8 SFTPService (io.cloudslang.content.rft.services.SFTPService)8 ClusterComputeResourceService (io.cloudslang.content.vmware.services.ClusterComputeResourceService)8