KSC Open API
Kaspersky Security Center API description
|
Gateway connection is a way to communicate between nodes which don't have possibility to create direct connection. Gateway connection is created with help of gateway nodes, each of those has two connections and redirect all data between them. For example it is possible to create gateway connection from OpenAPI client to Network agent through KSC Server as a gateway node; in such case OpenAPI client may make OpenAPI calls to Network agent. With help of gateway connections OpenAPI client may connect to Slave servers, Network agents and components on them. Multi-node gateway connections are also supported, so gateway connections such as OpenAPIClient->MasterServer->SlaveServer->NetworkAgent are possible.
Gateway connections may be created using GatewayConnection interface. The general scheme to create a gateway connection is following:
If 'login' method was used for authentication, then after successful authentication current connection may be used to make OpenAPI calls to target.
If Session.StartSession was called for authentication, then all calls within created session will be routed to target host.
Example1: if you want to connect to Network agent NA1, which is managed by MasterServer1:
After successful authentication this connection may be used to communicate with NetworkAgent1, for example, by calling methods of NagHstCtl, NagRdu, NagGuiCalls, NagRemoteScreen(or NagCgwHelper to recursively create a deeper gateway connection)
Example2: if you want to connect to NetworkAgent2, which is managed by SlaveServer1, and you connected to MasterServer1, where MasterServer1 is a direct master server for SlaveServer1:
After successful authentication this connection may be used to communicate with NetworkAgent2, for example, by calling methods of NagHstCtl, NagRdu, NagGuiCalls, NagRemoteScreen (or NagCgwHelper to recursively create a deeper gateway connection).
With KlAkOAPI Python package slave server can be connected as follows:
# connect to main server with basic authentication to get gateway token server_main = KlAkOAPI.AdmServer.KlAkAdmServer.Create('https://ksc-main.example.com', 'username', 'password', verify = False) # step 1: get slave server location cgwHelper = KlAkOAPI.CgwHelper.KlAkCgwHelper(server_main) slaveServerLocation = cgwHelper.GetSlaveServerLocation(nChildServerId).RetVal() # step 2: build locations list arrLocation = [KlAkOAPI.Params.paramParams(slaveServerLocation)] # step 3: prepare gateway connection to main server with locations array built on previous step gatewayConnection = KlAkOAPI.GatewayConnection.KlAkGatewayConnection(server_main) token_on_slave = gatewayConnection.PrepareGatewayConnection(arrLocation).OutPar('wstrAuthKey') server_main.Disconnect() # connect slave server server = KlAkOAPI.AdmServer.KlAkAdmServer.CreateGateway('https://ksc-main.example.com', token_on_slave, verify = False)
Nagent can be connected as follows:
# connect to main server with basic authentication to get gateway token server_main = KlAkOAPI.AdmServer.KlAkAdmServer.Create('https://ksc-main.example.com', 'username', 'password', verify = False) # step 1: get nagent location cgwHelper = KlAkOAPI.CgwHelper.KlAkCgwHelper(server_main) nagentLocation = cgwHelper.GetNagentLocation(wsHostName).RetVal() # step 2: build locations list arrLocation = [KlAkOAPI.Params.paramParams(nagentLocation)] # step 3: prepare gateway connection to main server with locations array built on previous step gatewayConnection = KlAkOAPI.GatewayConnection.KlAkGatewayConnection(server_main) token_on_nagent = gatewayConnection.PrepareGatewayConnection(arrLocation).OutPar('wstrAuthKey') server_main.Disconnect() # connect nagent server = KlAkOAPI.AdmServer.KlAkAdmServer.CreateGateway('https://ksc-main.example.com', token_on_slave, verify = False)