Sha256: 04300bc66cedeada7f6ba76a56cada579f8722bea8acee35cd072e4ae01ea9d1

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

module Ncrack
  class XML
    #
    # Represents a `credentials` XML element.
    #
    class Credentials

      #
      # Initializes the credentials object.
      #
      # @param [Nokogiri::XML::Node] node
      #   The XML node for the `credentials` XML element.
      #
      # @api private
      #
      def initialize(node)
        @node = node
      end

      #
      # The successfully bruteforced username.
      #
      # @return [String]
      #   The value of the `username` attribute.
      #
      def username
        @username ||= @node['username']
      end

      alias user_name username

      #
      # The successfully bruteforced password.
      #
      # @return [String]
      #   The value of the `password` attribute.
      #
      def password
        @password ||= @node['password']
      end

      #
      # Converts the credentials to a String.
      #
      # @return [String]
      #   Returns a `"username:password"` String.
      #
      def to_s
        "#{username}:#{password}"
      end

      #
      # Converts the credentials to a String.
      #
      # @return [(String, String)]
      #   Returns a tuple of the {#username} and {#password}.
      #
      def to_a
        [username, password]
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-ncrack-0.1.0 lib/ncrack/xml/credentials.rb