Example #1
0
  public static void main(String[] args) throws Exception {

    System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
    /**
     * This test does not establish any connection to the specified URL, hence a dummy URL is used.
     */
    URL foobar = new URL("https://example.com/");

    HttpsURLConnection urlc = (HttpsURLConnection) foobar.openConnection();

    try {
      urlc.getCipherSuite();
    } catch (IllegalStateException e) {
      System.out.print("Caught proper exception: ");
      System.out.println(e.getMessage());
    }

    try {
      urlc.getServerCertificateChain();
    } catch (IllegalStateException e) {
      System.out.print("Caught proper exception: ");
      System.out.println(e.getMessage());
    }

    try {
      urlc.setDefaultHostnameVerifier(null);
    } catch (IllegalArgumentException e) {
      System.out.print("Caught proper exception: ");
      System.out.println(e.getMessage());
    }

    try {
      urlc.setHostnameVerifier(null);
    } catch (IllegalArgumentException e) {
      System.out.print("Caught proper exception: ");
      System.out.println(e.getMessage());
    }

    try {
      urlc.setDefaultSSLSocketFactory(null);
    } catch (IllegalArgumentException e) {
      System.out.print("Caught proper exception: ");
      System.out.println(e.getMessage());
    }

    try {
      urlc.setSSLSocketFactory(null);
    } catch (IllegalArgumentException e) {
      System.out.print("Caught proper exception");
      System.out.println(e.getMessage());
    }
    System.out.println("TESTS PASSED");
  }
        public void handleMessage(Message msg) {
          super.handleMessage(msg);

          try {
            prog.dismiss();
          } catch (
              IllegalArgumentException
                  e) { // this may happen due to race conditions on activity shutdown?
            e.printStackTrace();
          }
          switch (msg.what) {
            case QH_OK:
              buildView();
              break;
            case QH_EMPTY:
              doAlert(null, "Server gave an unexpected response (no signon acknowledgement?)");
              break;
            case QH_ERR_OFX:
              {
                OfxError e = (OfxError) msg.obj;
                switch (e.getErrorCode()) {
                    // case StatusResponse.STATUS_ERROR: // General error (ERROR)
                    // case StatusResponse.STATUS_MFA_REQUIRED: // User credentials are correct, but
                    // further authentication required (ERROR)
                    // case StatusResponse.STATUS_MFA_INVALID: // MFACHALLENGEA contains invalid
                    // information (ERROR)
                  case StatusResponse
                      .STATUS_FI_INVALID: // <FI> Missing or Invalid in <SONRQ> (ERROR)
                    doAlert(e, "Server is rejecting connection details (FI_ID or FI_ORG)");
                    break;
                    // case StatusResponse.STATUS_PINCH_NEEDED: // Must change USERPASS (INFO)
                  case StatusResponse
                      .STATUS_AUTHTOKEN_REQUIRED: // OFX server requires AUTHTOKEN in signon during
                                                  // the next session (ERROR)
                  case StatusResponse
                      .STATUS_BAD_LOGIN: // Signon invalid (see section 2.5.1) (ERROR)
                  case StatusResponse.STATUS_AUTHTOKEN_INVALID: // AUTHTOKEN invalid (ERROR)
                    loginFailure();
                    break;
                  case StatusResponse.STATUS_ACCT_BUSY: // Customer account already in use (ERROR)
                    doAlert(e, "Your account is currently in use");
                    break;
                  case StatusResponse.STATUS_ACCT_LOCKED: // USERPASS Lockout (ERROR)
                    doAlert(e, "Your account has been locked");
                    break;
                    // case StatusResponse.STATUS_EMPTY_REQUEST: // Empty signon transaction not
                    // supported (ERROR)
                    // case StatusResponse.STATUS_PINCH_REQUIRED: // Signon invalid without
                    // supporting pin change request (ERROR)
                    // case StatusResponse.STATUS_CLIENTUID_REJECTED: // CLIENTUID error (ERROR)
                  case StatusResponse
                      .STATUS_CALL_US: // User should contact financial institution (ERROR)
                    doAlert(e, "Please contact your financial institution");
                    break;
                  default:
                    doAlert(e, "Server refused the login");
                    break;
                }
              }

            case QH_ERR_HTTP:
            case QH_ERR_TIMEOUT:
            case QH_ERR_CONN:
            case QH_ERR_SSL:
              doRetryableAlert((Exception) msg.obj, "Unable to connect to server");
              break;

            default:
              doAlert((Exception) msg.obj, OfxProfile.exceptionComment((Exception) msg.obj));
              break;
          }
        }