本文整理匯總了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;
}