Cisco Cisco Security Manager 4.0 仕様ガイド
![Cisco](https://files.manualsbrain.com/attachments/7380d0050044647c30f5c24bbbf5d0c0b6d9bb84/common/fit/150/50/faa183d287233c52228cfea3dbc2a127fe780f60564fcb0955d9c3d1cd23/brand_logo.png)
Cisco Security Manager 4.4 API Specification (Version 1.1)
OL- 29074-01
Page 160
static
{
initSSL();
}
}
private
static
void
initSSL() {
SSLContext sslContext =
null
;
try
{
sslContext = SSLContext.getInstance(
"SSL"
);
sslContext.init(
null
,
new
TrustManager[] {
new
X509TrustManager() {
public
X509Certificate[] getAcceptedIssuers() {
System.
out
.println(
"getAcceptedIssuers ============="
);
return
null
;
}
public
void
checkClientTrusted(X509Certificate[] certs, String authType) {
System.
out
.println(
"checkClientTrusted ============="
);
}
public
void
checkServerTrusted(X509Certificate[] certs, String authType) {
System.
out
.println(
"checkServerTrusted ============="
);
}
}},
}},
new
SecureRandom());
SSLSocketFactory sf =
new
SSLSocketFactory(sslContext);
Scheme httpsScheme =
new
Scheme(
"https"
, 443, sf);
SchemeRegistry schemeRegistry =
new
SchemeRegistry();
schemeRegistry.register(httpsScheme);
HttpParams params =
HttpParams params =
new
BasicHttpParams();
ClientConnectionManager cm =
new
ThreadSafeClientConnManager(params, schemeRegistry);
httpclient
=
new
DefaultHttpClient(cm, params);
}
catch
(NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
catch
(KeyManagementException e) {
e.printStackTrace();
}
}
}
}
/**
* This method will send the XML payload and return the XML response as a string.
*
@param
uri
*
@param
host
*
@param
isCookieNeeded
*
@return
*
@throws
IOException
*
@throws
ClientProtocolException
*/
public
void
doPost (URI uri, String payload, String host,
boolean
isCookieNeeded)
throws
Exception {
HttpResponse httpresponse =
HttpResponse httpresponse =
null
;
HttpPost httppost =
new
HttpPost (uri);
if
(isCookieNeeded) {
httpclient
.setCookieStore(
ascookie
);
}
httppost.addHeader(
httppost.addHeader(
"Content-Type"
,
"text/xml"
);
StringEntity strEntity =
new
StringEntity (payload,
"UTF-8"
);
httppost.setEntity(strEntity);
System.
System.
out
.println(
"Calling : "
+uri.toString());
httpresponse =
httpclient
.execute(httppost);
ascookie
=
httpclient
.getCookieStore();
processResponse(httpresponse);
}
}