-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: BrouseLi <[email protected]>
- Loading branch information
Showing
34 changed files
with
698 additions
and
1,069 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/main/java/com/angshi/mimicwebpolicy/Config/OkHttpConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.angshi.mimicwebpolicy.Config; | ||
|
||
import okhttp3.ConnectionPool; | ||
import okhttp3.OkHttpClient; | ||
import org.springframework.context.annotation.Bean; | ||
|
||
import javax.net.ssl.SSLContext; | ||
import javax.net.ssl.SSLSocketFactory; | ||
import javax.net.ssl.TrustManager; | ||
import javax.net.ssl.X509TrustManager; | ||
import java.security.KeyManagementException; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.SecureRandom; | ||
import java.security.cert.CertificateException; | ||
import java.security.cert.X509Certificate; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
public class OkHttpConfig { | ||
@Bean | ||
public X509TrustManager x509TrustManager() { | ||
return new X509TrustManager() { | ||
@Override | ||
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { | ||
} | ||
@Override | ||
public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { | ||
} | ||
@Override | ||
public X509Certificate[] getAcceptedIssuers() { | ||
return new X509Certificate[0]; | ||
} | ||
}; | ||
} | ||
@Bean | ||
public SSLSocketFactory sslSocketFactory() { | ||
try { | ||
//信任任何链接 | ||
SSLContext sslContext = SSLContext.getInstance("TLS"); | ||
sslContext.init(null, new TrustManager[]{x509TrustManager()}, new SecureRandom()); | ||
return sslContext.getSocketFactory(); | ||
} catch (NoSuchAlgorithmException e) { | ||
e.printStackTrace(); | ||
} catch (KeyManagementException e) { | ||
e.printStackTrace(); | ||
} | ||
return null; | ||
} | ||
/** | ||
* Create a new connection pool with tuning parameters appropriate for a single-user application. | ||
* The tuning parameters in this pool are subject to change in future OkHttp releases. Currently | ||
*/ | ||
@Bean | ||
public ConnectionPool pool() { | ||
return new ConnectionPool(200, 5, TimeUnit.MINUTES); | ||
} | ||
@Bean | ||
public OkHttpClient okHttpClient() { | ||
return new OkHttpClient.Builder() | ||
.sslSocketFactory(sslSocketFactory(), x509TrustManager()) | ||
.retryOnConnectionFailure(false)//是否开启缓存 | ||
.connectionPool(pool())//连接池 | ||
.connectTimeout(10L, TimeUnit.SECONDS) | ||
.readTimeout(10L, TimeUnit.SECONDS) | ||
.build(); | ||
} | ||
} |
104 changes: 0 additions & 104 deletions
104
src/main/java/com/angshi/mimicwebpolicy/Entity/Board.java
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
src/main/java/com/angshi/mimicwebpolicy/Entity/Boards.java
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
src/main/java/com/angshi/mimicwebpolicy/Entity/Hardware.java
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
src/main/java/com/angshi/mimicwebpolicy/Entity/HelloWorldClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 0 additions & 117 deletions
117
src/main/java/com/angshi/mimicwebpolicy/Entity/Interface.java
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
src/main/java/com/angshi/mimicwebpolicy/Entity/Interfaces.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.