Example usage for javax.net.ssl SSLException getMessage

List of usage examples for javax.net.ssl SSLException getMessage

Introduction

In this page you can find the example usage for javax.net.ssl SSLException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.msr.dnsdemo.network.DownloadFile.java

private InputStream openURL(String url) {
    HttpGet httpget = new HttpGet(url);
    HttpResponse response;/* w  w w.j a  v  a2s. c om*/
    try {
        try {
            response = httpclient.execute(httpget);
        } catch (SSLException e) {
            Log.i(TAG, "SSL Certificate is not trusted");
            response = httpclient.execute(httpget);
        }
        Log.i(TAG, "Status:[" + response.getStatusLine().toString() + "]");
        HttpEntity entity = response.getEntity();

        if (entity != null) {
            return new GZIPInputStream(entity.getContent());
        }
    } catch (ClientProtocolException e) {
        Log.e(TAG, "There was a protocol based error", e);
    } catch (UnknownHostException e) {
        Log.e(TAG, e.getMessage());
    } catch (IOException e) {
        Log.e(TAG, "There was an IO Stream related error", e);
    }

    return null;
}

From source file:org.parosproxy.paros.network.SSLConnector.java

/**
 * Attempts to get a new socket connection to the given host within the
 * given time limit./*  ww  w. j a v  a  2  s .  c om*/
 * 
 * @param host
 *            the host name/IP
 * @param port
 *            the port on the host
 * @param localAddress
 *            the local host name/IP to bind the socket to
 * @param localPort
 *            the port on the local machine
 * @param params
 *            {@link HttpConnectionParams Http connection parameters}
 * 
 * @return Socket a new socket
 * 
 * @throws IOException
 *             if an I/O error occurs while creating the socket
 * @throws UnknownHostException
 *             if the IP address of the host cannot be determined
 * @throws    ConnectTimeoutException        
 */
@Override
public Socket createSocket(final String host, final int port, final InetAddress localAddress,
        final int localPort, final HttpConnectionParams params)
        throws IOException, UnknownHostException, ConnectTimeoutException {
    if (params == null) {
        throw new IllegalArgumentException("Parameters may not be null");
    }
    int timeout = params.getConnectionTimeout();
    if (timeout == 0) {
        InetAddress hostAddress = getCachedMisconfiguredHost(host, port);
        if (hostAddress != null) {
            return clientSSLSockFactory.createSocket(hostAddress, port, localAddress, localPort);
        }
        try {
            SSLSocket sslSocket = (SSLSocket) clientSSLSockFactory.createSocket(host, port, localAddress,
                    localPort);
            sslSocket.startHandshake();

            return sslSocket;
        } catch (SSLException e) {
            if (!e.getMessage().contains(CONTENTS_UNRECOGNIZED_NAME_EXCEPTION)) {
                throw e;
            }

            hostAddress = InetAddress.getByName(host);
            cacheMisconfiguredHost(host, port, hostAddress);
            return clientSSLSockFactory.createSocket(hostAddress, port, localAddress, localPort);
        }
    }
    Socket socket = clientSSLSockFactory.createSocket();
    SocketAddress localAddr = new InetSocketAddress(localAddress, localPort);
    socket.bind(localAddr);
    SocketAddress remoteAddr = new InetSocketAddress(host, port);
    socket.connect(remoteAddr, timeout);

    return socket;
}

From source file:org.apache.hc.client5.http.impl.auth.CredSspScheme.java

private void beginTlsHandshake() throws AuthenticationException {
    try {//from www. ja  va  2 s.c om
        getSSLEngine().beginHandshake();
    } catch (final SSLException e) {
        throw new AuthenticationException("SSL Engine error: " + e.getMessage(), e);
    }
}

From source file:org.apache.hc.client5.http.impl.auth.CredSspScheme.java

private void wrap(final ByteBuffer src, final ByteBuffer dst) throws AuthenticationException {
    final SSLEngine sslEngine = getSSLEngine();
    try {//from   ww w  . j ava  2s.  co  m
        final SSLEngineResult engineResult = sslEngine.wrap(src, dst);
        if (engineResult.getStatus() != Status.OK) {
            throw new AuthenticationException("SSL Engine error status: " + engineResult.getStatus());
        }
    } catch (final SSLException e) {
        throw new AuthenticationException("SSL Engine wrap error: " + e.getMessage(), e);
    }
}

From source file:org.apache.hc.client5.http.impl.auth.CredSspScheme.java

