Example usage for javax.net.ssl SSLException toString

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

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:de.taxilof.UulmLoginAgent.java

/**
 * perform the Login & necessary Checks
 *//*from   w  w  w. j a  v a2s .c  o m*/
public void login() {
    // setting up my http client
    DefaultHttpClient client = new DefaultHttpClient();
    client.getParams().setParameter(CoreProtocolPNames.USER_AGENT,
            "Mozilla/5.0 (Linux; U; Android; uulmLogin " + context.getString(R.string.app_version) + ")");
    // disable redirects in client, used from isLoggedIn method
    client.setRedirectHandler(new RedirectHandler() {
        public URI getLocationURI(HttpResponse arg0, HttpContext arg1) throws ProtocolException {
            return null;
        }

        public boolean isRedirectRequested(HttpResponse arg0, HttpContext arg1) {
            return false;
        }
    });

    // get IP
    String ipAddress = getIp();
    if (ipAddress == null) {
        Log.d("uulmLogin", "Could not get IP Address, aborting.");
        return;
    }
    Log.d("uulmLogin", "Got IP: " + ipAddress + ", continuing.");

    // check if IP prefix is wrong
    if (!(ipAddress.startsWith(context.getString(R.string.ip_prefix)))) {
        Log.d("uulmLogin", "Wrong IP Prefix.");
        return;
    }

    // check the SSID
    String ssid = getSsid();
    if (!(context.getString(R.string.ssid).equals(ssid))) {
        Log.d("uulmLogin", "Wrong SSID, aborting.");
        return;
    }

    // check if we are already logged in
    if (isLoggedIn(client, 5)) {
        Log.d("uulmLogin", "Already logged in, aborting.");
        return;
    }

    // try to login via GET Request
    try {
        // login
        HttpGet get = new HttpGet(String.format("%s?username=%s&password=%s&login=Anmelden",
                context.getString(R.string.capo_uri), username, URLEncoder.encode(password)));
        @SuppressWarnings("unused")
        HttpResponse response = client.execute(get);
        Log.d("uulmLogin", "Login done, HttpResponse:" + HttpHelper.request(response));
    } catch (SSLException ex) {
        Log.w("uulmLogin", "SSL Error while sending Login Request: " + ex.toString());
        if (notifyFailure)
            notify("Login to Welcome failed", "SSL Error: could not verify Host", true);
        return;
    } catch (Exception e) {
        Log.w("uulmLogin", "Error while sending Login Request: " + e.toString());
        if (notifyFailure)
            notify("Login to Welcome failed", "Error while sending Login Request.", true);
        return;
    }

    // should be logged in now, but we check it now, just to be sure
    if (isLoggedIn(client, 2)) {
        if (notifySuccess)
            notify("Login to welcome successful.", "Your IP: " + ipAddress, false);
        Log.d("uulmLogin", "Login successful.");
    } else {
        if (notifyFailure)
            notify("Login to welcome failed.", "Maybe wrong Username/Password?", true);
        Log.w("uulmLogin", "Login failed, wrong user/pass?");
    }
}

From source file:org.apache.tomcat.util.net.jsse.JSSESocketFactory.java

public Socket acceptSocket(ServerSocket socket) throws IOException {
    SSLSocket asock = null;//  ww  w.  j av  a2s.c o  m
    try {
        asock = (SSLSocket) socket.accept();
        asock.setNeedClientAuth(clientAuth);
    } catch (SSLException e) {
        throw new SocketException("SSL handshake error" + e.toString());
    }
    return asock;
}

From source file:org.glite.security.trustmanager.tomcat.TMSSLServerSocketFactory.java

public Socket acceptSocket(ServerSocket sSocket) throws IOException {
    LOGGER.debug("TMSSLServerSocketFactory.acceptSocket:");

    SSLSocket asock = null;/*from   w ww. j a  v  a  2  s  .  c o  m*/

    try {
        asock = (SSLSocket) sSocket.accept();
        configureClientAuth(asock);
    } catch (SSLException e) {
        throw new SocketException("SSL handshake error" + e.toString());
    }

    return asock;
}

From source file:org.jsslutils.extra.apachetomcat5.JSSLutilsJSSESocketFactory.java

public Socket acceptSocket(ServerSocket socket) throws IOException {
    SSLSocket asock = null;//from ww w.  j  ava2  s .c  o  m
    try {
        asock = (SSLSocket) socket.accept();
        configureClientAuth(asock);
    } catch (SSLException e) {
        throw new SocketException("SSL handshake error" + e.toString());
    }
    return asock;
}