Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Anchor
_Toc341972300
_Toc341972300
Create a DualShield Class

Code Block
languagepy
class DualShield:

...



headers = {"Content-Type": "application/json"}

...


app_context = "/das5/rest/"

...



def _init_(self, host, port, keyFile, certFile):

...


self.keyFile = keyFile

...


self.certFile = certFile

...


self.conn = HTTPSConnection(host, port, keyFile, certFile)

...



def execute(self, method, params):

...


data = json.dumps(params)

...


self.conn.request("POST", self.app_context + method, data, self.headers)

...


response = self.conn.getresponse()

...


data = response.read()

...


return json.loads(data.decode('utf-8'))

...



def close(self):

...


self.conn.close()

...


self.conn = None


Anchor
_Toc341972301
_Toc341972301
Initialize DualShield Variables

Code Block
languagepy
host = 'dualshield.deepnetlabs.com'

...


port = 8071

...


keyFile = 'apikey.pem'

...


certFile = 'apicert.pem'

...


domainname='deepnetlabs.com'

Replace the values of these variable with your own.
host: the host name (FQDN) of your DualShield server
port: the port number of the DualShield authentication server
keyFile: Your agent's private key file
certFile: Your agent's certificate file
domainname: The name of the domain that your agent is connected to

Anchor
_Toc341972302
_Toc341972302
Create a Test Class

Code Block
languagepy
class TestDualShield(unittest.TestCase):

...



def setUp(self):

...


self.auth=DualShield(host, port, keyFile, certFile)

...



def tearDown(self):

...


self.auth.close()


Anchor
_Toc341972303
_Toc341972303
Check the Connection

...