コード例 #1
0
 @Override
 public void checkServerTrusted(X509Certificate[] chain, String authType)
     throws CertificateException {
   if (!trust.get()) {
     throw new CertificateException("Server certificate not trusted.");
   }
   tm.checkServerTrusted(chain, authType);
 }
コード例 #2
0
 public void checkServerTrusted(X509Certificate[] chain, String authType)
     throws CertificateException {
   try {
     tm.checkServerTrusted(chain, authType);
   } catch (CertificateException e) {
     Object[] answer = {"Proceed", "Exit"};
     int ret =
         JOptionPane.showOptionDialog(
             null,
             e.getCause().getLocalizedMessage() + "\n" + "Continue connecting to this host?",
             "Confirm certificate exception?",
             JOptionPane.YES_NO_OPTION,
             JOptionPane.WARNING_MESSAGE,
             null,
             answer,
             answer[0]);
     if (ret == JOptionPane.NO_OPTION) System.exit(1);
   } catch (java.lang.Exception e) {
     throw new Exception(e.toString());
   }
 }
コード例 #3
0
 @Override
 public X509Certificate[] getAcceptedIssuers() {
   return tm.getAcceptedIssuers();
 }
コード例 #4
0
 @Override
 public void checkClientTrusted(X509Certificate[] chain, String authType)
     throws CertificateException {
   tm.checkClientTrusted(chain, authType);
 }
コード例 #5
0
ファイル: CheckNullEntity.java プロジェクト: wei-tang/JVM
  /*
   * Primary constructor, used to drive remainder of the test.
   *
   * Fork off the other side, then do your work.
   */
  CheckNullEntity() throws Exception {
    String authType = "RSA";
    int failed = 0x3F; // indicate six tests for normal TM
    int extFailed = 0x3F; // indicate six tests for extended TM

    initialize();
    try {
      try {
        trustManager.checkClientTrusted(certChain, (String) null);
      } catch (IllegalArgumentException iae) {
        // get the right exception
        failed >>= 1;
      }

      try {
        trustManager.checkServerTrusted(certChain, (String) null);
      } catch (IllegalArgumentException iae) {
        // get the right exception
        failed >>= 1;
      }

      try {
        trustManager.checkClientTrusted(certChain, "");
      } catch (IllegalArgumentException iae) {
        // get the right exception
        failed >>= 1;
      }

      try {
        trustManager.checkServerTrusted(certChain, "");
      } catch (IllegalArgumentException iae) {
        // get the right exception
        failed >>= 1;
      }

      try {
        trustManager.checkClientTrusted(null, authType);
      } catch (IllegalArgumentException iae) {
        // get the right exception
        failed >>= 1;
      }

      try {
        trustManager.checkServerTrusted(null, authType);
      } catch (IllegalArgumentException iae) {
        // get the right exception
        failed >>= 1;
      }

      if (trustManager instanceof X509ExtendedTrustManager) {
        try {
          ((X509ExtendedTrustManager) trustManager)
              .checkClientTrusted(certChain, (String) null, "localhost", null);
        } catch (IllegalArgumentException iae) {
          // get the right exception
          extFailed >>= 1;
        }

        try {
          ((X509ExtendedTrustManager) trustManager)
              .checkServerTrusted(certChain, (String) null, "localhost", null);
        } catch (IllegalArgumentException iae) {
          // get the right exception
          extFailed >>= 1;
        }

        try {
          ((X509ExtendedTrustManager) trustManager)
              .checkClientTrusted(certChain, "", "localhost", null);
        } catch (IllegalArgumentException iae) {
          // get the right exception
          extFailed >>= 1;
        }

        try {
          ((X509ExtendedTrustManager) trustManager)
              .checkServerTrusted(certChain, "", "localhost", null);
        } catch (IllegalArgumentException iae) {
          // get the right exception
          extFailed >>= 1;
        }

        try {
          ((X509ExtendedTrustManager) trustManager)
              .checkClientTrusted(null, authType, "localhost", null);
        } catch (IllegalArgumentException iae) {
          // get the right exception
          extFailed >>= 1;
        }

        try {
          ((X509ExtendedTrustManager) trustManager)
              .checkServerTrusted(null, authType, "localhost", null);
        } catch (IllegalArgumentException iae) {
          // get the right exception
          extFailed >>= 1;
        }
      } else {
        extFailed = 0;
      }
    } catch (NullPointerException npe) {
      // IllegalArgumentException should be thrown
      failed = 1;
    } catch (Exception e) {
      // ignore
      System.out.println("Got another exception e" + e);
    }

    if (failed != 0 || extFailed != 0) {
      throw new Exception("Should throw IllegalArgumentException");
    }
  }