Class: Vertica::Messages::Password
Instance Method Summary
collapse
Methods inherited from Message
message_id, #message_string
Constructor Details
#initialize(password, auth_method = nil, options = {}) ⇒ Password
7
8
9
10
11
|
# File 'lib/vertica/messages/frontend_messages/password.rb', line 7
def initialize(password, auth_method = nil, options = {})
@password = password
@auth_method = auth_method || Vertica::Messages::Authentication::CLEARTEXT_PASSWORD
@options = options
end
|
Instance Method Details
#encoded_password ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/vertica/messages/frontend_messages/password.rb', line 13
def encoded_password
case @auth_method
when Vertica::Messages::Authentication::CLEARTEXT_PASSWORD
@password
when Vertica::Messages::Authentication::CRYPT_PASSWORD
@password.crypt(@options[:salt])
when Vertica::Messages::Authentication::MD5_PASSWORD
require 'digest/md5'
@password = Digest::MD5.hexdigest(@password + @options[:user])
@password = Digest::MD5.hexdigest(@password + @options[:salt])
@password = 'md5' + @password
else
raise ArgumentError.new("unsupported authentication method: #{@auth_method}")
end
end
|
#to_bytes ⇒ Object
29
30
31
|
# File 'lib/vertica/messages/frontend_messages/password.rb', line 29
def to_bytes
message_string [encoded_password].pack('Z*')
end
|