Class: Qualys::Auth

Inherits:
Api
  • Object
show all
Defined in:
lib/qualys/auth.rb

Defined Under Namespace

Classes: InvalidLogin

Constant Summary

Constants inherited from Api

Qualys::Api::PRODUCTION_ENDPOINT

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Api

api_get, api_post

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/qualys/auth.rb', line 5

def name
  @name
end

Class Method Details

.loginObject

Do Login



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/qualys/auth.rb', line 8

def self.

  # Request a login
  response = self.api_post('session/', {
      :body => {
        :action => 'login', 
        :username => Qualys::Config.username, 
        :password => Qualys::Config.password
      }
    })
   
  # set the session key
  Qualys::Config.session_key = response.header['Set-Cookie']
  true
 
end

.logoutObject

Set Logout



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/qualys/auth.rb', line 26

def self.logout

  # Request a login
  response = self.api_post('session/', {
      :body => {
        :action => 'logout', 
      }
    })
   
  # set the session key
  Qualys::Config.session_key = nil
  true

end