Class: Vertica::Messages::Password
- Inherits:
-
FrontendMessage
- Object
- Message
- FrontendMessage
- Vertica::Messages::Password
- Defined in:
- lib/vertica/messages/frontend_messages/password.rb
Instance Method Summary collapse
- #encoded_password ⇒ Object
-
#initialize(password, auth_method = nil, options = {}) ⇒ Password
constructor
A new instance of Password.
- #to_bytes ⇒ Object
Methods inherited from Message
Constructor Details
#initialize(password, auth_method = nil, options = {}) ⇒ Password
Returns a new instance of Password.
7 8 9 10 11 |
# File 'lib/vertica/messages/frontend_messages/password.rb', line 7 def initialize(password, auth_method = nil, = {}) @password = password @auth_method = auth_method || Vertica::Messages::Authentication::CLEARTEXT_PASSWORD @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 [encoded_password].pack('Z*') end |