| 1 19 20 package com.sslexplorer.agent.client.standalone; 21 22 import java.io.IOException ; 23 24 import org.eclipse.swt.graphics.Image; 25 26 import com.maverick.http.AuthenticationCancelledException; 27 import com.maverick.http.HttpAuthenticator; 28 import com.maverick.http.HttpException; 29 import com.maverick.http.UnsupportedAuthenticationException; 30 import com.sslexplorer.agent.client.AgentAction; 31 import com.sslexplorer.agent.client.gui.swt.SWTAuthenticationDialog; 32 import com.sslexplorer.agent.client.gui.swt.SWTRunner; 33 import com.sslexplorer.agent.client.gui.swt.SWTSystemTrayGUI; 34 35 public class StandaloneGUI extends SWTSystemTrayGUI { 36 37 static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(StandaloneGUI.class); 39 41 private Image authImage; 42 43 46 protected void doInit() { 47 super.doInit(); 48 authImage = loadImage(SWTSystemTrayGUI.class, "/images/authentication-dialog.png"); 50 addMenu("Connection"); 51 addMenuItem("Connection", new AgentAction() { 52 53 public void actionPerformed() { 54 try { 55 getAgent().connect("localhost", 443, null, null, false); 56 } catch (IOException e) { 57 e.printStackTrace(); 59 } catch (HttpException e) { 60 e.printStackTrace(); 62 } catch (UnsupportedAuthenticationException e) { 63 e.printStackTrace(); 65 } catch (AuthenticationCancelledException e) { 66 e.printStackTrace(); 68 } 69 } 70 71 public String getAction() { 72 return "Connect"; 73 } 74 75 }); 76 addMenuItem("Connection", new AgentAction() { 77 78 public void actionPerformed() { 79 getAgent().disconnect(); 80 } 81 82 public String getAction() { 83 return "Disconnect"; 84 } 85 }); 86 addMenuSeperator(null); 87 } 88 89 92 protected void exit() { 93 super.exit(); 94 getAgent().startShutdownProcedure(); 95 log.info("Exiting JVM."); System.exit(0); 99 } 100 101 104 public boolean promptForCredentials(final boolean proxy, final HttpAuthenticator authenticator) { 105 return ((Boolean )SWTRunner.syncExec(getDisplay(), new SWTRunner() { 106 public Object doRun() { 107 return new Boolean (SWTAuthenticationDialog.promptForCredentials(proxy, getShell(), authenticator, proxy ? null : authImage)); 108 } 109 110 })).booleanValue(); 111 } 112 113 } 114 | Popular Tags |