Example usage for javax.net.ssl SSLEngine getClass

List of usage examples for javax.net.ssl SSLEngine getClass

Introduction

In this page you can find the example usage for javax.net.ssl SSLEngine getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:mitm.BouncyCastleSslEngineSource.java

private boolean tryHostNameVerificationJava6(SSLEngine sslEngine) {

    // Very ugly internal access, but should work with Java 6 from Oracle,
    // but won't work with my Java 6 from Apple and what's about Android?
    ///* ww  w . java  2s.  co  m*/
    if ("sun.security.ssl.SSLEngineImpl".equals(sslEngine.getClass().getName())) {
        try {
            Method method = sslEngine.getClass().getMethod("tryHostNameVerification", String.class);
            method.invoke(sslEngine, "HTTPS");
            return true;
        } catch (IllegalAccessException e) {
            LOG.debug("sun.security.ssl.SSLEngineImpl#tryHostNameVerification", e);
        } catch (InvocationTargetException e) {
            LOG.debug("sun.security.ssl.SSLEngineImpl#tryHostNameVerification", e);
        } catch (NoSuchMethodException e) {
            LOG.debug("sun.security.ssl.SSLEngineImpl#tryHostNameVerification", e);
        } catch (SecurityException e) {
            LOG.debug("sun.security.ssl.SSLEngineImpl#tryHostNameVerification", e);
        }
    }
    return false;
}