Fakesslcertificatesocketfactory Class - VMware VCENTER CHARGEBACK 1.5 - API Manual

Vcenter chargeback api programming guide
Hide thumbs Also See for VCENTER CHARGEBACK 1.5 - API:
Table of Contents

Advertisement

FakeSSLCertificateSocketFactory Class

The code examples use the following class to access resources over the HTTPS protocol. 
/**
* Helper class to accept self-signed certificate.
*/
public class FakeSSLCertificateSocketFactory implements SecureProtocolSocketFactory {
private SSLContext sslContext;
public FakeSSLCertificateSocketFactory() throws NoSuchAlgorithmException,
sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, new TrustManager[] {new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] ax509certificate, String s) throws
// Allow.
}
@Override
public void checkServerTrusted(X509Certificate[] ax509certificate, String s) throws
// Allow.
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
}}, null);
}
@Override
public Socket createSocket(String s, int i) throws IOException, UnknownHostException {
return sslContext.getSocketFactory().createSocket(s, i);
}
@Override
public Socket createSocket(String s, int i, InetAddress inetaddress, int j) throws
return sslContext.getSocketFactory().createSocket(s, i, inetaddress, j);
}
@Override
public Socket createSocket(String s, int i, InetAddress inetaddress, int j,
UnknownHostException, ConnectTimeoutException {
return sslContext.getSocketFactory().createSocket(s, i, inetaddress, j);
}
@Override
public Socket createSocket(Socket socket, String s, int i, boolean flag) throws IOException,
return sslContext.getSocketFactory().createSocket(socket, s, i, flag);
}
}
VMware, Inc.
KeyManagementException {
CertificateException {
CertificateException {
IOException, UnknownHostException {
HttpConnectionParams httpconnectionparams) throws IOException,
UnknownHostException {
Chapter 2 Understanding the Workflow
13

Advertisement

Table of Contents
loading

Table of Contents