Search in sources :

Example 1 with Validator

use of org.apache.kafka.common.config.ConfigDef.Validator in project connect-utils by jcustenborder.

the class Validators method validKeyStoreType.

/**
 * Validator is used to ensure that the KeyStore type specified is valid.
 * @return
 */
public static Validator validKeyStoreType() {
    return (s, o) -> {
        if (!(o instanceof String)) {
            throw new ConfigException(s, o, "Must be a string.");
        }
        String keyStoreType = o.toString();
        try {
            KeyStore.getInstance(keyStoreType);
        } catch (KeyStoreException e) {
            ConfigException exception = new ConfigException(s, o, "Invalid KeyStore type");
            exception.initCause(e);
            throw exception;
        }
    };
}
Also used : ValidEnum(com.github.jcustenborder.kafka.connect.utils.config.ValidEnum) SSLContext(javax.net.ssl.SSLContext) TrustManagerFactory(javax.net.ssl.TrustManagerFactory) KeyManagerFactory(javax.net.ssl.KeyManagerFactory) KeyStore(java.security.KeyStore) KeyStoreException(java.security.KeyStoreException) ConfigException(org.apache.kafka.common.config.ConfigException) ValidPattern(com.github.jcustenborder.kafka.connect.utils.config.ValidPattern) ValidPort(com.github.jcustenborder.kafka.connect.utils.config.ValidPort) Validator(org.apache.kafka.common.config.ConfigDef.Validator) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Preconditions(com.google.common.base.Preconditions) Pattern(java.util.regex.Pattern) ConfigException(org.apache.kafka.common.config.ConfigException) KeyStoreException(java.security.KeyStoreException)

Example 2 with Validator

use of org.apache.kafka.common.config.ConfigDef.Validator in project connect-utils by jcustenborder.

the class Validators method validKeyManagerFactory.

/**
 * Validator is used to ensure that the KeyManagerFactory Algorithm specified is valid.
 * @return
 */
public static Validator validKeyManagerFactory() {
    return (s, o) -> {
        if (!(o instanceof String)) {
            throw new ConfigException(s, o, "Must be a string.");
        }
        String keyStoreType = o.toString();
        try {
            KeyManagerFactory.getInstance(keyStoreType);
        } catch (NoSuchAlgorithmException e) {
            ConfigException exception = new ConfigException(s, o, "Invalid Algorithm");
            exception.initCause(e);
            throw exception;
        }
    };
}
Also used : ValidEnum(com.github.jcustenborder.kafka.connect.utils.config.ValidEnum) SSLContext(javax.net.ssl.SSLContext) TrustManagerFactory(javax.net.ssl.TrustManagerFactory) KeyManagerFactory(javax.net.ssl.KeyManagerFactory) KeyStore(java.security.KeyStore) KeyStoreException(java.security.KeyStoreException) ConfigException(org.apache.kafka.common.config.ConfigException) ValidPattern(com.github.jcustenborder.kafka.connect.utils.config.ValidPattern) ValidPort(com.github.jcustenborder.kafka.connect.utils.config.ValidPort) Validator(org.apache.kafka.common.config.ConfigDef.Validator) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Preconditions(com.google.common.base.Preconditions) Pattern(java.util.regex.Pattern) ConfigException(org.apache.kafka.common.config.ConfigException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 3 with Validator

use of org.apache.kafka.common.config.ConfigDef.Validator in project connect-utils by jcustenborder.

the class Validators method validTrustManagerFactory.

/**
 * Validator is used to ensure that the TrustManagerFactory Algorithm specified is valid.
 * @return
 */
public static Validator validTrustManagerFactory() {
    return (s, o) -> {
        if (!(o instanceof String)) {
            throw new ConfigException(s, o, "Must be a string.");
        }
        String keyStoreType = o.toString();
        try {
            TrustManagerFactory.getInstance(keyStoreType);
        } catch (NoSuchAlgorithmException e) {
            ConfigException exception = new ConfigException(s, o, "Invalid Algorithm");
            exception.initCause(e);
            throw exception;
        }
    };
}
Also used : ValidEnum(com.github.jcustenborder.kafka.connect.utils.config.ValidEnum) SSLContext(javax.net.ssl.SSLContext) TrustManagerFactory(javax.net.ssl.TrustManagerFactory) KeyManagerFactory(javax.net.ssl.KeyManagerFactory) KeyStore(java.security.KeyStore) KeyStoreException(java.security.KeyStoreException) ConfigException(org.apache.kafka.common.config.ConfigException) ValidPattern(com.github.jcustenborder.kafka.connect.utils.config.ValidPattern) ValidPort(com.github.jcustenborder.kafka.connect.utils.config.ValidPort) Validator(org.apache.kafka.common.config.ConfigDef.Validator) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Preconditions(com.google.common.base.Preconditions) Pattern(java.util.regex.Pattern) ConfigException(org.apache.kafka.common.config.ConfigException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 4 with Validator

use of org.apache.kafka.common.config.ConfigDef.Validator in project connect-utils by jcustenborder.

the class Validators method validSSLContext.

/**
 * Validator is used to ensure that the TrustManagerFactory Algorithm specified is valid.
 * @return
 */
public static Validator validSSLContext() {
    return (s, o) -> {
        if (!(o instanceof String)) {
            throw new ConfigException(s, o, "Must be a string.");
        }
        String keyStoreType = o.toString();
        try {
            SSLContext.getInstance(keyStoreType);
        } catch (NoSuchAlgorithmException e) {
            ConfigException exception = new ConfigException(s, o, "Invalid Algorithm");
            exception.initCause(e);
            throw exception;
        }
    };
}
Also used : ValidEnum(com.github.jcustenborder.kafka.connect.utils.config.ValidEnum) SSLContext(javax.net.ssl.SSLContext) TrustManagerFactory(javax.net.ssl.TrustManagerFactory) KeyManagerFactory(javax.net.ssl.KeyManagerFactory) KeyStore(java.security.KeyStore) KeyStoreException(java.security.KeyStoreException) ConfigException(org.apache.kafka.common.config.ConfigException) ValidPattern(com.github.jcustenborder.kafka.connect.utils.config.ValidPattern) ValidPort(com.github.jcustenborder.kafka.connect.utils.config.ValidPort) Validator(org.apache.kafka.common.config.ConfigDef.Validator) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Preconditions(com.google.common.base.Preconditions) Pattern(java.util.regex.Pattern) ConfigException(org.apache.kafka.common.config.ConfigException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Aggregations

ValidEnum (com.github.jcustenborder.kafka.connect.utils.config.ValidEnum)4 ValidPattern (com.github.jcustenborder.kafka.connect.utils.config.ValidPattern)4 ValidPort (com.github.jcustenborder.kafka.connect.utils.config.ValidPort)4 Preconditions (com.google.common.base.Preconditions)4 KeyStore (java.security.KeyStore)4 KeyStoreException (java.security.KeyStoreException)4 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)4 Pattern (java.util.regex.Pattern)4 KeyManagerFactory (javax.net.ssl.KeyManagerFactory)4 SSLContext (javax.net.ssl.SSLContext)4 TrustManagerFactory (javax.net.ssl.TrustManagerFactory)4 Validator (org.apache.kafka.common.config.ConfigDef.Validator)4 ConfigException (org.apache.kafka.common.config.ConfigException)4