|
7 | 7 | import java.nio.channels.SelectableChannel; |
8 | 8 | import java.nio.channels.Selector; |
9 | 9 | import java.nio.charset.Charset; |
| 10 | +import java.time.Duration; |
10 | 11 | import java.util.ArrayList; |
11 | 12 | import java.util.List; |
12 | 13 | import java.util.concurrent.ThreadLocalRandom; |
|
15 | 16 | import java.util.function.BiFunction; |
16 | 17 | import java.util.function.Consumer; |
17 | 18 |
|
| 19 | +import javax.net.ssl.SSLContext; |
| 20 | +import javax.net.ssl.SSLParameters; |
| 21 | + |
18 | 22 | import org.zeromq.proto.ZPicture; |
19 | 23 |
|
20 | 24 | import zmq.Ctx; |
|
28 | 32 | import zmq.io.mechanism.Mechanisms; |
29 | 33 | import zmq.io.net.SocketFactory.ChannelFactoryWrapper; |
30 | 34 | import zmq.io.net.SelectorProviderChooser; |
| 35 | +import zmq.io.net.tls.PrincipalConverter; |
31 | 36 | import zmq.msg.MsgAllocator; |
32 | 37 | import zmq.util.Draft; |
33 | 38 | import zmq.util.Z85; |
@@ -3103,6 +3108,69 @@ public ChannelFactoryWrapper<? extends SocketAddress> getChannelWrapper() |
3103 | 3108 | return base.getSocketOptx(zmq.ZMQ.ZMQ_CHANNEL_WRAPPER_FACTORY); |
3104 | 3109 | } |
3105 | 3110 |
|
| 3111 | + /** |
| 3112 | + * When using the tls {@link zmq.io.net.NetProtocol}, it will set the {@link SSLContext} to be used. |
| 3113 | + * @param sslContext The {@link SSLContext} to used |
| 3114 | + * |
| 3115 | + * @return true if the option was set, otherwise false |
| 3116 | + */ |
| 3117 | + public boolean setSslContext(SSLContext sslContext) |
| 3118 | + { |
| 3119 | + return base.setSocketOpt(zmq.ZMQ.ZMQ_TLS_CONTEXT, sslContext); |
| 3120 | + } |
| 3121 | + |
| 3122 | + /** |
| 3123 | + * The {@link SSLContext} to use can be defined both in the factory or specific for the current socket using |
| 3124 | + * {@link #setSslContext}. This method return the effective one. |
| 3125 | + * @return The effective {@link SSLContext} |
| 3126 | + */ |
| 3127 | + public SSLContext getSslContext() |
| 3128 | + { |
| 3129 | + return base.getSocketOptx(zmq.ZMQ.ZMQ_TLS_CONTEXT); |
| 3130 | + } |
| 3131 | + |
| 3132 | + /** |
| 3133 | + * When using the tls {@link zmq.io.net.NetProtocol}, it will set the {@link SSLParameters} to be used. |
| 3134 | + * @param sslParams The {@link SSLParameters} to used |
| 3135 | + * |
| 3136 | + * @return true if the option was set, otherwise false |
| 3137 | + */ |
| 3138 | + public boolean setSslParameters(SSLParameters sslParams) |
| 3139 | + { |
| 3140 | + return base.setSocketOpt(zmq.ZMQ.ZMQ_TLS_PARAMETERS, sslParams); |
| 3141 | + } |
| 3142 | + |
| 3143 | + /** |
| 3144 | + * The {@link SSLContext} to use can be defined both in the factory or specific for the current socket using |
| 3145 | + * {@link #setSslParameters}. This method return the effective one. |
| 3146 | + * @return The effective {@link SSLParameters} |
| 3147 | + */ |
| 3148 | + public SSLParameters getSslParameter() |
| 3149 | + { |
| 3150 | + return base.getSocketOptx(zmq.ZMQ.ZMQ_TLS_PARAMETERS); |
| 3151 | + } |
| 3152 | + |
| 3153 | + /** |
| 3154 | + * When using the tls {@link zmq.io.net.NetProtocol}, it will set the {@link PrincipalConverter} to be used. |
| 3155 | + * @param principalConverter The {@link PrincipalConverter} to be used |
| 3156 | + * |
| 3157 | + * @return true if the option was set, otherwise false |
| 3158 | + */ |
| 3159 | + public boolean setPrincipalConvert(PrincipalConverter principalConverter) |
| 3160 | + { |
| 3161 | + return base.setSocketOpt(zmq.ZMQ.ZMQ_TLS_PRINCIPAL_CONVERT, principalConverter); |
| 3162 | + } |
| 3163 | + |
| 3164 | + /** |
| 3165 | + * The {@link PrincipalConverter} to use can be defined both in the factory or specific for the current socket using |
| 3166 | + * {@link #setPrincipalConvert}. This method return the effective one. |
| 3167 | + * @return The effective {@link PrincipalConverter} |
| 3168 | + */ |
| 3169 | + public PrincipalConverter getPrincipalConverter() |
| 3170 | + { |
| 3171 | + return base.getSocketOptx(zmq.ZMQ.ZMQ_TLS_PRINCIPAL_CONVERT); |
| 3172 | + } |
| 3173 | + |
3106 | 3174 | /** |
3107 | 3175 | * Bind to network interface. Start listening for new connections. |
3108 | 3176 | * |
|
0 commit comments