private void unwrap(final ByteBuffer src, final ByteBuffer dst) throws MalformedChallengeException {

    try {// w w  w. j  a  va  2 s. co  m
        final SSLEngineResult engineResult = sslEngine.unwrap(src, dst);
        if (engineResult.getStatus() != Status.OK) {
            throw new MalformedChallengeException("SSL Engine error status: " + engineResult.getStatus());
        }

        if (sslEngine.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
            final Runnable task = sslEngine.getDelegatedTask();
            task.run();
        }

    } catch (final SSLException e) {
        throw new MalformedChallengeException("SSL Engine unwrap error: " + e.getMessage(), e);
    }
}

From source file:jp.co.fttx.rakuphotomail.mail.store.WebDavStore.java

/**
 * Makes the initial connection to Exchange for authentication. Determines the type of authentication necessary for
 * the server./*from ww  w.  j a v a2s.c  om*/
 *
 * @throws MessagingException
 */
private ConnectionInfo doInitialConnection() throws MessagingException {
    // For our initial connection we are sending an empty GET request to
    // the configured URL, which should be in the following form:
    // https://mail.server.com/Exchange/alias
    //
    // Possible status codes include:
    // 401 - the server uses basic authentication
    // 30x - the server is trying to redirect us to an OWA login
    // 20x - success
    //
    // The latter two indicate form-based authentication.
    ConnectionInfo info = new ConnectionInfo();

    WebDavHttpClient httpClient = getHttpClient();

    HttpGeneric request = new HttpGeneric(mUrl);
    request.setMethod("GET");

    try {
        HttpResponse response = httpClient.executeOverride(request, mContext);
        info.statusCode = response.getStatusLine().getStatusCode();

        if (info.statusCode == 401) {
            // 401 is the "Unauthorized" status code, meaning the server wants
            // an authentication header for basic authentication.
            info.requiredAuthType = AUTH_TYPE_BASIC;
        } else if ((info.statusCode >= 200 && info.statusCode < 300) || // Success
                (info.statusCode >= 300 && info.statusCode < 400) || // Redirect
                (info.statusCode == 440)) { // Unauthorized
            // We will handle all 3 situations the same. First we take an educated
            // guess at where the authorization DLL is located. If this is this
            // doesn't work, then we'll use the redirection URL for OWA login given
            // to us by exchange. We can use this to scrape the location of the
            // authorization URL.
            info.requiredAuthType = AUTH_TYPE_FORM_BASED;

            if (mAuthPath != null && !mAuthPath.equals("")) {
                // The user specified their own authentication path, use that.
                info.guessedAuthUrl = getRoot() + mAuthPath;
            } else {
                // Use the default path to the authentication dll.
                info.guessedAuthUrl = getRoot() + "/exchweb/bin/auth/owaauth.dll";
            }

            // Determine where the server is trying to redirect us.
            Header location = response.getFirstHeader("Location");
            if (location != null) {
                info.redirectUrl = location.getValue();
            }
        } else {
            throw new IOException("Error with code " + info.statusCode + " during request processing: "
                    + response.getStatusLine().toString());
        }
    } catch (SSLException e) {
        throw new CertificateValidationException(e.getMessage(), e);
    } catch (IOException ioe) {
        Log.e(RakuPhotoMail.LOG_TAG, "IOException: " + ioe + "\nTrace: " + processException(ioe));
        throw new MessagingException("IOException", ioe);
    }

    return info;
}

From source file:com.fsck.k9.mail.store.webdav.WebDavStore.java

/**
 * Makes the initial connection to Exchange for authentication. Determines the type of authentication necessary for
 * the server.//from   ww  w  .java 2  s  . co  m
 *
 * @throws MessagingException
 */
private ConnectionInfo doInitialConnection() throws MessagingException {
    // For our initial connection we are sending an empty GET request to
    // the configured URL, which should be in the following form:
    // https://mail.server.com/Exchange/alias
    //
    // Possible status codes include:
    // 401 - the server uses basic authentication
    // 30x - the server is trying to redirect us to an OWA login
    // 20x - success
    //
    // The latter two indicate form-based authentication.
    ConnectionInfo info = new ConnectionInfo();

    WebDavHttpClient httpClient = getHttpClient();

    HttpGeneric request = new HttpGeneric(mUrl);
    request.setMethod("GET");

    try {
        HttpResponse response = httpClient.executeOverride(request, mContext);
        info.statusCode = response.getStatusLine().getStatusCode();

        if (info.statusCode == 401) {
            // 401 is the "Unauthorized" status code, meaning the server wants
            // an authentication header for basic authentication.
            info.requiredAuthType = AUTH_TYPE_BASIC;
        } else if ((info.statusCode >= 200 && info.statusCode < 300) || // Success
                (info.statusCode >= 300 && info.statusCode < 400) || // Redirect
                (info.statusCode == 440)) { // Unauthorized
            // We will handle all 3 situations the same. First we take an educated
            // guess at where the authorization DLL is located. If this is this
            // doesn't work, then we'll use the redirection URL for OWA login given
            // to us by exchange. We can use this to scrape the location of the
            // authorization URL.
            info.requiredAuthType = AUTH_TYPE_FORM_BASED;

            if (mAuthPath != null && !mAuthPath.equals("")) {
                // The user specified their own authentication path, use that.
                info.guessedAuthUrl = getRoot() + mAuthPath;
            } else {
                // Use the default path to the authentication dll.
                info.guessedAuthUrl = getRoot() + "/exchweb/bin/auth/owaauth.dll";
            }

            // Determine where the server is trying to redirect us.
            Header location = response.getFirstHeader("Location");
            if (location != null) {
                info.redirectUrl = location.getValue();
            }
        } else {
            throw new IOException("Error with code " + info.statusCode + " during request processing: "
                    + response.getStatusLine().toString());
        }
    } catch (SSLException e) {
        throw new CertificateValidationException(e.getMessage(), e);
    } catch (IOException ioe) {
        Log.e(LOG_TAG, "IOException: " + ioe + "\nTrace: " + processException(ioe));
        throw new MessagingException("IOException", ioe);
    }

    return info;
}

