本文整理汇总了Java中org.apache.http.conn.ssl.SSLSocketFactory.STRICT_HOSTNAME_VERIFIER属性的典型用法代码示例。如果您正苦于以下问题:Java SSLSocketFactory.STRICT_HOSTNAME_VERIFIER属性的具体用法?Java SSLSocketFactory.STRICT_HOSTNAME_VERIFIER怎么用?Java SSLSocketFactory.STRICT_HOSTNAME_VERIFIER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.http.conn.ssl.SSLSocketFactory
的用法示例。
在下文中一共展示了SSLSocketFactory.STRICT_HOSTNAME_VERIFIER属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
public static void main(String... args) throws Exception {
Set<String> policies = new HashSet<String>();
for (String arg : args) {
arg = Strings.trimToNull(arg);
if (arg != null) {
if (arg.equals(CONFIDENTIALITY) || arg.equals(CLIENT_AUTHENTICATION) || arg.equals(HELP)) {
policies.add(arg);
} else {
LOGGER.error(MAVEN_USAGE);
throw new Exception(MAVEN_USAGE);
}
}
}
if (policies.contains(HELP)) {
LOGGER.info(MAVEN_USAGE);
} else {
final String scheme;
final int port;
if (policies.contains(CONFIDENTIALITY)) {
scheme = "https";
port = getPort(8443);
SSLContext sslcontext = SSLContext.getInstance("TLS");
sslcontext.init(null, null, null);
SSLSocketFactory sf = new SSLSocketFactory(sslcontext, SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
Scheme https = new Scheme(scheme, port, sf);
SchemeRegistry sr = new SchemeRegistry();
sr.register(https);
} else {
scheme = "http";
port = getPort(8080);
}
Element assertion = policies.contains(CLIENT_AUTHENTICATION) ? getAssertion() : null;
invokeWorkService(scheme, port, getContext(), assertion);
}
}
示例2: main
public static void main(String... args) throws Exception {
Set<String> policies = new HashSet<String>();
for (String arg : args) {
arg = Strings.trimToNull(arg);
if (arg != null) {
if (arg.equals(CONFIDENTIALITY) || arg.equals(CLIENT_AUTHENTICATION) || arg.equals(HELP)) {
policies.add(arg);
} else {
LOGGER.error(MAVEN_USAGE);
throw new Exception(MAVEN_USAGE);
}
}
}
if (policies.contains(HELP)) {
LOGGER.info(MAVEN_USAGE);
} else {
final String scheme;
final int port;
if (policies.contains(CONFIDENTIALITY)) {
scheme = "https";
port = getPort(8443);
SSLContext sslcontext = SSLContext.getInstance("TLS");
sslcontext.init(null, null, null);
SSLSocketFactory sf = new SSLSocketFactory(sslcontext, SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
Scheme https = new Scheme(scheme, port, sf);
SchemeRegistry sr = new SchemeRegistry();
sr.register(https);
} else {
scheme = "http";
port = getPort(8080);
}
String username = policies.contains(CLIENT_AUTHENTICATION) ? "kermit" : "misspiggy";
invokeWorkService(scheme, port, getContext(), username);
}
}
示例3: main
public static void main(String... args) throws Exception {
Set<String> policies = new HashSet<String>();
for (String arg : args) {
arg = Strings.trimToNull(arg);
if (arg != null) {
if (arg.equals(CONFIDENTIALITY) || arg.equals(CLIENT_AUTHENTICATION) || arg.equals(HELP)) {
policies.add(arg);
} else {
LOGGER.error(MAVEN_USAGE);
throw new Exception(MAVEN_USAGE);
}
}
}
if (policies.contains(HELP)) {
LOGGER.info(MAVEN_USAGE);
} else {
final String scheme;
final int port;
if (policies.contains(CONFIDENTIALITY)) {
scheme = "https";
port = getPort(8443);
SSLContext sslcontext = SSLContext.getInstance("TLS");
sslcontext.init(null, null, null);
SSLSocketFactory sf = new SSLSocketFactory(sslcontext, SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
Scheme https = new Scheme(scheme, port, sf);
SchemeRegistry sr = new SchemeRegistry();
sr.register(https);
} else {
scheme = "http";
port = getPort(8080);
}
String[] userPass = policies.contains(CLIENT_AUTHENTICATION) ? new String[] { "kermit", "the-frog-1" } : null;
invokeWorkService(scheme, port, getContext(), userPass);
}
}
示例4: main
public static void main(String... args) throws Exception {
Set<String> policies = new HashSet<String>();
for (String arg : args) {
arg = Strings.trimToNull(arg);
if (arg != null) {
if (arg.equals(CONFIDENTIALITY) || arg.equals(SIGNENCRYPT) || arg.equals(HELP)) {
policies.add(arg);
} else {
LOGGER.error(MAVEN_USAGE);
throw new Exception(MAVEN_USAGE);
}
}
}
if (policies.contains(HELP)) {
LOGGER.info(MAVEN_USAGE);
} else {
final String scheme;
final int port;
if (policies.contains(CONFIDENTIALITY)) {
scheme = "https";
port = getPort(8443);
SSLContext sslcontext = SSLContext.getInstance("TLS");
sslcontext.init(null, null, null);
SSLSocketFactory sf = new SSLSocketFactory(sslcontext, SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
Scheme https = new Scheme(scheme, port, sf);
SchemeRegistry sr = new SchemeRegistry();
sr.register(https);
} else {
scheme = "http";
port = getPort(8080);
}
boolean signencrypt = policies.contains(SIGNENCRYPT);
invokeWorkService(scheme, port, getContext(), signencrypt);
}
}
示例5: main
public static void main(String... args) throws Exception {
Set<String> policies = new HashSet<String>();
for (String arg : args) {
arg = Strings.trimToNull(arg);
if (arg != null) {
if (arg.equals(CONFIDENTIALITY) || arg.equals(CLIENT_AUTHENTICATION) || arg.equals(HELP)) {
policies.add(arg);
} else {
LOGGER.error(MAVEN_USAGE);
throw new Exception(MAVEN_USAGE);
}
}
}
if (policies.contains(HELP)) {
LOGGER.info(MAVEN_USAGE);
} else {
final String scheme;
final int port;
if (policies.contains(CONFIDENTIALITY)) {
scheme = "https";
port = getPort(8443);
SSLContext sslcontext = SSLContext.getInstance("TLS");
sslcontext.init(null, null, null);
SSLSocketFactory sf = new SSLSocketFactory(sslcontext, SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
Scheme https = new Scheme(scheme, port, sf);
SchemeRegistry sr = new SchemeRegistry();
sr.register(https);
} else {
scheme = "http";
port = getPort(8080);
}
String binarySecurityToken = policies.contains(CLIENT_AUTHENTICATION) ? new StringPuller().pull("/xml/BinarySecurityToken.xml") : null;
invokeWorkService(scheme, port, getContext(), binarySecurityToken);
}
}
示例6: createHttpClient
/**
* Creates a new HttpClient object using the specified AWS
* ClientConfiguration to configure the client.
*
* @param config
* Client configuration options (ex: proxy settings, connection
* limits, etc).
*
* @return The new, configured HttpClient.
*/
@SuppressWarnings("deprecation")
public HttpClient createHttpClient(ClientConfiguration config) {
/* Set HTTP client parameters */
HttpParams httpClientParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpClientParams, config.getConnectionTimeout());
HttpConnectionParams.setSoTimeout(httpClientParams, config.getSocketTimeout());
HttpConnectionParams.setStaleCheckingEnabled(httpClientParams, true);
HttpConnectionParams.setTcpNoDelay(httpClientParams, true);
int socketSendBufferSizeHint = config.getSocketBufferSizeHints()[0];
int socketReceiveBufferSizeHint = config.getSocketBufferSizeHints()[1];
if (socketSendBufferSizeHint > 0 || socketReceiveBufferSizeHint > 0) {
HttpConnectionParams.setSocketBufferSize(httpClientParams,
Math.max(socketSendBufferSizeHint, socketReceiveBufferSizeHint));
}
PoolingClientConnectionManager connectionManager = ConnectionManagerFactory
.createPoolingClientConnManager(config, httpClientParams);
SdkHttpClient httpClient = new SdkHttpClient(connectionManager, httpClientParams);
if(config.getMaxErrorRetry() > 0)
httpClient.setHttpRequestRetryHandler(SdkHttpRequestRetryHandler.Singleton);
// httpClient.setRedirectStrategy(new LocationHeaderNotRequiredRedirectStrategy());
try {
Scheme http = new Scheme("http", PlainSocketFactory.getSocketFactory(), 80);
SSLSocketFactory sf = new SSLSocketFactory(SSLContext.getDefault(),
SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
Scheme https = new Scheme("https", sf, 443);
SchemeRegistry sr = connectionManager.getSchemeRegistry();
sr.register(http);
sr.register(https);
} catch (NoSuchAlgorithmException e) {
throw new SCSClientException("Unable to access default SSL context", e);
}
// /*
// * If SSL cert checking for endpoints has been explicitly disabled,
// * register a new scheme for HTTPS that won't cause self-signed certs to
// * error out.
// */
// if (System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY) != null) {
Scheme sch = new Scheme("https", 443, new TrustingSocketFactory());
httpClient.getConnectionManager().getSchemeRegistry().register(sch);
// }
/* Set proxy if configured */
String proxyHost = config.getProxyHost();
int proxyPort = config.getProxyPort();
if (proxyHost != null && proxyPort > 0) {
// AmazonHttpClient.log.info("Configuring Proxy. Proxy Host: " + proxyHost + " " + "Proxy Port: " + proxyPort);
HttpHost proxyHttpHost = new HttpHost(proxyHost, proxyPort);
httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxyHttpHost);
String proxyUsername = config.getProxyUsername();
String proxyPassword = config.getProxyPassword();
String proxyDomain = config.getProxyDomain();
String proxyWorkstation = config.getProxyWorkstation();
if (proxyUsername != null && proxyPassword != null) {
httpClient.getCredentialsProvider().setCredentials(
new AuthScope(proxyHost, proxyPort),
new NTCredentials(proxyUsername, proxyPassword, proxyWorkstation, proxyDomain));
}
}
return httpClient;
}