本文整理了Java中javax.net.ssl.SSLSocketFactory.getDefault()
方法的一些代码示例,展示了SSLSocketFactory.getDefault()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SSLSocketFactory.getDefault()
方法的具体详情如下:
包路径:javax.net.ssl.SSLSocketFactory
类名称:SSLSocketFactory
方法名:getDefault
[英]Returns the default SSLSocketFactory instance. The default is defined by the security property 'ssl.SocketFactory.provider'.
[中]返回默认的SSLSocketFactory实例。默认值由安全属性的ssl定义。袜子工厂。提供者'。
代码示例来源:origin: jenkinsci/jenkins
/**
* @see SecureProtocolSocketFactory#createSocket(java.lang.String,int)
*/
public Socket createSocket(String host, int port)
throws IOException, UnknownHostException {
return SSLSocketFactory.getDefault().createSocket(
host,
port
);
}
代码示例来源:origin: knowm/XChange
private SSLSocketFactory getDefaultFactory() {
return (SSLSocketFactory) SSLSocketFactory.getDefault();
}
代码示例来源:origin: org.postgresql/postgresql
public DefaultJavaSSLFactory(Properties info) {
_factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* @see SecureProtocolSocketFactory#createSocket(java.net.Socket,java.lang.String,int,boolean)
*/
public Socket createSocket(
Socket socket,
String host,
int port,
boolean autoClose)
throws IOException, UnknownHostException {
return ((SSLSocketFactory) SSLSocketFactory.getDefault()).createSocket(
socket,
host,
port,
autoClose
);
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* @see SecureProtocolSocketFactory#createSocket(java.lang.String,int)
*/
public Socket createSocket(String host, int port)
throws IOException, UnknownHostException {
return SSLSocketFactory.getDefault().createSocket(
host,
port
);
}
代码示例来源:origin: cSploit/android
public ProxyThread(Socket socket, OnRequestListener listener, ArrayList<Proxy.ProxyFilter> filters, String hostRedirection, int portRedirection) throws IOException{
super("ProxyThread");
mSocket = socket;
mWriter = null;
mReader = mSocket.getInputStream();
mRequestListener = listener;
mFilters = filters;
mHostRedirect = hostRedirection;
mPortRedirect = portRedirection;
mSocketFactory = SSLSocketFactory.getDefault();
}
代码示例来源:origin: wildfly/wildfly
public StompConnection(String dest, String userid, String password, boolean reconnect, boolean ssl) {;
server_destinations.add(dest);
this.userid = userid;
this.password = password;
this.reconnect = reconnect;
if (ssl)
socket_factory = SSLSocketFactory.getDefault();
else
socket_factory = SocketFactory.getDefault();
this.sslParameters = null;
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* @see SecureProtocolSocketFactory#createSocket(java.lang.String,int,java.net.InetAddress,int)
*/
public Socket createSocket(
String host,
int port,
InetAddress clientHost,
int clientPort)
throws IOException, UnknownHostException {
return SSLSocketFactory.getDefault().createSocket(
host,
port,
clientHost,
clientPort
);
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* @see SecureProtocolSocketFactory#createSocket(java.net.Socket,java.lang.String,int,boolean)
*/
public Socket createSocket(
Socket socket,
String host,
int port,
boolean autoClose)
throws IOException, UnknownHostException {
return ((SSLSocketFactory) SSLSocketFactory.getDefault()).createSocket(
socket,
host,
port,
autoClose
);
}
代码示例来源:origin: stackoverflow.com
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
URL url = new URL("https://gridserver:3049/cgi-bin/ls.py");
HttpsURLConnection conn = (HttpsURLConnection)url.openConnection();
conn.setSSLSocketFactory(sslsocketfactory);
InputStream inputstream = conn.getInputStream();
InputStreamReader inputstreamreader = new InputStreamReader(inputstream);
BufferedReader bufferedreader = new BufferedReader(inputstreamreader);
String string = null;
while ((string = bufferedreader.readLine()) != null) {
System.out.println("Received " + string);
}
代码示例来源:origin: gocd/gocd
public GoServer() {
this(new SystemEnvironment(), (SSLSocketFactory) SSLSocketFactory.getDefault());
}
代码示例来源:origin: oblac/jodd
/**
* Returns default SSL socket factory allowing setting trust managers.
*/
protected SSLSocketFactory getDefaultSSLSocketFactory(final boolean trustAllCertificates) throws IOException {
if (trustAllCertificates) {
try {
SSLContext sc = SSLContext.getInstance(sslProtocol);
sc.init(null, TrustManagers.TRUST_ALL_CERTS, new java.security.SecureRandom());
return sc.getSocketFactory();
}
catch (NoSuchAlgorithmException | KeyManagementException e) {
throw new IOException(e);
}
} else {
return (SSLSocketFactory) SSLSocketFactory.getDefault();
}
}
代码示例来源:origin: TakahikoKawasaki/nv-websocket-client
public SocketFactory selectSocketFactory(boolean secure)
{
if (secure)
{
if (mSSLContext != null)
{
return mSSLContext.getSocketFactory();
}
if (mSSLSocketFactory != null)
{
return mSSLSocketFactory;
}
return SSLSocketFactory.getDefault();
}
if (mSocketFactory != null)
{
return mSocketFactory;
}
return SocketFactory.getDefault();
}
}
代码示例来源:origin: apache/hbase
@Override
public Socket accept() throws IOException {
Socket socket = super.accept();
SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket sslSocket =
(SSLSocket) sslSocketFactory.createSocket(socket,
socket.getInetAddress().getHostName(), socket.getPort(), true);
sslSocket.setUseClientMode(false);
sslSocket.setNeedClientAuth(false);
ArrayList<String> secureProtocols = new ArrayList<>();
for (String p : sslSocket.getEnabledProtocols()) {
if (!p.contains("SSLv3")) {
secureProtocols.add(p);
}
}
sslSocket.setEnabledProtocols(secureProtocols.toArray(new String[secureProtocols.size()]));
return sslSocket;
}
};
代码示例来源:origin: cymcsg/UltimateAndroid
/**
* @deprecated
*/
public static void sendWithSSlSocket(String urlLink) {
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
URL url = null;
try {
url = new URL(urlLink);
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setSSLSocketFactory(sslsocketfactory);
InputStream inputstream = conn.getInputStream();
InputStreamReader inputstreamreader = new InputStreamReader(inputstream);
BufferedReader bufferedreader = new BufferedReader(inputstreamreader);
String string = null;
while ((string = bufferedreader.readLine()) != null) {
System.out.println("Received " + string);
}
} catch (Exception e) {
e.printStackTrace();
Logs.e(e, "");
}
}
代码示例来源:origin: apache/activemq
private Socket createSocket(URI target) throws Exception {
if (isSsl(target)) {
return SSLSocketFactory.getDefault().createSocket();
}
return new Socket();
}
代码示例来源:origin: com.h2database/h2
/**
* Create a secure client socket that is connected to the given address and
* port.
*
* @param address the address to connect to
* @param port the port
* @return the socket
*/
public static Socket createSocket(InetAddress address, int port)
throws IOException {
Socket socket = null;
setKeystore();
SSLSocketFactory f = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket secureSocket = (SSLSocket) f.createSocket();
secureSocket.connect(new InetSocketAddress(address, port),
SysProperties.SOCKET_CONNECT_TIMEOUT);
secureSocket.setEnabledProtocols(
disableSSL(secureSocket.getEnabledProtocols()));
if (SysProperties.ENABLE_ANONYMOUS_TLS) {
String[] list = enableAnonymous(
secureSocket.getEnabledCipherSuites(),
secureSocket.getSupportedCipherSuites());
secureSocket.setEnabledCipherSuites(list);
}
socket = secureSocket;
return socket;
}
代码示例来源:origin: apache/activemq
/**
* Creates a new SSL SocketFactory. The given factory will use user-provided
* key and trust managers (if the user provided them).
*
* @return Newly created (Ssl)SocketFactory.
* @throws IOException
*/
@Override
protected SocketFactory createSocketFactory() throws IOException {
if( SslContext.getCurrentSslContext()!=null ) {
SslContext ctx = SslContext.getCurrentSslContext();
try {
return ctx.getSSLContext().getSocketFactory();
} catch (Exception e) {
throw IOExceptionSupport.create(e);
}
} else {
return SSLSocketFactory.getDefault();
}
}
代码示例来源:origin: apache/activemq
/**
* Creates a new SSL SocketFactory. The given factory will use user-provided
* key and trust managers (if the user provided them).
*
* @return Newly created (Ssl)SocketFactory.
* @throws IOException
*/
@Override
protected SocketFactory createSocketFactory() throws IOException {
if (SslContext.getCurrentSslContext() != null) {
SslContext ctx = SslContext.getCurrentSslContext();
try {
return ctx.getSSLContext().getSocketFactory();
} catch (Exception e) {
throw IOExceptionSupport.create(e);
}
} else {
return SSLSocketFactory.getDefault();
}
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void support_tls_versions_of_java8() {
underTest = HttpConnector.newBuilder().url(serverUrl).build();
assertTlsAndClearTextSpecifications(underTest);
assertThat(underTest.okHttpClient().sslSocketFactory()).isInstanceOf(SSLSocketFactory.getDefault().getClass());
}
内容来源于网络,如有侵权,请联系作者删除!