From source file:br.pcfl.up.mail.store.WebDavStore.java

/**
 * Makes the initial connection to Exchange for authentication. Determines the type of authentication necessary for
 * the server.//from  w  w  w. java 2 s. com
 *
 * @throws MessagingException
 */
private ConnectionInfo doInitialConnection() throws MessagingException {
    // For our initial connection we are sending an empty GET request to
    // the configured URL, which should be in the following form:
    // https://mail.server.com/Exchange/alias
    //
    // Possible status codes include:
    // 401 - the server uses basic authentication
    // 30x - the server is trying to redirect us to an OWA login
    // 20x - success
    //
    // The latter two indicate form-based authentication.
    ConnectionInfo info = new ConnectionInfo();

    WebDavHttpClient httpClient = getHttpClient();

    HttpGeneric request = new HttpGeneric(mUrl);
    request.setMethod("GET");

    try {
        HttpResponse response = httpClient.executeOverride(request, mContext);
        info.statusCode = response.getStatusLine().getStatusCode();

        if (info.statusCode == 401) {
            // 401 is the "Unauthorized" status code, meaning the server wants
            // an authentication header for basic authentication.
            info.requiredAuthType = AUTH_TYPE_BASIC;
        } else if ((info.statusCode >= 200 && info.statusCode < 300) || // Success
                (info.statusCode >= 300 && info.statusCode < 400) || // Redirect
                (info.statusCode == 440)) { // Unauthorized
            // We will handle all 3 situations the same. First we take an educated
            // guess at where the authorization DLL is located. If this is this
            // doesn't work, then we'll use the redirection URL for OWA login given
            // to us by exchange. We can use this to scrape the location of the
            // authorization URL.
            info.requiredAuthType = AUTH_TYPE_FORM_BASED;

            if (mAuthPath != null && !mAuthPath.equals("")) {
                // The user specified their own authentication path, use that.
                info.guessedAuthUrl = getRoot() + mAuthPath;
            } else {
                // Use the default path to the authentication dll.
                info.guessedAuthUrl = getRoot() + "/exchweb/bin/auth/owaauth.dll";
            }

            // Determine where the server is trying to redirect us.
            Header location = response.getFirstHeader("Location");
            if (location != null) {
                info.redirectUrl = location.getValue();
            }
        } else {
            throw new IOException("Error with code " + info.statusCode + " during request processing: "
                    + response.getStatusLine().toString());
        }
    } catch (SSLException e) {
        throw new CertificateValidationException(e.getMessage(), e);
    } catch (IOException ioe) {
        Log.e(Up.LOG_TAG, "IOException: " + ioe + "\nTrace: " + processException(ioe));
        throw new MessagingException("IOException", ioe);
    }

    return info;
}

From source file:cn.mailchat.mail.store.WebDavStore.java

/**
 * Makes the initial connection to Exchange for authentication. Determines the type of authentication necessary for
 * the server.//from ww w  .  j  a v a2s.  com
 *
 * @throws MessagingException
 */
