Cisco Cisco Security Manager 4.7 Guía Del Usuario
Cisco Security Manager 4.7 API Specification (Version 2.0)
OL- 32164-01
Page 234
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.6 List shared policies assigned to all devices
The following simple sample program implemented in java demonstrates a REST client that iterates over CSM’s
device inventory and lists the directly assigned shared policies on all devices. Use the following client.properties
file:
device inventory and lists the directly assigned shared policies on all devices. Use the following client.properties
file:
USER=admin
PASSWORD=admin
HOST=localhost
XML_REQUEST=<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
<csm:deviceListByCapabilityRequest xmlns:csm=\"csm\">\
<protVersion>1.0</protVersion>\
<reqId>123</reqId>\
<deviceCapability>*</deviceCapability>\
</csm:deviceListByCapabilityRequest>
XML_REQUEST1=<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
<csm:policyListByDeviceGIDRequest xmlns:csm=\"csm\">\
<protVersion>1.0</protVersion>\
<reqId>123</reqId>\
<gid>DEVICE_ID</gid>\
</csm:policyListByDeviceGIDRequest>
# Set LOGIN_REQUIRED to true if the URI supplied
# requires login to be done as a prerequisite.
LOGIN_REQUIRED=true
URI=https://localhost/nbi/configservice/getDeviceListByType
URI1=https://localhost/nbi/configservice/getPolicyListByDeviceGID
PASSWORD=admin
HOST=localhost
XML_REQUEST=<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
<csm:deviceListByCapabilityRequest xmlns:csm=\"csm\">\
<protVersion>1.0</protVersion>\
<reqId>123</reqId>\
<deviceCapability>*</deviceCapability>\
</csm:deviceListByCapabilityRequest>
XML_REQUEST1=<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
<csm:policyListByDeviceGIDRequest xmlns:csm=\"csm\">\
<protVersion>1.0</protVersion>\
<reqId>123</reqId>\
<gid>DEVICE_ID</gid>\
</csm:policyListByDeviceGIDRequest>
# Set LOGIN_REQUIRED to true if the URI supplied
# requires login to be done as a prerequisite.
LOGIN_REQUIRED=true
URI=https://localhost/nbi/configservice/getDeviceListByType
URI1=https://localhost/nbi/configservice/getPolicyListByDeviceGID
After compiling, use the following command to run the program:
Command Prompt> java RestClient <path_to_client.properties> [<uri>]
Class
RestClient.java
/**
* Sample program to collect the Shared Access Rules applied to Devices in CSM.
*/
import
java.io.*;
import
java.net.URI;
import
java.security.KeyManagementException;