本文整理汇总了Java中com.sun.jersey.client.urlconnection.HTTPSProperties类的典型用法代码示例。如果您正苦于以下问题:Java HTTPSProperties类的具体用法?Java HTTPSProperties怎么用?Java HTTPSProperties使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HTTPSProperties类属于com.sun.jersey.client.urlconnection包,在下文中一共展示了HTTPSProperties类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hostIgnoringClient
import com.sun.jersey.client.urlconnection.HTTPSProperties; //导入依赖的package包/类
/**
* Create a client which trust any HTTPS server
*
* @return
*/
public static Client hostIgnoringClient() {
try {
SSLContext sslcontext = SSLContext.getInstance("TLS");
sslcontext.init(null, null, null);
DefaultClientConfig config = new DefaultClientConfig();
Map<String, Object> properties = config.getProperties();
HTTPSProperties httpsProperties = new HTTPSProperties(new HostnameVerifier() {
@Override
public boolean verify(String s, SSLSession sslSession) {
return true;
}
}, sslcontext);
properties.put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, httpsProperties);
// config.getClasses().add( JacksonJsonProvider.class );
return Client.create(config);
} catch (KeyManagementException | NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
示例2: initSSL
import com.sun.jersey.client.urlconnection.HTTPSProperties; //导入依赖的package包/类
private void initSSL(ClientConfig config) throws Exception {
log("* Init SSL connection ...");
sslContext = SSLContext.getInstance("SSL");
tm = createTrustManager();
sslContext.init(null, new TrustManager[] {tm}, null);
config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
new HTTPSProperties(createHostnameVerifier(), sslContext));
SSLSocketFactory factory = sslContext.getSocketFactory();
URL url = new URL(server);
String host = url.getHost();
int port = url.getPort();
log(" -> Opening connection to " + host + ":" + port + "...");
SSLSocket socket = (SSLSocket) factory.createSocket(host, port);
socket.setSoTimeout(10000);
log(" -> Starting SSL handshake...");
socket.startHandshake();
socket.close();
log(" -> No errors, certificate is already trusted");
}
示例3: getClientConfig
import com.sun.jersey.client.urlconnection.HTTPSProperties; //导入依赖的package包/类
private ClientConfig getClientConfig(boolean tlsEnabled, boolean hostnameVerificationEnabled)
throws NoSuchAlgorithmException {
ClientConfig clientConfig = new DefaultClientConfig();
if (tlsEnabled) {
HostnameVerifier verifier = hostnameVerificationEnabled ?
HttpsURLConnection.getDefaultHostnameVerifier() : ALLOW_ALL_HOSTNAME_VERIFIER;
clientConfig.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
new HTTPSProperties(verifier, SSLContext.getDefault()));
}
return clientConfig;
}
示例4: getOperationsList
import com.sun.jersey.client.urlconnection.HTTPSProperties; //导入依赖的package包/类
/**
* Fetches the operations list (list of changes) from the remote repository.
*
* @param remoteRegistry
* harvested registry.
* @return list of operations fetched from the registry.
* @throws UniformInterfaceException
* if remote repository's reply have unexpected format.
*/
private Operations getOperationsList(RemoteRegistry remoteRegistry)
throws UniformInterfaceException {
ClientConfig config = new DefaultClientConfig();
config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
new HTTPSProperties(getHostnameVerifier(), getSSLContext()));
Client client = Client.create(config);
client.addFilter(new HTTPBasicAuthFilter("test", "test"));
WebResource service = client.resource(getURI(remoteRegistry));
service.addFilter(new HTTPBasicAuthFilter("test", "test"));
if (remoteRegistry.getLatestHarvestDate() != null) {
service = service.queryParam("from", remoteRegistry.getLatestHarvestDate().toString());
}
return service.accept(MediaType.APPLICATION_XML).get(Operations.class);
}
示例5: initClient
import com.sun.jersey.client.urlconnection.HTTPSProperties; //导入依赖的package包/类
private Client initClient(Context context) {
final Boolean skipSsl = context.getBoolean(CONF_SKIP_SSL, Boolean.FALSE);
if (skipSsl) {
ClientConfig config = new DefaultClientConfig(); // SSL configuration
// SSL configuration
config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
new com.sun.jersey.client.urlconnection.HTTPSProperties(getHostnameVerifier(), getSSLContext()));
return Client.create(config);
} else {
return new Client();
}
}
示例6: getClientConfig
import com.sun.jersey.client.urlconnection.HTTPSProperties; //导入依赖的package包/类
@Override
protected ClientConfig getClientConfig() {
ClientConfig clientConfig = super.getClientConfig();
/* Adding HTTPS-specific properties to config */
clientConfig.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, getHttpsProperties());
return clientConfig;
}
示例7: createClient
import com.sun.jersey.client.urlconnection.HTTPSProperties; //导入依赖的package包/类
private static Client createClient() {
ClientConfig config = new DefaultClientConfig();
SSLContext context = Ssl.createContext();
if (context != null) {
config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
new HTTPSProperties(HttpsURLConnection.getDefaultHostnameVerifier(), context));
}
Client client = Client.create(config);
client.setChunkedEncodingSize(1024 * 100); // 100kb
return client;
}
示例8: getHttpsProperties
import com.sun.jersey.client.urlconnection.HTTPSProperties; //导入依赖的package包/类
private HTTPSProperties getHttpsProperties() {
return new HTTPSProperties(getHostnameVerifier(), getSslContext());
}