Cisco Cisco Security Manager 4.5 Guia De Especificação

Página de 217
 
 
 
  
 
Cisco Security Manager 4.4 API Specification (Version 1.1) 
 
OL- 29074-01 
Page  182
 
                            retArr.add(element.getTextContent()); 
                        } 
                    } 
 
                }
else
                    System.
out
.println(
"Some issue, Obtained HTTP status code 
:"
+sl.getStatusCode()); 
                    System.
out
.println(response); 
                    
//Do something...
 
                } 
            } 
        } 
        
return
 retArr; 
    } 
 
    
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>]"
); 
    } 
 
 
8.7 List content of a given shared policy 
 
The following simple sample program implemented in java demonstrates a REST client the lists the content of a 
firewall access rule shared policy given the name of the shared policy. Use the client.properties file as defined below 
(change shared policy name defined in the properties file appropriately) : 
 
USER=admin 
PASSWORD=admin 
HOST=localhost 
XML_REQUEST=<?xml version=\"1.0\" encoding=\"UTF-8\"?>\ 
<csm:policyConfigByNameRequest  xmlns:csm=\"csm\">\ 
   <protVersion>1.0</protVersion>\ 
   <reqId>123</reqId>\ 
   <name>ACL1</name>\ 
   <policyType>DeviceAccessRuleFirewallPolicy</policyType>\ 
</csm:policyConfigByNameRequest> 
# 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/getPolicyConfigByName 
  
 
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 get the contents of a shared policy given the shared policy name.
 
 */
 
import
 java.io.ByteArrayInputStream;