public void run() throws Exception { Thread[] threads = new Thread[THREADS]; for (int i = 0; i < THREADS; i++) { try { threads[i] = new Thread(peerFactory.newClient(this), "Client " + i); } catch (Exception e) { e.printStackTrace(); return; } threads[i].start(); } try { for (int i = 0; i < THREADS; i++) { threads[i].join(); } } catch (InterruptedException e) { setFailed(); e.printStackTrace(); } if (failed) { throw new Exception("*** Test '" + peerFactory.getName() + "' failed ***"); } else { System.out.println("Test '" + peerFactory.getName() + "' completed successfully"); } }
void interact(final X509Certificate[] chain, String authType, CertificateException cause) throws CertificateException { /* prepare the MTMDecision blocker object */ MTMDecision choice = new MTMDecision(); final int myId = createDecisionId(choice); final String certMessage = certChainMessage(chain, cause); BroadcastReceiver decisionReceiver = new BroadcastReceiver() { public void onReceive(Context ctx, Intent i) { interactResult(i); } }; master.registerReceiver( decisionReceiver, new IntentFilter(DECISION_INTENT + "/" + master.getPackageName())); LaunchRunnable lr = new LaunchRunnable(myId, certMessage); masterHandler.post(lr); Log.d(TAG, "openDecisions: " + openDecisions); Log.d(TAG, "waiting on " + myId); try { synchronized (choice) { choice.wait(); } } catch (InterruptedException e) { e.printStackTrace(); } master.unregisterReceiver(decisionReceiver); if (lr.launchNotifReceiver != null) master.unregisterReceiver(lr.launchNotifReceiver); Log.d(TAG, "finished wait on " + myId + ": " + choice.state); switch (choice.state) { case MTMDecision.DECISION_ALWAYS: storeCert(chain); case MTMDecision.DECISION_ONCE: break; default: throw (cause); } }