private ConnectionInfo doInitialConnection() throws MessagingException {
    // For our initial connection we are sending an empty GET request to
    // the configured URL, which should be in the following form:
    // https://mail.server.com/Exchange/alias
    //
    // Possible status codes include:
    // 401 - the server uses basic authentication
    // 30x - the server is trying to redirect us to an OWA login
    // 20x - success
    //
    // The latter two indicate form-based authentication.
    ConnectionInfo info = new ConnectionInfo();

    WebDavHttpClient httpClient = getHttpClient();

    HttpGeneric request = new HttpGeneric(mUrl);
    request.setMethod("GET");

    try {
        HttpResponse response = httpClient.executeOverride(request, mContext);
        info.statusCode = response.getStatusLine().getStatusCode();

        if (info.statusCode == 401) {
            // 401 is the "Unauthorized" status code, meaning the server wants
            // an authentication header for basic authentication.
            info.requiredAuthType = AUTH_TYPE_BASIC;
        } else if ((info.statusCode >= 200 && info.statusCode < 300) || // Success
                (info.statusCode >= 300 && info.statusCode < 400) || // Redirect
                (info.statusCode == 440)) { // Unauthorized
            // We will handle all 3 situations the same. First we take an educated
            // guess at where the authorization DLL is located. If this is this
            // doesn't work, then we'll use the redirection URL for OWA login given
            // to us by exchange. We can use this to scrape the location of the
            // authorization URL.
            info.requiredAuthType = AUTH_TYPE_FORM_BASED;

            if (mAuthPath != null && !mAuthPath.equals("")) {
                // The user specified their own authentication path, use that.
                info.guessedAuthUrl = getRoot() + mAuthPath;
            } else {
                // Use the default path to the authentication dll.
                info.guessedAuthUrl = getRoot() + "/exchweb/bin/auth/owaauth.dll";
            }

            // Determine where the server is trying to redirect us.
            Header location = response.getFirstHeader("Location");
            if (location != null) {
                info.redirectUrl = location.getValue();
            }
        } else {
            throw new IOException("Error with code " + info.statusCode + " during request processing: "
                    + response.getStatusLine().toString());
        }
    } catch (SSLException e) {
        throw new CertificateValidationException(e.getMessage(), e);
    } catch (IOException ioe) {
        Log.e(MailChat.LOG_TAG, "IOException: " + ioe + "\nTrace: " + processException(ioe));
        throw new MessagingException("IOException", ioe);
    }

    return info;
}

From source file:com.top.Ertebat.mail.store.WebDavStore.java

/**
 * Makes the initial connection to Exchange for authentication. Determines the type of authentication necessary for
 * the server.//  w  w  w.j av a  2s  .c om
 *
 * @throws MessagingException
 */
private ConnectionInfo doInitialConnection() throws MessagingException {
    // For our initial connection we are sending an empty GET request to
    // the configured URL, which should be in the following form:
    // https://mail.server.com/Exchange/alias
    //
    // Possible status codes include:
    // 401 - the server uses basic authentication
    // 30x - the server is trying to redirect us to an OWA login
    // 20x - success
    //
    // The latter two indicate form-based authentication.
    ConnectionInfo info = new ConnectionInfo();

    WebDavHttpClient httpClient = getHttpClient();

    HttpGeneric request = new HttpGeneric(mUrl);
    request.setMethod("GET");

    try {
        HttpResponse response = httpClient.executeOverride(request, mContext);
        info.statusCode = response.getStatusLine().getStatusCode();

        if (info.statusCode == 401) {
            // 401 is the "Unauthorized" status code, meaning the server wants
            // an authentication header for basic authentication.
            info.requiredAuthType = AUTH_TYPE_BASIC;
        } else if ((info.statusCode >= 200 && info.statusCode < 300) || // Success
                (info.statusCode >= 300 && info.statusCode < 400) || // Redirect
                (info.statusCode == 440)) { // Unauthorized
            // We will handle all 3 situations the same. First we take an educated
            // guess at where the authorization DLL is located. If this is this
            // doesn't work, then we'll use the redirection URL for OWA login given
            // to us by exchange. We can use this to scrape the location of the
            // authorization URL.
            info.requiredAuthType = AUTH_TYPE_FORM_BASED;

            if (mAuthPath != null && !mAuthPath.equals("")) {
                // The user specified their own authentication path, use that.
                info.guessedAuthUrl = getRoot() + mAuthPath;
            } else {
                // Use the default path to the authentication dll.
                info.guessedAuthUrl = getRoot() + "/exchweb/bin/auth/owaauth.dll";
            }

            // Determine where the server is trying to redirect us.
            Header location = response.getFirstHeader("Location");
            if (location != null) {
                info.redirectUrl = location.getValue();
            }
        } else {
            throw new IOException("Error with code " + info.statusCode + " during request processing: "
                    + response.getStatusLine().toString());
        }
    } catch (SSLException e) {
        throw new CertificateValidationException(e.getMessage(), e);
    } catch (IOException ioe) {
        Log.e(Ertebat.LOG_TAG, "IOException: " + ioe + "\nTrace: " + processException(ioe));
        throw new MessagingException("IOException", ioe);
    }

    return info;
}