/** * Singleton initializer. * * Uses reflection to extract and 'cache' the method to invoke to indicate the desited host name to the server side. * * @param sslSocketClass Underlying class providing the implementation of {@link SSLSocket}. * @return Method to call to indicate the server name of interest to the server. */ private static Method initFrom(Class<?> sslSocketClass) { Log_OC.i(TAG, "SSLSocket implementation: " + sslSocketClass.getCanonicalName()); Method setHostnameMethod = null; try { setHostnameMethod = sslSocketClass.getMethod(METHOD_NAME, String.class); } catch (SecurityException e) { Log_OC.e(TAG, "Could not access to SSLSocket#setHostname(String) method ", e); } catch (NoSuchMethodException e) { Log_OC.i(TAG, "Could not find SSLSocket#setHostname(String) method - SNI not supported"); } mSingleInstance.set(new ServerNameIndicator(sslSocketClass, setHostnameMethod)); return setHostnameMethod; }
/** * Singleton initializer. * * Uses reflection to extract and 'cache' the method to invoke to indicate the desited host name to the server side. * * @param sslSocketClass Underlying class providing the implementation of {@link SSLSocket}. * @return Method to call to indicate the server name of interest to the server. */ private static Method initFrom(Class<?> sslSocketClass) { Log_OC.i(TAG, "SSLSocket implementation: " + sslSocketClass.getCanonicalName()); Method setHostnameMethod = null; try { setHostnameMethod = sslSocketClass.getMethod(METHOD_NAME, String.class); } catch (SecurityException e) { Log_OC.e(TAG, "Could not access to SSLSocket#setHostname(String) method ", e); } catch (NoSuchMethodException e) { Log_OC.i(TAG, "Could not find SSLSocket#setHostname(String) method - SNI not supported"); } mSingleInstance.set(new ServerNameIndicator(sslSocketClass, setHostnameMethod)); return setHostnameMethod; }