Cisco Cisco Security Manager 4.7 Guía Del Usuario

Descargar
Página de 290
 
 
 
  
 
Cisco Security Manager 4.7 API Specification (Version 2.0) 
 
OL- 32164-01 
Page  243
 
                    String login_payload = 
"<?xml version=\"1.0\" encoding=\"UTF-
8\"?><csm:loginRequest  
xmlns:csm=\"csm\"><protVersion>1.0</protVersion><reqId>123</reqId><username>"
+username+
"</usernam
e><password>"
+password+
"</password></csm:loginRequest>"
                    client.doPost(
new
 URI(
"https://"
+host+
"/nbi/login"
), login_payload, host, 
false
); 
                } 
                
//Step 2:
 
                client.doPost(uri, payload, host, 
true
); 
            } 
        }
catch
(Exception ex){ 
            System.
out
.println(ex.getMessage()); usage();} 
    } 
 
    
public
 
static
 
void
 usage(){ 
        System.
out
.println(
"Please check the data entered in the properties file"
); 
        System.
out
.println(
"Usage : "
); 
        System.
out
.println(
"java RestClient <path_to_client.properties> [<uri>]"
); 
    } 
 
9.8 Subscribing to change notifications – Deployment, OOB 
 
The following simple sample program implemented in java demonstrates a REST client that registers for change 
notifications from CSM to receive Deployment and Out of Band (OOB) events. Please note that to receive change 
notifications, the client registers a specific syslog service (IP and Port) to which CSM will sent ‘asynchronous’ 
notifications
. To see the actual notifications, please use any open source Syslog server or implement a simple UDP 
listener at the specified IP/Port (see SyslogServer element below) to list the notification content.  
 
Use the client.properties file as listed below: 
 
USER=admin 
PASSWORD=admin 
HOST=localhost 
XML_REQUEST=<?xml version=\"1.0\" encoding=\"UTF-8\"?>\ 
<csm:eventSubRequest xmlns:csm=\"csm\">\ 
   <op>add</op>\ 
   <subscriptionId>123454</subscriptionId>\ 
   <eventFilterItem>\ 
   <filterEventType>syslog</filterEventType>\ 
   <filterEventFormat>xml</filterEventFormat>\ 
   <filterEventCategory>configChange</filterEventCategory>\ 
   </eventFilterItem>\ 
   <syslogServer>\ 
       <port>514</port>\ 
       <destAddress>10.10.10.10</destAddress>\ 
   </syslogServer>\ 
</csm:eventSubRequest> 
 
# Set LOGIN_REQUIRED to true if the URI supplied  
# requires login to be done as a prerequisite. 
LOGIN_REQUIRED=true 
URI=https://localhost/nbi/eventservice/eventSubscription
 
 
 
After compiling, use the following command to run the program: