private void setClientOptionValues()

in iothub/device/iot-device-client/src/main/java/com/microsoft/azure/sdk/iot/device/ClientConfiguration.java [223:290]


    private void setClientOptionValues(ClientOptions clientOptions)
    {
        this.modelId = clientOptions != null && clientOptions.getModelId() != null ? clientOptions.getModelId() : null;
        this.keepAliveInterval = clientOptions != null && clientOptions.getKeepAliveInterval() != 0 ? clientOptions.getKeepAliveInterval() : DEFAULT_KEEP_ALIVE_INTERVAL_IN_SECONDS;
        this.httpsReadTimeout = clientOptions != null && clientOptions.getHttpsReadTimeout() != 0 ? clientOptions.getHttpsReadTimeout() : DEFAULT_HTTPS_READ_TIMEOUT_MILLIS;
        this.httpsConnectTimeout = clientOptions != null && clientOptions.getHttpsConnectTimeout() != 0 ? clientOptions.getHttpsConnectTimeout() : DEFAULT_HTTPS_CONNECT_TIMEOUT_MILLIS;
        this.amqpOpenAuthenticationSessionTimeout = clientOptions != null && clientOptions.getAmqpAuthenticationSessionTimeout() != 0 ? clientOptions.getAmqpAuthenticationSessionTimeout() : DEFAULT_AMQP_OPEN_AUTHENTICATION_SESSION_TIMEOUT_IN_SECONDS;
        this.amqpOpenDeviceSessionsTimeout = clientOptions != null && clientOptions.getAmqpDeviceSessionTimeout() != 0 ? clientOptions.getAmqpDeviceSessionTimeout() : DEFAULT_AMQP_OPEN_DEVICE_SESSIONS_TIMEOUT_IN_SECONDS;
        this.proxySettings = clientOptions != null && clientOptions.getProxySettings() != null ? clientOptions.getProxySettings() : null;
        this.sendInterval = clientOptions != null && clientOptions.getSendInterval() != 0 ? clientOptions.getSendInterval() : DEFAULT_SEND_INTERVAL_IN_MILLISECONDS;
        this.threadNamePrefix = clientOptions != null ? clientOptions.getThreadNamePrefix() : null;
        this.threadNameSuffix = clientOptions != null ? clientOptions.getThreadNameSuffix() : null;
        this.useIdentifiableThreadNames = clientOptions == null || clientOptions.isUsingIdentifiableThreadNames();
        this.logRoutineDisconnectsAsErrors = clientOptions == null || clientOptions.isLoggingRoutineDisconnectsAsErrors();
        this.messageExpiredCheckPeriod = clientOptions != null ? clientOptions.getMessageExpirationCheckPeriod() : DEFAULT_MESSAGE_EXPIRATION_CHECK_PERIOD;

        if (proxySettings != null)
        {
            IotHubClientProtocol protocol = this.getProtocol();

            if (protocol != HTTPS && protocol != AMQPS_WS && protocol != MQTT_WS)
            {
                throw new IllegalArgumentException("Use of proxies is unsupported unless using HTTPS, MQTT_WS or AMQPS_WS");
            }
        }

        if (this.getSasTokenAuthentication() != null && clientOptions != null)
        {
            if (clientOptions.getSasTokenExpiryTime() <= 0)
            {
                throw new IllegalArgumentException("ClientOption sasTokenExpiryTime must be greater than 0");
            }

            if (clientOptions.getSasTokenExpiryTime() >= MAX_SAS_TOKEN_EXPIRY_TIME_SECONDS)
            {
                // Higher values cause overflows that result in the SDK repeatedly renewing SAS tokens
                // and are generally a security risk
                throw new IllegalArgumentException("ClientOption sasTokenExpiryTime must be less than 10 years");
            }

            this.getSasTokenAuthentication().setTokenValidSecs(clientOptions.getSasTokenExpiryTime());
        }

        if (this.keepAliveInterval <= 0)
        {
            throw new IllegalArgumentException("ClientOption keepAliveInterval must be greater than 0");
        }

        if (this.httpsReadTimeout < 0)
        {
            throw new IllegalArgumentException("ClientOption httpsReadTimeout must be greater than or equal to 0");
        }

        if (this.httpsConnectTimeout < 0)
        {
            throw new IllegalArgumentException("ClientOption httpsConnectTimeout must be greater than or equal to 0");
        }

        if (this.amqpOpenAuthenticationSessionTimeout <= 0)
        {
            throw new IllegalArgumentException("ClientOption amqpAuthenticationSessionTimeout must be greater than 0");
        }

        if (this.amqpOpenDeviceSessionsTimeout <= 0)
        {
            throw new IllegalArgumentException("ClientOption amqpDeviceSessionTimeout must be greater than 0");
        }
    }