protected T validate()

in cassandra-analytics-common/src/main/java/org/apache/cassandra/secrets/SslConfig.java [419:473]


        protected T validate()
        {
            if (keyStorePath != null && base64EncodedKeyStore != null)
            {
                throw new IllegalArgumentException(
                        String.format("Both '%s' and '%s' options were provided. Only one of the options can be provided",
                                      KEYSTORE_PATH, KEYSTORE_BASE64_ENCODED));
            }

            if (keyStorePassword != null)
            {
                // When the keystore password is provided, either the key store path or
                // the encoded key store must be provided
                if (keyStorePath == null && base64EncodedKeyStore == null)
                {
                    throw new IllegalArgumentException(
                            String.format("One of the '%s' or '%s' options must be provided when the '%s' option is provided",
                                          KEYSTORE_PATH, KEYSTORE_BASE64_ENCODED, KEYSTORE_PASSWORD));
                }
            }
            else
            {

                throw new IllegalArgumentException(
                        String.format("The '%s' option must be provided when either the '%s' or '%s' options are provided",
                                      KEYSTORE_PASSWORD, KEYSTORE_PATH, KEYSTORE_BASE64_ENCODED));
            }

            if (trustStorePassword != null)
            {
                // Only one of trust store path or encoded trust store must be provided, not both
                if (trustStorePath != null && base64EncodedTrustStore != null)
                {
                    throw new IllegalArgumentException(
                            String.format("Both '%s' and '%s' options were provided. Only one of the options can be provided",
                                          TRUSTSTORE_PATH, TRUSTSTORE_BASE64_ENCODED));
                }

                // When the trust store password is provided, either the trust store
                // path or the encoded trust store must be provided
                if (trustStorePath == null && base64EncodedTrustStore == null)
                {
                    throw new IllegalArgumentException(
                           String.format("One of the '%s' or '%s' options must be provided when the '%s' option is provided",
                                          TRUSTSTORE_PATH, TRUSTSTORE_BASE64_ENCODED, TRUSTSTORE_PASSWORD));
                }
            }
            else if (trustStorePath != null || base64EncodedTrustStore != null)
            {
                throw new IllegalArgumentException(
                        String.format("The '%s' option must be provided when either the '%s' or '%s' options are provided",
                                      TRUSTSTORE_PASSWORD, TRUSTSTORE_PATH, TRUSTSTORE_BASE64_ENCODED));
            }
            return self();
        }