Module: LogStash::Outputs::ElasticSearchJava::Shield::ClassMethods

Defined in:
lib/logstash/outputs/elasticsearch_java/shield.rb

Instance Method Summary collapse

Instance Method Details

#branch_client_optionsObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/logstash/outputs/elasticsearch_java/shield.rb', line 37

def branch_client_options
  alias_method :original_client_options, :client_options
  define_method(:client_options) do
    shield_settings = {"plugin.types" => "org.elasticsearch.shield.ShieldPlugin"}

    if @ssl
      shield_settings['shield.transport.ssl'] = "true"

      if @keystore
        shield_settings['shield.ssl.keystore.path'] = @keystore if @keystore
        shield_settings['shield.ssl.keystore.password'] = @keystore_password.value if @keystore_password
      end

      if @truststore
        shield_settings['shield.transport.ssl.truststore.path'] = @truststore if @truststore
        shield_settings['shield.transport.ssl.truststore.password'] = @truststore_password.value if @truststore_password
      end
    end

    if @user && @password
      shield_settings["shield.user"] = "#{@user}:#{@password.value}"
    end

    new_client_options = original_client_options
    new_client_options[:client_settings].merge!(shield_settings)
    new_client_options[:elasticsearch_plugins] ||= []
    new_client_options[:elasticsearch_plugins] << org.elasticsearch.shield.ShieldPlugin
    new_client_options
  end
end

#create_optionsObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/logstash/outputs/elasticsearch_java/shield.rb', line 14

def create_options
  # Enable shield SSL
  config :ssl, :validate => :boolean, :default => false

  # Use the specified JKS keystore
  config :keystore, :validate => :path

  # Set the keystore password
  config :keystore_password, :validate => :password

  # Set the truststore path
  config :truststore, :validate => :path

  # Set the truststore password
  config :truststore_password, :validate => :password

  # Shield user
  config :user, :validate => :string

  # Shield password
  config :password, :validate => :password
end