@@ -33,6 +33,8 @@ public class WolfSSLParametersHelper
3333{
3434 private static Method getServerNames = null ;
3535 private static Method setServerNames = null ;
36+ private static Method getApplicationProtocols = null ;
37+ private static Method setApplicationProtocols = null ;
3638
3739 /** Default WolfSSLParametersHelper constructor */
3840 public WolfSSLParametersHelper () { }
@@ -59,6 +61,12 @@ public Object run() {
5961 case "setServerNames" :
6062 setServerNames = m ;
6163 continue ;
64+ case "getApplicationProtocols" :
65+ getApplicationProtocols = m ;
66+ continue ;
67+ case "setApplicationProtocols" :
68+ setApplicationProtocols = m ;
69+ continue ;
6270 default :
6371 continue ;
6472 }
@@ -100,7 +108,7 @@ protected static SSLParameters decoupleParams(WolfSSLParameters in) {
100108 /* Methods added as of JDK 1.8, older JDKs will not have them. Using
101109 * Java reflection to detect availability. */
102110
103- if (setServerNames != null ) {
111+ if (setServerNames != null || setApplicationProtocols != null ) {
104112
105113 try {
106114 /* load WolfSSLJDK8Helper at runtime, not compiled on older JDKs */
@@ -110,9 +118,16 @@ protected static SSLParameters decoupleParams(WolfSSLParameters in) {
110118 paramList [0 ] = javax .net .ssl .SSLParameters .class ;
111119 paramList [1 ] = java .lang .reflect .Method .class ;
112120 paramList [2 ] = com .wolfssl .provider .jsse .WolfSSLParameters .class ;
121+ Method mth = null ;
113122
114- Method mth = cls .getDeclaredMethod ("setServerNames" , paramList );
115- mth .invoke (obj , ret , setServerNames , in );
123+ if (setServerNames != null ) {
124+ mth = cls .getDeclaredMethod ("setServerNames" , paramList );
125+ mth .invoke (obj , ret , setServerNames , in );
126+ }
127+ if (setApplicationProtocols != null ) {
128+ mth = cls .getDeclaredMethod ("setApplicationProtocols" , paramList );
129+ mth .invoke (obj , ret , setServerNames , in );
130+ }
116131
117132 } catch (Exception e ) {
118133 /* ignore, class not found */
@@ -124,7 +139,6 @@ protected static SSLParameters decoupleParams(WolfSSLParameters in) {
124139 * with newer versions of SSLParameters, but will need to be added
125140 * conditionally to wolfJSSE when supported. */
126141 /*ret.setAlgorithmConstraints(in.getAlgorithmConstraints());
127- ret.setApplicationProtocols(in.getApplicationProtocols());
128142 ret.setEnableRetransmissions(in.getEnableRetransmissions());
129143 ret.setEndpointIdentificationAlgorithm(
130144 in.getEndpointIdentificationAlgorithm());
@@ -170,17 +184,24 @@ protected static void importParams(SSLParameters in,
170184 /* Methods added as of JDK 1.8, older JDKs will not have them. Using
171185 * Java reflection to detect availability. */
172186
173- if (getServerNames != null ) {
187+ if (getServerNames != null || getApplicationProtocols != null ) {
174188 try {
175189 /* load WolfSSLJDK8Helper at runtime, not compiled on older JDKs */
176190 Class <?> cls = Class .forName ("com.wolfssl.provider.jsse.WolfSSLJDK8Helper" );
177191 Object obj = cls .getConstructor ().newInstance ();
178192 Class [] paramList = new Class [2 ];
179193 paramList [0 ] = javax .net .ssl .SSLParameters .class ;
180194 paramList [1 ] = com .wolfssl .provider .jsse .WolfSSLParameters .class ;
195+ Method mth = null ;
181196
182- Method mth = cls .getDeclaredMethod ("getServerNames" , paramList );
183- mth .invoke (obj , in , out );
197+ if (getServerNames != null ) {
198+ mth = cls .getDeclaredMethod ("getServerNames" , paramList );
199+ mth .invoke (obj , in , out );
200+ }
201+ if (getApplicationProtocols != null ) {
202+ mth = cls .getDeclaredMethod ("getApplicationProtocols" , paramList );
203+ mth .invoke (obj , in , out );
204+ }
184205
185206 } catch (Exception e ) {
186207 /* ignore, class not found */
@@ -192,7 +213,6 @@ protected static void importParams(SSLParameters in,
192213 * with newer versions of SSLParameters, but will need to be added
193214 * conditionally to wolfJSSE when supported. */
194215 /*out.setAlgorithmConstraints(in.getAlgorithmConstraints());
195- out.setApplicationProtocols(in.getApplicationProtocols());
196216 out.setEnableRetransmissions(in.getEnableRetransmissions());
197217 out.setEndpointIdentificationAlgorithm(
198218 in.getEndpointIdentificationAlgorithm());
0 commit comments