Class: Vertica::Protocol::Password
- Inherits:
-
FrontendMessage
- Object
- Message
- FrontendMessage
- Vertica::Protocol::Password
- Defined in:
- lib/vertica/protocol/frontend/password.rb
Instance Method Summary collapse
- #encoded_password ⇒ Object
-
#initialize(password, auth_method: Vertica::Protocol::Authentication::CLEARTEXT_PASSWORD, salt: nil, user: nil) ⇒ Password
constructor
A new instance of Password.
- #message_body ⇒ Object
Methods inherited from FrontendMessage
Methods inherited from Message
Constructor Details
#initialize(password, auth_method: Vertica::Protocol::Authentication::CLEARTEXT_PASSWORD, salt: nil, user: nil) ⇒ Password
Returns a new instance of Password.
6 7 8 9 |
# File 'lib/vertica/protocol/frontend/password.rb', line 6 def initialize(password, auth_method: Vertica::Protocol::Authentication::CLEARTEXT_PASSWORD, salt: nil, user: nil) @password = password @auth_method, @salt, @user = auth_method, salt, user end |
Instance Method Details
#encoded_password ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/vertica/protocol/frontend/password.rb', line 11 def encoded_password case @auth_method when Vertica::Protocol::Authentication::CLEARTEXT_PASSWORD @password when Vertica::Protocol::Authentication::CRYPT_PASSWORD @password.crypt(@salt) when Vertica::Protocol::Authentication::MD5_PASSWORD require 'digest/md5' @password = Digest::MD5.hexdigest("#{@password}#{@user}") @password = Digest::MD5.hexdigest("#{@password}#{@salt}") @password = "md5#{@password}" else raise ArgumentError.new("unsupported authentication method: #{@auth_method}") end end |
#message_body ⇒ Object
27 28 29 |
# File 'lib/vertica/protocol/frontend/password.rb', line 27 def [encoded_password].pack('Z*') end |