@Override public Map<String,String> validate( Map<String,String> rawConfig, Consumer<String> warningConsumer ) throws InvalidSettingException { Map<String,String> result = s.validate( rawConfig, warningConsumer ); assertEncryption( name, s, rawConfig ); return result; } };
@Override @Nonnull public Map<String,String> validate( @Nonnull Map<String,String> rawConfig, @Nonnull Consumer<String> warningConsumer ) throws InvalidSettingException { final HashMap<String,String> result = new HashMap<>(); ownedEntries( rawConfig ).forEach( s -> result.putAll( getSettingFor( s.getKey(), rawConfig ) .orElseThrow( () -> new InvalidSettingException( format( "Invalid connector setting: %s", s.getKey() ) ) ) .validate( rawConfig, warningConsumer ) ) ); warnAboutDeprecatedConnectors( result, warningConsumer ); return result; }
@Nonnull private static Map<String,String> assertEncryption( @Nonnull String name, @Nonnull Setting<?> setting, @Nonnull Map<String,String> rawConfig ) throws InvalidSettingException { Map<String,String> result = setting.validate( rawConfig, nullConsumer ); Optional<?> encryption = Optional.ofNullable( setting.apply( rawConfig::get ) ); if ( "https".equalsIgnoreCase( name ) ) { if ( encryption.isPresent() && encryption.get() != TLS ) { throw new InvalidSettingException( format( "'%s' is only allowed to be '%s'; not '%s'", setting.name(), TLS.name(), encryption.get() ) ); } } else if ( "http".equalsIgnoreCase( name ) ) { if ( encryption.isPresent() && encryption.get() != NONE ) { throw new InvalidSettingException( format( "'%s' is only allowed to be '%s'; not '%s'", setting.name(), NONE.name(), encryption.get() ) ); } } return result; }
@Override public Map<String,String> validate( Map<String,String> rawConfig, Consumer<String> warningConsumer ) throws InvalidSettingException { Map<String,String> result = s.validate( rawConfig, warningConsumer ); assertEncryption( name, s, rawConfig ); return result; } };
@Override @Nonnull public Map<String,String> validate( @Nonnull Map<String,String> rawConfig, @Nonnull Consumer<String> warningConsumer ) throws InvalidSettingException { final HashMap<String,String> result = new HashMap<>(); ownedEntries( rawConfig ).forEach( s -> result.putAll( getSettingFor( s.getKey(), rawConfig ) .orElseThrow( () -> new InvalidSettingException( format( "Invalid connector setting: %s", s.getKey() ) ) ) .validate( rawConfig, warningConsumer ) ) ); warnAboutDeprecatedConnectors( result, warningConsumer ); return result; }
@Nonnull private static Map<String,String> assertEncryption( @Nonnull String name, @Nonnull Setting<?> setting, @Nonnull Map<String,String> rawConfig ) throws InvalidSettingException { Map<String,String> result = setting.validate( rawConfig, nullConsumer ); Optional<?> encryption = Optional.ofNullable( setting.apply( rawConfig::get ) ); if ( "https".equalsIgnoreCase( name ) ) { if ( encryption.isPresent() && encryption.get() != TLS ) { throw new InvalidSettingException( format( "'%s' is only allowed to be '%s'; not '%s'", setting.name(), TLS.name(), encryption.get() ) ); } } else if ( "http".equalsIgnoreCase( name ) ) { if ( encryption.isPresent() && encryption.get() != NONE ) { throw new InvalidSettingException( format( "'%s' is only allowed to be '%s'; not '%s'", setting.name(), NONE.name(), encryption.get() ) ); } } return result; }