左晓为主开发手持机充值管理机
zuoxiao
2023-12-19 da8f72d2db0bbfc221a881d5aa31065cd5717043
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package com.easysocket.config;
 
import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
 
/**
 * socket的ssl配置
 */
 
public class SocketSSLConfig {
    /**
     * 安全协议名称(缺省为SSL)
     */
    private String mProtocol;
    /**
     * 信任证书管理器(缺省为X509)
     */
    private TrustManager[] mTrustManagers;
    /**
     * 证书秘钥管理器(缺省为null)
     */
    private KeyManager[] mKeyManagers;
    /**
     * 自定义SSLFactory(缺省为null)
     */
    private SSLSocketFactory mCustomSSLFactory;
 
    private SocketSSLConfig() {
 
    }
 
    public static class Builder {
 
        private SocketSSLConfig mConfig;
 
        public Builder() {
            mConfig = new SocketSSLConfig();
        }
 
        public Builder setProtocol(String protocol) {
            mConfig.mProtocol = protocol;
            return this;
        }
 
        public Builder setTrustManagers(TrustManager[] trustManagers) {
            mConfig.mTrustManagers = trustManagers;
            return this;
        }
 
        public Builder setKeyManagers(KeyManager[] keyManagers) {
            mConfig.mKeyManagers = keyManagers;
            return this;
        }
 
        public Builder setCustomSSLFactory(SSLSocketFactory customSSLFactory) {
            mConfig.mCustomSSLFactory = customSSLFactory;
            return this;
        }
 
        public SocketSSLConfig build() {
            return mConfig;
        }
    }
 
    public KeyManager[] getKeyManagers() {
        return mKeyManagers;
    }
 
    public String getProtocol() {
        return mProtocol;
    }
 
    public TrustManager[] getTrustManagers() {
        return mTrustManagers;
    }
 
    public SSLSocketFactory getCustomSSLFactory() {
        return mCustomSSLFactory;
    }
}