# File lib/cloudservers/authentication.rb, line 10
    def initialize(connection)
      path = '/v1.0'
      hdrhash = { "X-Auth-User" => connection.authuser, "X-Auth-Key" => connection.authkey }
      begin
        server = Net::HTTP::Proxy(connection.proxy_host, connection.proxy_port).new(connection.auth_host,connection.auth_port)
        if connection.auth_scheme == "https"
          server.use_ssl = true
          server.verify_mode = OpenSSL::SSL::VERIFY_NONE
        end
        server.start
      rescue
        raise CloudServers::Exception::Connection, "Unable to connect to #{server}"
      end
      response = server.get(path,hdrhash)
      if (response.code == "204")
        connection.authtoken = response["x-auth-token"]
        connection.svrmgmthost = URI.parse(response["x-server-management-url"]).host
        connection.svrmgmtpath = URI.parse(response["x-server-management-url"]).path
        # Force the path into the v1.0 URL space
        connection.svrmgmtpath.sub!(/\/.*?\//, '/v1.0/')
        connection.svrmgmtport = URI.parse(response["x-server-management-url"]).port
        connection.svrmgmtscheme = URI.parse(response["x-server-management-url"]).scheme
        connection.authok = true
      else
        connection.authtoken = false
        raise CloudServers::Exception::Authentication, "Authentication failed with response code #{response.code}"
      end
      server.finish
    end